Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | #include <glib-object.h> |
| 21 | #include <inttypes.h> |
| 22 | #include <signal.h> |
| 23 | #include <stdio.h> |
| 24 | #include <string.h> |
| 25 | |
| 26 | #include <sys/time.h> |
| 27 | |
| 28 | #include <thrift/c_glib/thrift.h> |
| 29 | #include <thrift/c_glib/protocol/thrift_binary_protocol.h> |
Chandler May | 6dde90b | 2016-01-10 06:01:10 +0000 | [diff] [blame] | 30 | #include <thrift/c_glib/protocol/thrift_compact_protocol.h> |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 31 | #include <thrift/c_glib/protocol/thrift_multiplexed_protocol.h> |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 32 | #include <thrift/c_glib/transport/thrift_buffered_transport.h> |
| 33 | #include <thrift/c_glib/transport/thrift_framed_transport.h> |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 34 | #include <thrift/c_glib/transport/thrift_ssl_socket.h> |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 35 | #include <thrift/c_glib/transport/thrift_socket.h> |
| 36 | #include <thrift/c_glib/transport/thrift_transport.h> |
| 37 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 38 | #include "../gen-c_glib/t_test_second_service.h" |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 39 | #include "../gen-c_glib/t_test_thrift_test.h" |
| 40 | |
| 41 | /* Handle SIGPIPE signals (indicating the server has closed the |
| 42 | connection prematurely) by outputting an error message before |
| 43 | exiting. */ |
| 44 | static void |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 45 | sigpipe_handler (int signal_number) |
| 46 | { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 47 | THRIFT_UNUSED_VAR (signal_number); |
| 48 | |
| 49 | /* Flush standard output to make sure the test results so far are |
| 50 | logged */ |
| 51 | fflush (stdout); |
| 52 | |
| 53 | fputs ("Broken pipe (server closed connection prematurely)\n", stderr); |
| 54 | fflush (stderr); |
| 55 | |
| 56 | /* Re-raise the signal, this time invoking the default signal |
| 57 | handler, to terminate the program */ |
| 58 | raise (SIGPIPE); |
| 59 | } |
| 60 | |
| 61 | /* Compare two gint32 values. Used for sorting and finding integer |
| 62 | values within a GList. */ |
| 63 | static gint |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 64 | gint32_compare (gconstpointer a, gconstpointer b) |
| 65 | { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 66 | gint32 int32_a = *(gint32 *)a; |
| 67 | gint32 int32_b = *(gint32 *)b; |
| 68 | int result = 0; |
| 69 | |
| 70 | if (int32_a < int32_b) |
| 71 | result = -1; |
| 72 | else if (int32_a > int32_b) |
| 73 | result = 1; |
| 74 | |
| 75 | return result; |
| 76 | } |
| 77 | |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 78 | /** |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 79 | * It gets a multiplexed protocol which uses a concrete protocol underneath |
| 80 | * @param protocol_name the fully qualified protocol path (e.g. "binary:multi") |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 81 | * @param transport the underlying transport |
| 82 | * @param service_name the single supported service name |
| 83 | * @todo need to allow multiple services to fully test multiplexed |
| 84 | * @return a multiplexed protocol wrapping the correct underlying protocol |
| 85 | */ |
| 86 | ThriftProtocol * |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 87 | get_multiplexed_protocol(gchar *protocol_name, ThriftTransport *transport, gchar *service_name) |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 88 | { |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 89 | ThriftProtocol * multiplexed_protocol = NULL; |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 90 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 91 | if ( strncmp(protocol_name, "binary:", 7) == 0) { |
| 92 | multiplexed_protocol = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL, |
| 93 | "transport", transport, |
| 94 | NULL); |
| 95 | } else if ( strncmp(protocol_name, "compact:", 8) == 0) { |
| 96 | multiplexed_protocol = g_object_new (THRIFT_TYPE_COMPACT_PROTOCOL, |
| 97 | "transport", transport, |
| 98 | NULL); |
| 99 | } else { |
| 100 | fprintf(stderr, "Unknown multiplex protocol name: %s\n", protocol_name); |
| 101 | return NULL; |
| 102 | } |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 103 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 104 | return g_object_new (THRIFT_TYPE_MULTIPLEXED_PROTOCOL, |
| 105 | "transport", transport, |
| 106 | "protocol", multiplexed_protocol, |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 107 | "service-name", service_name, |
| 108 | NULL); |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 109 | } |
| 110 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 111 | int |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 112 | main (int argc, char **argv) |
| 113 | { |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 114 | static gchar * host = NULL; |
| 115 | static gint port = 9090; |
| 116 | static gboolean ssl = FALSE; |
| 117 | static gchar * transport_option = NULL; |
| 118 | static gchar * protocol_option = NULL; |
| 119 | static gint num_tests = 1; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 120 | |
| 121 | static |
| 122 | GOptionEntry option_entries[] ={ |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 123 | { "host", 'h', 0, G_OPTION_ARG_STRING, &host, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 124 | "Host to connect (=localhost)", NULL }, |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 125 | { "port", 'p', 0, G_OPTION_ARG_INT, &port, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 126 | "Port number to connect (=9090)", NULL }, |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 127 | { "ssl", 's', 0, G_OPTION_ARG_NONE, &ssl, |
| 128 | "Enable SSL", NULL }, |
| 129 | { "transport", 't', 0, G_OPTION_ARG_STRING, &transport_option, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 130 | "Transport: buffered, framed (=buffered)", NULL }, |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 131 | { "protocol", 'r', 0, G_OPTION_ARG_STRING, &protocol_option, |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 132 | "Protocol: binary, compact, multi, multic (=binary)", NULL }, |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 133 | { "testloops", 'n', 0, G_OPTION_ARG_INT, &num_tests, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 134 | "Number of tests (=1)", NULL }, |
| 135 | { NULL } |
| 136 | }; |
| 137 | |
| 138 | struct sigaction sigpipe_action; |
| 139 | |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 140 | GType socket_type = THRIFT_TYPE_SOCKET; |
| 141 | gchar *socket_name = "ip"; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 142 | GType transport_type = THRIFT_TYPE_BUFFERED_TRANSPORT; |
| 143 | gchar *transport_name = "buffered"; |
| 144 | GType protocol_type = THRIFT_TYPE_BINARY_PROTOCOL; |
| 145 | gchar *protocol_name = "binary"; |
| 146 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 147 | ThriftSocket *socket = NULL; |
| 148 | ThriftTransport *transport = NULL; |
| 149 | ThriftProtocol *protocol = NULL; |
| 150 | ThriftProtocol *protocol2 = NULL; // for multiplexed tests |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 151 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 152 | TTestThriftTestIf *test_client = NULL; |
| 153 | TTestSecondServiceIf *second_service = NULL; // for multiplexed tests |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 154 | |
| 155 | struct timeval time_start, time_stop, time_elapsed; |
| 156 | guint64 time_elapsed_usec, time_total_usec = 0; |
| 157 | guint64 time_min_usec = G_MAXUINT64, time_max_usec = 0, time_avg_usec; |
| 158 | |
| 159 | GOptionContext *option_context; |
| 160 | gboolean options_valid = TRUE; |
| 161 | int test_num = 0; |
| 162 | int fail_count = 0; |
| 163 | GError *error = NULL; |
| 164 | |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 165 | #if (!GLIB_CHECK_VERSION (2, 36, 0)) |
| 166 | g_type_init (); |
| 167 | #endif |
| 168 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 169 | /* Configure and parse our command-line options */ |
| 170 | option_context = g_option_context_new (NULL); |
| 171 | g_option_context_add_main_entries (option_context, |
| 172 | option_entries, |
| 173 | NULL); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 174 | if (!g_option_context_parse (option_context, |
| 175 | &argc, |
| 176 | &argv, |
| 177 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 178 | fprintf (stderr, "%s\n", error->message); |
| 179 | return 255; |
| 180 | } |
| 181 | g_option_context_free (option_context); |
| 182 | |
| 183 | /* Set remaining default values for unspecified options */ |
| 184 | if (host == NULL) |
| 185 | host = g_strdup ("localhost"); |
| 186 | |
| 187 | /* Validate the parsed options */ |
Chandler May | 6dde90b | 2016-01-10 06:01:10 +0000 | [diff] [blame] | 188 | if (protocol_option != NULL) { |
| 189 | if (strncmp (protocol_option, "compact", 8) == 0) { |
| 190 | protocol_type = THRIFT_TYPE_COMPACT_PROTOCOL; |
| 191 | protocol_name = "compact"; |
| 192 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 193 | else if (strncmp (protocol_option, "multi", 6) == 0) { |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 194 | protocol_type = THRIFT_TYPE_MULTIPLEXED_PROTOCOL; |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 195 | protocol_name = "binary:multi"; |
| 196 | } |
| 197 | else if (strncmp (protocol_option, "multic", 7) == 0) { |
| 198 | protocol_type = THRIFT_TYPE_MULTIPLEXED_PROTOCOL; |
| 199 | protocol_name = "compact:multic"; |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 200 | } |
| 201 | else if (strncmp (protocol_option, "binary", 7) == 0) { |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 202 | printf("We are going with default protocol\n"); |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 203 | } |
| 204 | else { |
Chandler May | 6dde90b | 2016-01-10 06:01:10 +0000 | [diff] [blame] | 205 | fprintf (stderr, "Unknown protocol type %s\n", protocol_option); |
| 206 | options_valid = FALSE; |
| 207 | } |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | if (transport_option != NULL) { |
| 211 | if (strncmp (transport_option, "framed", 7) == 0) { |
| 212 | transport_type = THRIFT_TYPE_FRAMED_TRANSPORT; |
| 213 | transport_name = "framed"; |
| 214 | } |
| 215 | else if (strncmp (transport_option, "buffered", 9) != 0) { |
| 216 | fprintf (stderr, "Unknown transport type %s\n", transport_option); |
| 217 | options_valid = FALSE; |
| 218 | } |
| 219 | } |
| 220 | |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 221 | if (ssl) { |
| 222 | socket_type = THRIFT_TYPE_SSL_SOCKET; |
| 223 | socket_name = "ip-ssl"; |
| 224 | printf("Type name %s\n", g_type_name (socket_type)); |
| 225 | } |
| 226 | |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 227 | if (!options_valid) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 228 | return 254; |
| 229 | |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 230 | printf ("Connecting (%s/%s) to: %s/%s:%d\n", |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 231 | transport_name, |
| 232 | protocol_name, |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 233 | socket_name, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 234 | host, |
| 235 | port); |
| 236 | |
| 237 | /* Install our SIGPIPE handler, which outputs an error message to |
| 238 | standard error before exiting so testers can know what |
| 239 | happened */ |
| 240 | memset (&sigpipe_action, 0, sizeof (sigpipe_action)); |
| 241 | sigpipe_action.sa_handler = sigpipe_handler; |
| 242 | sigpipe_action.sa_flags = SA_RESETHAND; |
| 243 | sigaction (SIGPIPE, &sigpipe_action, NULL); |
| 244 | |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 245 | if (ssl) { |
| 246 | thrift_ssl_socket_initialize_openssl(); |
| 247 | } |
| 248 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 249 | /* Establish all our connection objects */ |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 250 | socket = g_object_new (socket_type, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 251 | "hostname", host, |
| 252 | "port", port, |
| 253 | NULL); |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 254 | |
| 255 | if (ssl && !thrift_ssl_load_cert_from_file(THRIFT_SSL_SOCKET(socket), "../keys/CA.pem")) { |
| 256 | fprintf(stderr, "Unable to load validation certificate ../keys/CA.pem - did you run in the test/c_glib directory?\n"); |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 257 | g_clear_object (&socket); |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 258 | return 253; |
| 259 | } |
| 260 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 261 | transport = g_object_new (transport_type, |
| 262 | "transport", socket, |
| 263 | NULL); |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 264 | |
| 265 | if(protocol_type==THRIFT_TYPE_MULTIPLEXED_PROTOCOL) { |
| 266 | // TODO: A multiplexed test should also test "Second" (see Java TestServer) |
| 267 | // The context comes from the name of the thrift file. If multiple thrift |
| 268 | // schemas are used we have to redo the way this is done. |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 269 | protocol = get_multiplexed_protocol(protocol_name, transport, "ThriftTest"); |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 270 | if (NULL == protocol) { |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 271 | g_clear_object (&transport); |
| 272 | g_clear_object (&socket); |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 273 | return 252; |
| 274 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 275 | |
| 276 | // Make a second protocol and client running on the same multiplexed transport |
| 277 | protocol2 = get_multiplexed_protocol(protocol_name, transport, "SecondService"); |
| 278 | second_service = g_object_new (T_TEST_TYPE_SECOND_SERVICE_CLIENT, |
| 279 | "input_protocol", protocol2, |
| 280 | "output_protocol", protocol2, |
| 281 | NULL); |
| 282 | |
Gonzalo Aguilar Delgado | bc0082e | 2016-03-04 13:16:22 +0100 | [diff] [blame] | 283 | }else{ |
| 284 | protocol = g_object_new (protocol_type, |
| 285 | "transport", transport, |
| 286 | NULL); |
| 287 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 288 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 289 | test_client = g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT, |
| 290 | "input_protocol", protocol, |
| 291 | "output_protocol", protocol, |
| 292 | NULL); |
| 293 | |
| 294 | /* Execute the actual tests */ |
| 295 | for (test_num = 0; test_num < num_tests; ++test_num) { |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 296 | if (thrift_transport_open (transport, &error)) { |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 297 | gchar *string = NULL; |
| 298 | gboolean boolean = 0; |
| 299 | gint8 byte = 0; |
| 300 | gint32 int32 = 0; |
| 301 | gint64 int64 = 0; |
| 302 | gdouble dub = 0; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 303 | |
| 304 | gint byte_thing, i32_thing, inner_byte_thing, inner_i32_thing; |
| 305 | gint64 i64_thing, inner_i64_thing; |
| 306 | |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 307 | TTestXtruct *xtruct_out, *xtruct_out2, *xtruct_in, *inner_xtruct_in; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 308 | TTestXtruct2 *xtruct2_out, *xtruct2_in; |
| 309 | |
| 310 | GHashTable *map_out, *map_in, *inner_map_in; |
| 311 | GHashTable *set_out, *set_in; |
| 312 | gpointer key, value; |
| 313 | gint32 *i32_key_ptr, *i32_value_ptr; |
| 314 | GHashTableIter hash_table_iter, inner_hash_table_iter; |
| 315 | GList *keys_out, *keys_in, *keys_elem; |
| 316 | |
| 317 | GArray *list_out, *list_in; |
| 318 | |
| 319 | TTestNumberz numberz; |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 320 | TTestNumberz numberz2; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 321 | |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 322 | TTestUserId user_id, *user_id_ptr, *user_id_ptr2; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 323 | |
| 324 | TTestInsanity *insanity_out, *insanity_in; |
| 325 | GHashTable *user_map; |
| 326 | GHashTableIter user_map_iter; |
| 327 | GPtrArray *xtructs; |
| 328 | |
| 329 | TTestXception *xception = NULL; |
| 330 | TTestXception2 *xception2 = NULL; |
| 331 | |
| 332 | gboolean oneway_result; |
| 333 | struct timeval oneway_start, oneway_end, oneway_elapsed; |
| 334 | gint oneway_elapsed_usec; |
| 335 | |
| 336 | gboolean first; |
| 337 | gint32 i, j; |
| 338 | |
| 339 | printf ("Test #%d, connect %s:%d\n", test_num + 1, host, port); |
| 340 | gettimeofday (&time_start, NULL); |
| 341 | |
| 342 | /* These test routines have been ported from the C++ test |
| 343 | client, care being taken to ensure their output remains as |
| 344 | close as possible to the original to facilitate diffs. |
| 345 | |
| 346 | For simplicity comments have been omitted, but every routine |
| 347 | has the same basic structure: |
| 348 | |
| 349 | - Create and populate data structures as necessary. |
| 350 | |
| 351 | - Format and output (to the console) a representation of the |
| 352 | outgoing data. |
| 353 | |
| 354 | - Issue the remote method call to the server. |
| 355 | |
| 356 | - Format and output a representation of the returned data. |
| 357 | |
| 358 | - Verify the returned data matches what was expected. |
| 359 | |
| 360 | - Deallocate any created data structures. |
| 361 | |
| 362 | Note the recognized values and expected behaviour of each |
| 363 | remote method are described in ThriftTest.thrift, which |
| 364 | you'll find in the top-level "test" folder. */ |
| 365 | |
| 366 | /** |
| 367 | * VOID TEST |
| 368 | */ |
| 369 | printf ("testVoid()"); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 370 | if (t_test_thrift_test_if_test_void (test_client, &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 371 | printf (" = void\n"); |
| 372 | } |
| 373 | else { |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 374 | if(error!=NULL){ |
| 375 | printf ("%s\n", error->message); |
| 376 | g_error_free (error); |
| 377 | error = NULL; |
| 378 | } |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 379 | fail_count++; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * STRING TEST |
| 384 | */ |
| 385 | printf ("testString(\"Test\")"); |
| 386 | if (t_test_thrift_test_if_test_string (test_client, |
| 387 | &string, |
| 388 | "Test", |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 389 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 390 | printf (" = \"%s\"\n", string); |
| 391 | if (strncmp (string, "Test", 5) != 0) |
| 392 | fail_count++; |
| 393 | |
| 394 | g_free (string); |
| 395 | string = NULL; |
| 396 | } |
| 397 | else { |
| 398 | printf ("%s\n", error->message); |
| 399 | g_error_free (error); |
| 400 | error = NULL; |
| 401 | |
| 402 | fail_count++; |
| 403 | } |
| 404 | |
| 405 | /** |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 406 | * Multiplexed Test - do this right in the middle of the normal Test Client run |
| 407 | */ |
| 408 | if (second_service) { |
| 409 | printf ("testSecondServiceMultiplexSecondTestString(\"2nd\")"); |
| 410 | if (t_test_second_service_if_secondtest_string (second_service, |
| 411 | &string, |
| 412 | "2nd", |
| 413 | &error)) { |
| 414 | printf (" = \"%s\"\n", string); |
| 415 | if (strncmp (string, "testString(\"2nd\")", 18) != 0) { |
| 416 | ++fail_count; |
| 417 | } |
| 418 | |
| 419 | g_free (string); |
| 420 | string = NULL; |
| 421 | } else { |
| 422 | printf ("%s\n", error->message); |
| 423 | g_error_free (error); |
| 424 | error = NULL; |
| 425 | |
| 426 | ++fail_count; |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /** |
Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 431 | * BOOL TEST |
| 432 | */ |
| 433 | printf ("testByte(true)"); |
| 434 | if (t_test_thrift_test_if_test_bool (test_client, |
| 435 | &boolean, |
| 436 | 1, |
| 437 | &error)) { |
| 438 | printf (" = %s\n", boolean ? "true" : "false"); |
| 439 | if (boolean != 1) |
| 440 | fail_count++; |
| 441 | } |
| 442 | else { |
| 443 | printf ("%s\n", error->message); |
| 444 | g_error_free (error); |
| 445 | error = NULL; |
| 446 | |
| 447 | fail_count++; |
| 448 | } |
| 449 | printf ("testByte(false)"); |
| 450 | if (t_test_thrift_test_if_test_bool (test_client, |
| 451 | &boolean, |
| 452 | 0, |
| 453 | &error)) { |
| 454 | printf (" = %s\n", boolean ? "true" : "false"); |
| 455 | if (boolean != 0) |
| 456 | fail_count++; |
| 457 | } |
| 458 | else { |
| 459 | printf ("%s\n", error->message); |
| 460 | g_error_free (error); |
| 461 | error = NULL; |
| 462 | |
| 463 | fail_count++; |
| 464 | } |
| 465 | |
| 466 | /** |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 467 | * BYTE TEST |
| 468 | */ |
| 469 | printf ("testByte(1)"); |
| 470 | if (t_test_thrift_test_if_test_byte (test_client, |
| 471 | &byte, |
| 472 | 1, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 473 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 474 | printf (" = %d\n", byte); |
| 475 | if (byte != 1) |
| 476 | fail_count++; |
| 477 | } |
| 478 | else { |
| 479 | printf ("%s\n", error->message); |
| 480 | g_error_free (error); |
| 481 | error = NULL; |
| 482 | |
| 483 | fail_count++; |
| 484 | } |
Nobuaki Sukegawa | 30f465d | 2015-10-10 10:45:42 +0900 | [diff] [blame] | 485 | printf ("testByte(-1)"); |
| 486 | if (t_test_thrift_test_if_test_byte (test_client, |
| 487 | &byte, |
| 488 | -1, |
| 489 | &error)) { |
| 490 | printf (" = %d\n", byte); |
| 491 | if (byte != -1) |
| 492 | fail_count++; |
| 493 | } |
| 494 | else { |
| 495 | printf ("%s\n", error->message); |
| 496 | g_error_free (error); |
| 497 | error = NULL; |
| 498 | |
| 499 | fail_count++; |
| 500 | } |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 501 | |
| 502 | /** |
| 503 | * I32 TEST |
| 504 | */ |
| 505 | printf ("testI32(-1)"); |
| 506 | if (t_test_thrift_test_if_test_i32 (test_client, |
| 507 | &int32, |
| 508 | -1, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 509 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 510 | printf (" = %d\n", int32); |
| 511 | if (int32 != -1) |
| 512 | fail_count++; |
| 513 | } |
| 514 | else { |
| 515 | printf ("%s\n", error->message); |
| 516 | g_error_free (error); |
| 517 | error = NULL; |
| 518 | |
| 519 | fail_count++; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * I64 TEST |
| 524 | */ |
| 525 | printf ("testI64(-34359738368)"); |
| 526 | if (t_test_thrift_test_if_test_i64 (test_client, |
| 527 | &int64, |
| 528 | (gint64)-34359738368, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 529 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 530 | printf (" = %" PRId64 "\n", int64); |
| 531 | if (int64 != (gint64)-34359738368) |
| 532 | fail_count++; |
| 533 | } |
| 534 | else { |
| 535 | printf ("%s\n", error->message); |
| 536 | g_error_free (error); |
| 537 | error = NULL; |
| 538 | |
| 539 | fail_count++; |
| 540 | } |
| 541 | |
| 542 | /** |
| 543 | * DOUBLE TEST |
| 544 | */ |
| 545 | printf("testDouble(-5.2098523)"); |
| 546 | if (t_test_thrift_test_if_test_double (test_client, |
| 547 | &dub, |
| 548 | -5.2098523, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 549 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 550 | printf (" = %f\n", dub); |
| 551 | if ((dub - (-5.2098523)) > 0.001) |
| 552 | fail_count++; |
| 553 | } |
| 554 | else { |
| 555 | printf ("%s\n", error->message); |
| 556 | g_error_free (error); |
| 557 | error = NULL; |
| 558 | |
| 559 | fail_count++; |
| 560 | } |
| 561 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 562 | /** |
| 563 | * BINARY TEST |
| 564 | */ |
| 565 | printf ("testBinary(empty)"); |
| 566 | GByteArray *emptyArray = g_byte_array_new(); |
| 567 | GByteArray *result = NULL; |
| 568 | if (t_test_thrift_test_if_test_binary (test_client, |
| 569 | &result, |
| 570 | emptyArray, |
| 571 | &error)) { |
| 572 | GBytes *response = g_byte_array_free_to_bytes(result); // frees result |
| 573 | result = NULL; |
| 574 | gsize siz = g_bytes_get_size(response); |
| 575 | if (siz == 0) { |
| 576 | printf(" = empty\n"); |
| 577 | } else { |
| 578 | printf(" = not empty (%ld bytes)\n", (long)siz); |
| 579 | ++fail_count; |
| 580 | } |
| 581 | g_bytes_unref(response); |
| 582 | } else { |
| 583 | printf ("%s\n", error->message); |
| 584 | g_error_free (error); |
| 585 | error = NULL; |
| 586 | |
| 587 | fail_count++; |
| 588 | } |
| 589 | g_byte_array_unref(emptyArray); |
| 590 | emptyArray = NULL; |
| 591 | |
| 592 | // TODO: add testBinary() with data |
| 593 | printf ("testBinary([-128..127]) = {"); |
| 594 | const signed char bin_data[256] |
| 595 | = {-128, -127, -126, -125, -124, -123, -122, -121, -120, -119, -118, -117, -116, -115, -114, |
| 596 | -113, -112, -111, -110, -109, -108, -107, -106, -105, -104, -103, -102, -101, -100, -99, |
| 597 | -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, |
| 598 | -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, |
| 599 | -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, |
| 600 | -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, |
| 601 | -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, |
| 602 | -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, |
| 603 | -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, |
| 604 | 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
| 605 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, |
| 606 | 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 607 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, |
| 608 | 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 609 | 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, |
| 610 | 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 611 | 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, |
| 612 | 127}; |
| 613 | GByteArray *fullArray = g_byte_array_new(); |
| 614 | g_byte_array_append(fullArray, (guint8 *)(&bin_data[0]), 256); |
| 615 | if (t_test_thrift_test_if_test_binary (test_client, |
| 616 | &result, |
| 617 | fullArray, |
| 618 | &error)) { |
| 619 | GBytes *response = g_byte_array_free_to_bytes(result); // frees result |
| 620 | result = NULL; |
| 621 | gsize siz = g_bytes_get_size(response); |
| 622 | gconstpointer ptr = g_bytes_get_data(response, &siz); |
| 623 | if (siz == 256) { |
| 624 | gboolean first = 1; |
| 625 | gboolean failed = 0; |
| 626 | int i; |
| 627 | |
| 628 | for (i = 0; i < 256; ++i) { |
| 629 | if (!first) |
| 630 | printf(","); |
| 631 | else |
| 632 | first = 0; |
| 633 | int val = ((signed char *)ptr)[i]; |
| 634 | printf("%d", val); |
| 635 | if (!failed && val != i - 128) { |
| 636 | failed = 1; |
| 637 | } |
| 638 | } |
| 639 | printf("} "); |
| 640 | if (failed) { |
| 641 | printf("FAIL (bad content) size %ld OK\n", (long)siz); |
| 642 | ++fail_count; |
| 643 | } else { |
| 644 | printf("OK size %ld OK\n", (long)siz); |
| 645 | } |
| 646 | } else { |
| 647 | printf(" = bad size %ld\n", (long)siz); |
| 648 | ++fail_count; |
| 649 | } |
| 650 | g_bytes_unref(response); |
| 651 | } else { |
| 652 | printf ("%s\n", error->message); |
| 653 | g_error_free (error); |
| 654 | error = NULL; |
| 655 | |
| 656 | fail_count++; |
| 657 | } |
| 658 | g_byte_array_unref(fullArray); |
| 659 | fullArray = NULL; |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 660 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 661 | /** |
| 662 | * STRUCT TEST |
| 663 | */ |
| 664 | printf ("testStruct({\"Zero\", 1, -3, -5})"); |
| 665 | xtruct_out = g_object_new (T_TEST_TYPE_XTRUCT, |
| 666 | "string_thing", "Zero", |
| 667 | "byte_thing", 1, |
| 668 | "i32_thing", -3, |
| 669 | "i64_thing", -5LL, |
| 670 | NULL); |
| 671 | xtruct_in = g_object_new (T_TEST_TYPE_XTRUCT, NULL); |
| 672 | |
| 673 | if (t_test_thrift_test_if_test_struct (test_client, |
| 674 | &xtruct_in, |
| 675 | xtruct_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 676 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 677 | g_object_get (xtruct_in, |
| 678 | "string_thing", &string, |
| 679 | "byte_thing", &byte_thing, |
| 680 | "i32_thing", &i32_thing, |
| 681 | "i64_thing", &i64_thing, |
| 682 | NULL); |
| 683 | |
| 684 | printf (" = {\"%s\", %d, %d, %" PRId64 "}\n", |
| 685 | string, |
| 686 | byte_thing, |
| 687 | i32_thing, |
| 688 | i64_thing); |
| 689 | if ((string == NULL || strncmp (string, "Zero", 5) != 0) || |
| 690 | byte_thing != 1 || |
| 691 | i32_thing != -3 || |
| 692 | i64_thing != (gint64)-5) |
| 693 | fail_count++; |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 694 | |
| 695 | if (string) { |
| 696 | g_free (string); |
| 697 | string = NULL; |
| 698 | } |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 699 | } |
| 700 | else { |
| 701 | printf ("%s\n", error->message); |
| 702 | g_error_free (error); |
| 703 | error = NULL; |
| 704 | |
| 705 | fail_count++; |
| 706 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 707 | // g_clear_object(&xtruct_out); used below |
| 708 | g_clear_object(&xtruct_in); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 709 | |
| 710 | /** |
| 711 | * NESTED STRUCT TEST |
| 712 | */ |
| 713 | printf ("testNest({1, {\"Zero\", 1, -3, -5}), 5}"); |
| 714 | xtruct2_out = g_object_new (T_TEST_TYPE_XTRUCT2, |
| 715 | "byte_thing", 1, |
| 716 | "struct_thing", xtruct_out, |
| 717 | "i32_thing", 5, |
| 718 | NULL); |
| 719 | xtruct2_in = g_object_new (T_TEST_TYPE_XTRUCT2, NULL); |
| 720 | |
| 721 | if (t_test_thrift_test_if_test_nest (test_client, |
| 722 | &xtruct2_in, |
| 723 | xtruct2_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 724 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 725 | g_object_get (xtruct2_in, |
| 726 | "byte_thing", &byte_thing, |
| 727 | "struct_thing", &xtruct_in, |
| 728 | "i32_thing", &i32_thing, |
| 729 | NULL); |
| 730 | g_object_get (xtruct_in, |
| 731 | "string_thing", &string, |
| 732 | "byte_thing", &inner_byte_thing, |
| 733 | "i32_thing", &inner_i32_thing, |
| 734 | "i64_thing", &inner_i64_thing, |
| 735 | NULL); |
| 736 | |
| 737 | printf (" = {%d, {\"%s\", %d, %d, %" PRId64 "}, %d}\n", |
| 738 | byte_thing, |
| 739 | string, |
| 740 | inner_byte_thing, |
| 741 | inner_i32_thing, |
| 742 | inner_i64_thing, |
| 743 | i32_thing); |
| 744 | if (byte_thing != 1 || |
| 745 | (string == NULL || strncmp (string, "Zero", 5) != 0) || |
| 746 | inner_byte_thing != 1 || |
| 747 | inner_i32_thing != -3 || |
| 748 | inner_i64_thing != (gint64)-5 || |
| 749 | i32_thing != 5) |
| 750 | fail_count++; |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 751 | |
| 752 | if (string) { |
| 753 | g_free(string); |
| 754 | string = NULL; |
| 755 | } |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 756 | } |
| 757 | else { |
| 758 | printf ("%s\n", error->message); |
| 759 | g_error_free (error); |
| 760 | error = NULL; |
| 761 | |
| 762 | fail_count++; |
| 763 | } |
| 764 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 765 | g_clear_object(&xtruct_in); |
| 766 | g_clear_object(&xtruct2_in); |
| 767 | g_clear_object(&xtruct2_out); |
| 768 | g_clear_object(&xtruct_out); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 769 | |
| 770 | /** |
| 771 | * MAP TEST |
| 772 | */ |
| 773 | map_out = g_hash_table_new_full (g_int_hash, |
| 774 | g_int_equal, |
| 775 | g_free, |
| 776 | g_free); |
| 777 | for (i = 0; i < 5; ++i) { |
| 778 | i32_key_ptr = g_malloc (sizeof *i32_key_ptr); |
| 779 | i32_value_ptr = g_malloc (sizeof *i32_value_ptr); |
| 780 | |
| 781 | *i32_key_ptr = i; |
| 782 | *i32_value_ptr = i - 10; |
| 783 | |
| 784 | g_hash_table_insert (map_out, i32_key_ptr, i32_value_ptr); |
| 785 | } |
| 786 | printf ("testMap({"); |
| 787 | first = TRUE; |
| 788 | g_hash_table_iter_init (&hash_table_iter, map_out); |
| 789 | while (g_hash_table_iter_next (&hash_table_iter, |
| 790 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 791 | &value)) { |
| 792 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 793 | first = FALSE; |
| 794 | else |
| 795 | printf (", "); |
| 796 | |
| 797 | printf ("%d => %d", *(gint32 *)key, *(gint32 *)value); |
| 798 | } |
| 799 | printf ("})"); |
| 800 | |
| 801 | map_in = g_hash_table_new_full (g_int_hash, |
| 802 | g_int_equal, |
| 803 | g_free, |
| 804 | g_free); |
| 805 | |
| 806 | if (t_test_thrift_test_if_test_map (test_client, |
| 807 | &map_in, |
| 808 | map_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 809 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 810 | printf (" = {"); |
| 811 | first = TRUE; |
| 812 | g_hash_table_iter_init (&hash_table_iter, map_in); |
| 813 | while (g_hash_table_iter_next (&hash_table_iter, |
| 814 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 815 | &value)) { |
| 816 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 817 | first = FALSE; |
| 818 | else |
| 819 | printf (", "); |
| 820 | |
| 821 | printf ("%d => %d", *(gint32 *)key, *(gint32 *)value); |
| 822 | } |
| 823 | printf ("}\n"); |
| 824 | |
| 825 | if (g_hash_table_size (map_in) != g_hash_table_size (map_out)) |
| 826 | fail_count++; |
| 827 | else { |
| 828 | g_hash_table_iter_init (&hash_table_iter, map_out); |
| 829 | while (g_hash_table_iter_next (&hash_table_iter, |
| 830 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 831 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 832 | gpointer in_value = g_hash_table_lookup (map_in, key); |
| 833 | if (in_value == NULL || |
| 834 | *(gint32 *)in_value != *(gint32 *)value) { |
| 835 | fail_count++; |
| 836 | break; |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | } |
| 841 | else { |
| 842 | printf ("%s\n", error->message); |
| 843 | g_error_free (error); |
| 844 | error = NULL; |
| 845 | |
| 846 | fail_count++; |
| 847 | } |
| 848 | |
| 849 | g_hash_table_unref (map_in); |
| 850 | g_hash_table_unref (map_out); |
| 851 | |
| 852 | /** |
| 853 | * STRING MAP TEST |
| 854 | */ |
| 855 | map_out = g_hash_table_new_full (g_str_hash, |
| 856 | g_str_equal, |
| 857 | NULL, |
| 858 | NULL); |
| 859 | g_hash_table_insert (map_out, "a", "2"); |
| 860 | g_hash_table_insert (map_out, "b", "blah"); |
| 861 | g_hash_table_insert (map_out, "some", "thing"); |
| 862 | printf ("testStringMap({"); |
| 863 | first = TRUE; |
| 864 | g_hash_table_iter_init (&hash_table_iter, map_out); |
| 865 | while (g_hash_table_iter_next (&hash_table_iter, |
| 866 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 867 | &value)) { |
| 868 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 869 | first = FALSE; |
| 870 | else |
| 871 | printf (", "); |
| 872 | |
| 873 | printf ("\"%s\" => \"%s\"", (gchar *)key, (gchar *)value); |
| 874 | } |
| 875 | printf (")}"); |
| 876 | |
| 877 | map_in = g_hash_table_new_full (g_str_hash, |
| 878 | g_str_equal, |
| 879 | g_free, |
| 880 | g_free); |
| 881 | |
| 882 | if (t_test_thrift_test_if_test_string_map (test_client, |
| 883 | &map_in, |
| 884 | map_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 885 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 886 | printf (" = {"); |
| 887 | first = TRUE; |
| 888 | g_hash_table_iter_init (&hash_table_iter, map_in); |
| 889 | while (g_hash_table_iter_next (&hash_table_iter, |
| 890 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 891 | &value)) { |
| 892 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 893 | first = FALSE; |
| 894 | else |
| 895 | printf (", "); |
| 896 | |
| 897 | printf ("\"%s\" => \"%s\"", (gchar *)key, (gchar *)value); |
| 898 | } |
| 899 | printf ("}\n"); |
| 900 | |
| 901 | if (g_hash_table_size (map_in) != g_hash_table_size (map_out)) |
| 902 | fail_count++; |
| 903 | else { |
| 904 | g_hash_table_iter_init (&hash_table_iter, map_out); |
| 905 | while (g_hash_table_iter_next (&hash_table_iter, |
| 906 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 907 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 908 | gpointer in_value = g_hash_table_lookup (map_in, key); |
| 909 | if (in_value == NULL || |
| 910 | strcmp ((gchar *)in_value, (gchar *)value) != 0) { |
| 911 | fail_count++; |
| 912 | break; |
| 913 | } |
| 914 | } |
| 915 | } |
| 916 | } |
| 917 | else { |
| 918 | printf ("%s\n", error->message); |
| 919 | g_error_free (error); |
| 920 | error = NULL; |
| 921 | |
| 922 | fail_count++; |
| 923 | } |
| 924 | |
| 925 | g_hash_table_unref (map_in); |
| 926 | g_hash_table_unref (map_out); |
| 927 | |
| 928 | /** |
| 929 | * SET TEST |
| 930 | */ |
| 931 | set_out = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL); |
| 932 | for (i = -2; i < 3; ++i) { |
| 933 | i32_key_ptr = g_malloc (sizeof *i32_key_ptr); |
| 934 | *i32_key_ptr = i; |
| 935 | |
| 936 | g_hash_table_insert (set_out, i32_key_ptr, NULL); |
| 937 | } |
| 938 | printf ("testSet({"); |
| 939 | first = TRUE; |
| 940 | keys_out = g_hash_table_get_keys (set_out); |
| 941 | keys_elem = keys_out; |
| 942 | while (keys_elem != NULL) { |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 943 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 944 | first = FALSE; |
| 945 | else |
| 946 | printf (", "); |
| 947 | |
| 948 | printf ("%d", *(gint32 *)keys_elem->data); |
| 949 | |
| 950 | keys_elem = keys_elem->next; |
| 951 | } |
| 952 | printf ("})"); |
| 953 | |
| 954 | set_in = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL); |
| 955 | |
| 956 | if (t_test_thrift_test_if_test_set (test_client, |
| 957 | &set_in, |
| 958 | set_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 959 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 960 | printf(" = {"); |
| 961 | first = TRUE; |
| 962 | keys_in = g_hash_table_get_keys (set_in); |
| 963 | keys_elem = keys_in; |
| 964 | while (keys_elem != NULL) { |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 965 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 966 | first = FALSE; |
| 967 | else |
| 968 | printf (", "); |
| 969 | |
| 970 | printf ("%d", *(gint32 *)keys_elem->data); |
| 971 | |
| 972 | keys_elem = keys_elem->next; |
| 973 | } |
| 974 | printf ("}\n"); |
| 975 | |
| 976 | if (g_list_length (keys_in) != g_list_length (keys_out)) |
| 977 | fail_count++; |
| 978 | else { |
| 979 | keys_elem = keys_out; |
| 980 | while (keys_elem != NULL) { |
| 981 | if (g_list_find_custom (keys_in, |
| 982 | keys_elem->data, |
| 983 | gint32_compare) == NULL) { |
| 984 | fail_count++; |
| 985 | break; |
| 986 | } |
| 987 | |
| 988 | keys_elem = keys_elem->next; |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | g_list_free (keys_in); |
| 993 | } |
| 994 | else { |
| 995 | printf ("%s\n", error->message); |
| 996 | g_error_free (error); |
| 997 | error = NULL; |
| 998 | |
| 999 | fail_count++; |
| 1000 | } |
| 1001 | |
| 1002 | g_hash_table_unref (set_in); |
| 1003 | g_list_free (keys_out); |
| 1004 | g_hash_table_unref (set_out); |
| 1005 | |
| 1006 | /** |
| 1007 | * LIST TEST |
| 1008 | */ |
| 1009 | list_out = g_array_new (FALSE, TRUE, sizeof (gint32)); |
| 1010 | for (i = -2; i < 3; ++i) { |
| 1011 | g_array_append_val (list_out, i); |
| 1012 | } |
| 1013 | printf ("testList({"); |
| 1014 | first = TRUE; |
| 1015 | for (i = 0; i < (gint32)list_out->len; ++i) { |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1016 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1017 | first = FALSE; |
| 1018 | else |
| 1019 | printf (", "); |
| 1020 | |
| 1021 | printf ("%d", g_array_index (list_out, gint32, i)); |
| 1022 | } |
| 1023 | printf ("})"); |
| 1024 | |
| 1025 | list_in = g_array_new (FALSE, TRUE, sizeof (gint32)); |
| 1026 | |
| 1027 | if (t_test_thrift_test_if_test_list (test_client, |
| 1028 | &list_in, |
| 1029 | list_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1030 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1031 | printf (" = {"); |
| 1032 | first = TRUE; |
| 1033 | for (i = 0; i < (gint32)list_in->len; ++i) { |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1034 | if (first) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1035 | first = FALSE; |
| 1036 | else |
| 1037 | printf (", "); |
| 1038 | |
| 1039 | printf ("%d", g_array_index (list_in, gint32, i)); |
| 1040 | } |
| 1041 | printf ("}\n"); |
| 1042 | |
| 1043 | if (list_in->len != list_out->len || |
| 1044 | memcmp (list_in->data, |
| 1045 | list_out->data, |
| 1046 | list_in->len * sizeof (gint32)) != 0) |
| 1047 | fail_count++; |
| 1048 | } |
| 1049 | else { |
| 1050 | printf ("%s\n", error->message); |
| 1051 | g_error_free (error); |
| 1052 | error = NULL; |
| 1053 | |
| 1054 | fail_count++; |
| 1055 | } |
| 1056 | |
| 1057 | g_array_unref (list_in); |
| 1058 | g_array_unref (list_out); |
| 1059 | |
| 1060 | /** |
| 1061 | * ENUM TEST |
| 1062 | */ |
| 1063 | printf("testEnum(ONE)"); |
| 1064 | if (t_test_thrift_test_if_test_enum (test_client, |
| 1065 | &numberz, |
| 1066 | T_TEST_NUMBERZ_ONE, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1067 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1068 | printf(" = %d\n", numberz); |
| 1069 | if (numberz != T_TEST_NUMBERZ_ONE) |
| 1070 | fail_count++; |
| 1071 | } |
| 1072 | else { |
| 1073 | printf ("%s\n", error->message); |
| 1074 | g_error_free (error); |
| 1075 | error = NULL; |
| 1076 | |
| 1077 | fail_count++; |
| 1078 | } |
| 1079 | |
| 1080 | printf("testEnum(TWO)"); |
| 1081 | if (t_test_thrift_test_if_test_enum (test_client, |
| 1082 | &numberz, |
| 1083 | T_TEST_NUMBERZ_TWO, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1084 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1085 | printf(" = %d\n", numberz); |
| 1086 | if (numberz != T_TEST_NUMBERZ_TWO) |
| 1087 | fail_count++; |
| 1088 | } |
| 1089 | else { |
| 1090 | printf ("%s\n", error->message); |
| 1091 | g_error_free (error); |
| 1092 | error = NULL; |
| 1093 | |
| 1094 | fail_count++; |
| 1095 | } |
| 1096 | |
| 1097 | printf("testEnum(THREE)"); |
| 1098 | if (t_test_thrift_test_if_test_enum (test_client, |
| 1099 | &numberz, |
| 1100 | T_TEST_NUMBERZ_THREE, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1101 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1102 | printf(" = %d\n", numberz); |
| 1103 | if (numberz != T_TEST_NUMBERZ_THREE) |
| 1104 | fail_count++; |
| 1105 | } |
| 1106 | else { |
| 1107 | printf ("%s\n", error->message); |
| 1108 | g_error_free (error); |
| 1109 | error = NULL; |
| 1110 | |
| 1111 | fail_count++; |
| 1112 | } |
| 1113 | |
| 1114 | printf("testEnum(FIVE)"); |
| 1115 | if (t_test_thrift_test_if_test_enum (test_client, |
| 1116 | &numberz, |
| 1117 | T_TEST_NUMBERZ_FIVE, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1118 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1119 | printf(" = %d\n", numberz); |
| 1120 | if (numberz != T_TEST_NUMBERZ_FIVE) |
| 1121 | fail_count++; |
| 1122 | } |
| 1123 | else { |
| 1124 | printf ("%s\n", error->message); |
| 1125 | g_error_free (error); |
| 1126 | error = NULL; |
| 1127 | |
| 1128 | fail_count++; |
| 1129 | } |
| 1130 | |
| 1131 | printf("testEnum(EIGHT)"); |
| 1132 | if (t_test_thrift_test_if_test_enum (test_client, |
| 1133 | &numberz, |
| 1134 | T_TEST_NUMBERZ_EIGHT, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1135 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1136 | printf(" = %d\n", numberz); |
| 1137 | if (numberz != T_TEST_NUMBERZ_EIGHT) |
| 1138 | fail_count++; |
| 1139 | } |
| 1140 | else { |
| 1141 | printf ("%s\n", error->message); |
| 1142 | g_error_free (error); |
| 1143 | error = NULL; |
| 1144 | |
| 1145 | fail_count++; |
| 1146 | } |
| 1147 | |
| 1148 | /** |
| 1149 | * TYPEDEF TEST |
| 1150 | */ |
| 1151 | printf ("testTypedef(309858235082523)"); |
| 1152 | if (t_test_thrift_test_if_test_typedef (test_client, |
| 1153 | &user_id, |
| 1154 | 309858235082523LL, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1155 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1156 | printf(" = %" PRId64 "\n", user_id); |
| 1157 | if (user_id != 309858235082523LL) |
| 1158 | fail_count++; |
| 1159 | } |
| 1160 | else { |
| 1161 | printf ("%s\n", error->message); |
| 1162 | g_error_free (error); |
| 1163 | error = NULL; |
| 1164 | |
| 1165 | fail_count++; |
| 1166 | } |
| 1167 | |
| 1168 | /** |
| 1169 | * NESTED MAP TEST |
| 1170 | */ |
| 1171 | printf ("testMapMap(1)"); |
| 1172 | map_in = g_hash_table_new_full (g_int_hash, |
| 1173 | g_int_equal, |
| 1174 | g_free, |
| 1175 | (GDestroyNotify)g_hash_table_unref); |
| 1176 | if (t_test_thrift_test_if_test_map_map (test_client, |
| 1177 | &map_in, |
| 1178 | 1, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1179 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1180 | g_hash_table_iter_init (&hash_table_iter, map_in); |
| 1181 | |
| 1182 | printf (" = {"); |
| 1183 | while (g_hash_table_iter_next (&hash_table_iter, |
| 1184 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1185 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1186 | printf ("%d => {", *(gint32 *)key); |
| 1187 | |
| 1188 | g_hash_table_iter_init (&inner_hash_table_iter, |
| 1189 | (GHashTable *)value); |
| 1190 | while (g_hash_table_iter_next (&inner_hash_table_iter, |
| 1191 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1192 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1193 | printf ("%d => %d, ", *(gint32 *)key, *(gint32 *)value); |
| 1194 | } |
| 1195 | |
| 1196 | printf ("}, "); |
| 1197 | } |
| 1198 | printf ("}\n"); |
| 1199 | |
| 1200 | if (g_hash_table_size (map_in) != 2) |
| 1201 | fail_count++; |
| 1202 | else { |
| 1203 | gint32 inner_keys[] = {1, 2, 3, 4}; |
| 1204 | gint32 i32_key; |
| 1205 | |
| 1206 | i32_key = -4; |
| 1207 | inner_map_in = g_hash_table_lookup (map_in, &i32_key); |
| 1208 | if (inner_map_in == NULL || |
| 1209 | g_hash_table_size (inner_map_in) != 4) |
| 1210 | fail_count++; |
| 1211 | else { |
| 1212 | keys_in = g_hash_table_get_keys (inner_map_in); |
| 1213 | keys_in = g_list_sort (keys_in, gint32_compare); |
| 1214 | |
| 1215 | for (i = 0; i < 4; i++) { |
| 1216 | keys_elem = g_list_nth (keys_in, 3 - i); |
| 1217 | |
| 1218 | if (*(gint32 *)keys_elem->data != (-1 * inner_keys[i]) || |
| 1219 | *(gint32 *)g_hash_table_lookup (inner_map_in, |
| 1220 | keys_elem->data) != |
| 1221 | (-1 * inner_keys[i])) { |
| 1222 | fail_count++; |
| 1223 | break; |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | g_list_free (keys_in); |
| 1228 | } |
| 1229 | |
| 1230 | i32_key = 4; |
| 1231 | inner_map_in = g_hash_table_lookup (map_in, &i32_key); |
| 1232 | if (inner_map_in == NULL || |
| 1233 | g_hash_table_size (inner_map_in) != 4) |
| 1234 | fail_count++; |
| 1235 | else { |
| 1236 | keys_in = g_hash_table_get_keys (inner_map_in); |
| 1237 | keys_in = g_list_sort (keys_in, gint32_compare); |
| 1238 | |
| 1239 | for (i = 0; i < 4; i++) { |
| 1240 | keys_elem = g_list_nth (keys_in, i); |
| 1241 | |
| 1242 | if (*(gint32 *)keys_elem->data != inner_keys[i] || |
| 1243 | *(gint32 *)g_hash_table_lookup (inner_map_in, |
| 1244 | keys_elem->data) != |
| 1245 | inner_keys[i]) { |
| 1246 | fail_count++; |
| 1247 | break; |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | g_list_free (keys_in); |
| 1252 | } |
| 1253 | } |
| 1254 | } |
| 1255 | else { |
| 1256 | printf ("%s\n", error->message); |
| 1257 | g_error_free (error); |
| 1258 | error = NULL; |
| 1259 | |
| 1260 | fail_count++; |
| 1261 | } |
| 1262 | |
| 1263 | g_hash_table_unref (map_in); |
| 1264 | |
| 1265 | /** |
| 1266 | * INSANITY TEST |
| 1267 | */ |
| 1268 | insanity_out = g_object_new (T_TEST_TYPE_INSANITY, NULL); |
| 1269 | g_object_get (insanity_out, |
| 1270 | "userMap", &user_map, |
| 1271 | "xtructs", &xtructs, |
| 1272 | NULL); |
| 1273 | |
| 1274 | numberz = T_TEST_NUMBERZ_FIVE; |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 1275 | numberz2 = T_TEST_NUMBERZ_EIGHT; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1276 | user_id_ptr = g_malloc (sizeof *user_id_ptr); |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 1277 | *user_id_ptr = 5; |
| 1278 | user_id_ptr2 = g_malloc (sizeof *user_id_ptr); |
| 1279 | *user_id_ptr2 = 8; |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1280 | g_hash_table_insert (user_map, (gpointer)numberz, user_id_ptr); |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 1281 | g_hash_table_insert (user_map, (gpointer)numberz2, user_id_ptr2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1282 | g_hash_table_unref (user_map); |
| 1283 | |
| 1284 | xtruct_out = g_object_new (T_TEST_TYPE_XTRUCT, |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 1285 | "string_thing", "Hello2", |
| 1286 | "byte_thing", 2, |
| 1287 | "i32_thing", 2, |
| 1288 | "i64_thing", 2LL, |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1289 | NULL); |
Nobuaki Sukegawa | 01ede04 | 2015-09-29 02:16:53 +0900 | [diff] [blame] | 1290 | xtruct_out2 = g_object_new (T_TEST_TYPE_XTRUCT, |
| 1291 | "string_thing", "Goodbye4", |
| 1292 | "byte_thing", 4, |
| 1293 | "i32_thing", 4, |
| 1294 | "i64_thing", 4LL, |
| 1295 | NULL); |
| 1296 | g_ptr_array_add (xtructs, xtruct_out2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1297 | g_ptr_array_add (xtructs, xtruct_out); |
| 1298 | g_ptr_array_unref (xtructs); |
| 1299 | |
| 1300 | map_in = g_hash_table_new_full (g_int64_hash, |
| 1301 | g_int64_equal, |
| 1302 | g_free, |
| 1303 | (GDestroyNotify)g_hash_table_unref); |
| 1304 | |
| 1305 | printf("testInsanity()"); |
| 1306 | if (t_test_thrift_test_if_test_insanity (test_client, |
| 1307 | &map_in, |
| 1308 | insanity_out, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1309 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1310 | printf (" = {"); |
| 1311 | g_hash_table_iter_init (&hash_table_iter, map_in); |
| 1312 | while (g_hash_table_iter_next (&hash_table_iter, |
| 1313 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1314 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1315 | printf ("%" PRId64 " => {", *(TTestUserId *)key); |
| 1316 | |
| 1317 | g_hash_table_iter_init (&inner_hash_table_iter, |
| 1318 | (GHashTable *)value); |
| 1319 | while (g_hash_table_iter_next (&inner_hash_table_iter, |
| 1320 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1321 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1322 | printf ("%d => {", (TTestNumberz)key); |
| 1323 | |
| 1324 | g_object_get ((TTestInsanity *)value, |
| 1325 | "userMap", &user_map, |
| 1326 | "xtructs", &xtructs, |
| 1327 | NULL); |
| 1328 | |
| 1329 | printf ("{"); |
| 1330 | g_hash_table_iter_init (&user_map_iter, user_map); |
| 1331 | while (g_hash_table_iter_next (&user_map_iter, |
| 1332 | &key, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1333 | &value)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1334 | printf ("%d => %" PRId64 ", ", |
| 1335 | (TTestNumberz)key, |
| 1336 | *(TTestUserId *)value); |
| 1337 | } |
| 1338 | printf ("}, "); |
| 1339 | g_hash_table_unref (user_map); |
| 1340 | |
| 1341 | printf("{"); |
| 1342 | for (i = 0; i < (gint32)xtructs->len; ++i) { |
| 1343 | xtruct_in = g_ptr_array_index (xtructs, i); |
| 1344 | g_object_get (xtruct_in, |
| 1345 | "string_thing", &string, |
| 1346 | "byte_thing", &byte_thing, |
| 1347 | "i32_thing", &i32_thing, |
| 1348 | "i64_thing", &i64_thing, |
| 1349 | NULL); |
| 1350 | |
| 1351 | printf ("{\"%s\", %d, %d, %" PRId64 "}, ", |
| 1352 | string, |
| 1353 | byte_thing, |
| 1354 | i32_thing, |
| 1355 | i64_thing); |
| 1356 | } |
| 1357 | printf ("}"); |
| 1358 | g_ptr_array_unref (xtructs); |
| 1359 | |
| 1360 | printf ("}, "); |
| 1361 | } |
| 1362 | printf("}, "); |
| 1363 | } |
| 1364 | printf("}\n"); |
| 1365 | |
| 1366 | if (g_hash_table_size (map_in) != 2) |
| 1367 | fail_count++; |
| 1368 | else { |
| 1369 | TTestNumberz numberz_key_values[] = { |
| 1370 | T_TEST_NUMBERZ_TWO, T_TEST_NUMBERZ_THREE |
| 1371 | }; |
| 1372 | gint user_map_values[] = { 5, 8 }; |
| 1373 | TTestUserId user_id_key; |
| 1374 | |
| 1375 | user_id_key = 1; |
| 1376 | inner_map_in = g_hash_table_lookup (map_in, &user_id_key); |
| 1377 | if (inner_map_in == NULL || |
| 1378 | g_hash_table_size (inner_map_in) != 2) |
| 1379 | fail_count++; |
| 1380 | else { |
| 1381 | TTestNumberz numberz_key; |
| 1382 | |
| 1383 | for (i = 0; i < 2; ++i) { |
| 1384 | numberz_key = numberz_key_values[i]; |
| 1385 | insanity_in = |
| 1386 | g_hash_table_lookup (inner_map_in, |
| 1387 | (gconstpointer)numberz_key); |
| 1388 | if (insanity_in == NULL) |
| 1389 | fail_count++; |
| 1390 | else { |
| 1391 | g_object_get (insanity_in, |
| 1392 | "userMap", &user_map, |
| 1393 | "xtructs", &xtructs, |
| 1394 | NULL); |
| 1395 | |
| 1396 | if (user_map == NULL) |
| 1397 | fail_count++; |
| 1398 | else { |
| 1399 | if (g_hash_table_size (user_map) != 2) |
| 1400 | fail_count++; |
| 1401 | else { |
| 1402 | for (j = 0; j < 2; ++j) { |
| 1403 | numberz_key = (TTestNumberz)user_map_values[j]; |
| 1404 | |
| 1405 | value = |
| 1406 | g_hash_table_lookup (user_map, |
| 1407 | (gconstpointer)numberz_key); |
| 1408 | if (value == NULL || |
| 1409 | *(TTestUserId *)value != (TTestUserId)user_map_values[j]) |
| 1410 | fail_count++; |
| 1411 | } |
| 1412 | } |
| 1413 | |
| 1414 | g_hash_table_unref (user_map); |
| 1415 | } |
| 1416 | |
| 1417 | if (xtructs == NULL) |
| 1418 | fail_count++; |
| 1419 | else { |
| 1420 | if (xtructs->len != 2) |
| 1421 | fail_count++; |
| 1422 | else { |
| 1423 | xtruct_in = g_ptr_array_index (xtructs, 0); |
| 1424 | g_object_get (xtruct_in, |
| 1425 | "string_thing", &string, |
| 1426 | "byte_thing", &byte_thing, |
| 1427 | "i32_thing", &i32_thing, |
| 1428 | "i64_thing", &i64_thing, |
| 1429 | NULL); |
| 1430 | if ((string == NULL || |
| 1431 | strncmp (string, "Goodbye4", 9) != 0) || |
| 1432 | byte_thing != 4 || |
| 1433 | i32_thing != 4 || |
| 1434 | i64_thing != 4) |
| 1435 | fail_count++; |
| 1436 | |
| 1437 | if (string != NULL) |
| 1438 | g_free (string); |
| 1439 | |
| 1440 | xtruct_in = g_ptr_array_index (xtructs, 1); |
| 1441 | g_object_get (xtruct_in, |
| 1442 | "string_thing", &string, |
| 1443 | "byte_thing", &byte_thing, |
| 1444 | "i32_thing", &i32_thing, |
| 1445 | "i64_thing", &i64_thing, |
| 1446 | NULL); |
| 1447 | if ((string == NULL || |
| 1448 | strncmp (string, "Hello2", 7) != 0) || |
| 1449 | byte_thing != 2 || |
| 1450 | i32_thing != 2 || |
| 1451 | i64_thing != 2) |
| 1452 | fail_count++; |
| 1453 | |
| 1454 | if (string != NULL) |
| 1455 | g_free (string); |
| 1456 | } |
| 1457 | |
| 1458 | g_ptr_array_unref (xtructs); |
| 1459 | } |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | |
| 1464 | user_id_key = 2; |
| 1465 | inner_map_in = g_hash_table_lookup (map_in, &user_id_key); |
| 1466 | if (inner_map_in == NULL || |
| 1467 | g_hash_table_size (inner_map_in) != 1) |
| 1468 | fail_count++; |
| 1469 | else { |
| 1470 | insanity_in = |
| 1471 | g_hash_table_lookup (inner_map_in, |
| 1472 | (gconstpointer)T_TEST_NUMBERZ_SIX); |
| 1473 | if (insanity_in == NULL) |
| 1474 | fail_count++; |
| 1475 | else { |
| 1476 | g_object_get (insanity_in, |
| 1477 | "userMap", &user_map, |
| 1478 | "xtructs", &xtructs, |
| 1479 | NULL); |
| 1480 | |
| 1481 | if (user_map == NULL) |
| 1482 | fail_count++; |
| 1483 | else { |
| 1484 | if (g_hash_table_size (user_map) != 0) |
| 1485 | fail_count++; |
| 1486 | |
| 1487 | g_hash_table_unref (user_map); |
| 1488 | } |
| 1489 | |
| 1490 | if (xtructs == NULL) |
| 1491 | fail_count++; |
| 1492 | else { |
| 1493 | if (xtructs->len != 0) |
| 1494 | fail_count++; |
| 1495 | |
| 1496 | g_ptr_array_unref (xtructs); |
| 1497 | } |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | } |
| 1502 | else { |
| 1503 | printf ("%s\n", error->message); |
| 1504 | g_error_free (error); |
| 1505 | error = NULL; |
| 1506 | |
| 1507 | fail_count++; |
| 1508 | } |
| 1509 | |
| 1510 | g_hash_table_unref (map_in); |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1511 | g_clear_object (&insanity_out); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1512 | |
| 1513 | /* test exception */ |
| 1514 | printf ("testClient.testException(\"Xception\") =>"); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1515 | if (!t_test_thrift_test_if_test_exception (test_client, |
| 1516 | "Xception", |
| 1517 | &xception, |
| 1518 | &error) && |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1519 | xception != NULL) { |
| 1520 | g_object_get (xception, |
| 1521 | "errorCode", &int32, |
| 1522 | "message", &string, |
| 1523 | NULL); |
| 1524 | printf (" {%u, \"%s\"}\n", int32, string); |
| 1525 | g_free (string); |
| 1526 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1527 | g_clear_object (&xception); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1528 | |
| 1529 | g_error_free (error); |
| 1530 | error = NULL; |
| 1531 | } |
| 1532 | else { |
| 1533 | printf (" void\nFAILURE\n"); |
| 1534 | fail_count++; |
| 1535 | |
| 1536 | if (xception != NULL) { |
| 1537 | g_object_unref (xception); |
| 1538 | xception = NULL; |
| 1539 | } |
| 1540 | |
| 1541 | if (error != NULL) { |
| 1542 | g_error_free (error); |
| 1543 | error = NULL; |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | printf ("testClient.testException(\"TException\") =>"); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1548 | if (!t_test_thrift_test_if_test_exception (test_client, |
| 1549 | "TException", |
| 1550 | &xception, |
| 1551 | &error) && |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1552 | xception == NULL && |
| 1553 | error != NULL) { |
| 1554 | printf (" Caught TException\n"); |
| 1555 | |
| 1556 | g_error_free (error); |
| 1557 | error = NULL; |
| 1558 | } |
| 1559 | else { |
| 1560 | printf (" void\nFAILURE\n"); |
| 1561 | fail_count++; |
| 1562 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1563 | g_clear_object (&xception); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1564 | |
| 1565 | if (error != NULL) { |
| 1566 | g_error_free (error); |
| 1567 | error = NULL; |
| 1568 | } |
| 1569 | } |
| 1570 | |
| 1571 | printf ("testClient.testException(\"success\") =>"); |
| 1572 | if (t_test_thrift_test_if_test_exception (test_client, |
| 1573 | "success", |
| 1574 | &xception, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1575 | &error)) |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1576 | printf (" void\n"); |
| 1577 | else { |
| 1578 | printf (" void\nFAILURE\n"); |
| 1579 | fail_count++; |
| 1580 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1581 | g_clear_object (&xception); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1582 | |
| 1583 | g_error_free (error); |
| 1584 | error = NULL; |
| 1585 | } |
| 1586 | |
| 1587 | g_assert (error == NULL); |
| 1588 | |
| 1589 | /* test multi exception */ |
| 1590 | printf ("testClient.testMultiException(\"Xception\", \"test 1\") =>"); |
| 1591 | xtruct_in = g_object_new (T_TEST_TYPE_XTRUCT, NULL); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1592 | if (!t_test_thrift_test_if_test_multi_exception (test_client, |
| 1593 | &xtruct_in, |
| 1594 | "Xception", |
| 1595 | "test 1", |
| 1596 | &xception, |
| 1597 | &xception2, |
| 1598 | &error) && |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1599 | xception != NULL && |
| 1600 | xception2 == NULL) { |
| 1601 | g_object_get (xception, |
| 1602 | "errorCode", &int32, |
| 1603 | "message", &string, |
| 1604 | NULL); |
| 1605 | printf (" {%u, \"%s\"}\n", int32, string); |
| 1606 | g_free (string); |
| 1607 | |
| 1608 | g_object_unref (xception); |
| 1609 | xception = NULL; |
| 1610 | |
| 1611 | g_error_free (error); |
| 1612 | error = NULL; |
| 1613 | } |
| 1614 | else { |
| 1615 | printf (" result\nFAILURE\n"); |
| 1616 | fail_count++; |
| 1617 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1618 | g_clear_object (&xception); |
| 1619 | g_clear_object (&xception2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1620 | |
| 1621 | if (error != NULL) { |
| 1622 | g_error_free (error); |
| 1623 | error = NULL; |
| 1624 | } |
| 1625 | } |
| 1626 | g_object_unref (xtruct_in); |
| 1627 | |
| 1628 | printf ("testClient.testMultiException(\"Xception2\", \"test 2\") =>"); |
| 1629 | xtruct_in = g_object_new (T_TEST_TYPE_XTRUCT, NULL); |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1630 | if (!t_test_thrift_test_if_test_multi_exception (test_client, |
| 1631 | &xtruct_in, |
| 1632 | "Xception2", |
| 1633 | "test 2", |
| 1634 | &xception, |
| 1635 | &xception2, |
| 1636 | &error) && |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1637 | xception == NULL && |
| 1638 | xception2 != NULL) { |
| 1639 | g_object_get (xception2, |
| 1640 | "errorCode", &int32, |
| 1641 | "struct_thing", &inner_xtruct_in, |
| 1642 | NULL); |
| 1643 | g_object_get (inner_xtruct_in, |
| 1644 | "string_thing", &string, |
| 1645 | NULL); |
| 1646 | printf (" {%u, {\"%s\"}}\n", int32, string); |
| 1647 | g_free (string); |
| 1648 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1649 | g_clear_object (&inner_xtruct_in); |
| 1650 | g_clear_object (&xception2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1651 | |
| 1652 | g_error_free (error); |
| 1653 | error = NULL; |
| 1654 | } |
| 1655 | else { |
| 1656 | printf (" result\nFAILURE\n"); |
| 1657 | fail_count++; |
| 1658 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1659 | g_clear_object (&xception); |
| 1660 | g_clear_object (&xception2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1661 | |
| 1662 | if (error != NULL) { |
| 1663 | g_error_free (error); |
| 1664 | error = NULL; |
| 1665 | } |
| 1666 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1667 | g_clear_object (&xtruct_in); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1668 | |
| 1669 | printf ("testClient.testMultiException(\"success\", \"test 3\") =>"); |
| 1670 | xtruct_in = g_object_new (T_TEST_TYPE_XTRUCT, NULL); |
| 1671 | if (t_test_thrift_test_if_test_multi_exception (test_client, |
| 1672 | &xtruct_in, |
| 1673 | "success", |
| 1674 | "test 3", |
| 1675 | &xception, |
| 1676 | &xception2, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1677 | &error) && |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1678 | xception == NULL && |
| 1679 | xception2 == NULL) { |
| 1680 | g_object_get (xtruct_in, |
| 1681 | "string_thing", &string, |
| 1682 | NULL); |
| 1683 | printf (" {{\"%s\"}}\n", string); |
| 1684 | g_free (string); |
| 1685 | } |
| 1686 | else { |
| 1687 | printf (" result\nFAILURE\n"); |
| 1688 | fail_count++; |
| 1689 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1690 | g_clear_object (&xception); |
| 1691 | g_clear_object (&xception2); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1692 | |
| 1693 | if (error != NULL) { |
| 1694 | g_error_free (error); |
| 1695 | error = NULL; |
| 1696 | } |
| 1697 | } |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1698 | g_clear_object (&xtruct_in); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1699 | |
| 1700 | /* test oneway void */ |
| 1701 | printf ("testClient.testOneway(1) =>"); |
| 1702 | gettimeofday (&oneway_start, NULL); |
| 1703 | oneway_result = t_test_thrift_test_if_test_oneway (test_client, |
| 1704 | 1, |
| 1705 | &error); |
| 1706 | gettimeofday (&oneway_end, NULL); |
| 1707 | timersub (&oneway_end, &oneway_start, &oneway_elapsed); |
| 1708 | oneway_elapsed_usec = |
| 1709 | oneway_elapsed.tv_sec * 1000 * 1000 + oneway_elapsed.tv_usec; |
| 1710 | |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1711 | if (oneway_result) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1712 | if (oneway_elapsed_usec > 200 * 1000) { |
| 1713 | printf (" FAILURE - took %.2f ms\n", |
| 1714 | (double)oneway_elapsed_usec / 1000.0); |
| 1715 | fail_count++; |
| 1716 | } |
| 1717 | else |
| 1718 | printf (" success - took %.2f ms\n", |
| 1719 | (double)oneway_elapsed_usec / 1000.0); |
| 1720 | } |
| 1721 | else { |
| 1722 | printf ("%s\n", error->message); |
| 1723 | g_error_free (error); |
| 1724 | error = NULL; |
| 1725 | |
| 1726 | fail_count++; |
| 1727 | } |
| 1728 | |
| 1729 | /** |
| 1730 | * redo a simple test after the oneway to make sure we aren't "off by |
| 1731 | * one" -- if the server treated oneway void like normal void, this next |
| 1732 | * test will fail since it will get the void confirmation rather than |
| 1733 | * the correct result. In this circumstance, the client will receive the |
| 1734 | * error: |
| 1735 | * |
| 1736 | * application error: Wrong method name |
| 1737 | */ |
| 1738 | /** |
| 1739 | * I32 TEST |
| 1740 | */ |
| 1741 | printf ("re-test testI32(-1)"); |
| 1742 | if (t_test_thrift_test_if_test_i32 (test_client, |
| 1743 | &int32, |
| 1744 | -1, |
Roger Meier | 15df076 | 2014-09-29 20:50:56 +0200 | [diff] [blame] | 1745 | &error)) { |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1746 | printf (" = %d\n", int32); |
| 1747 | if (int32 != -1) |
| 1748 | fail_count++; |
| 1749 | } |
| 1750 | else { |
| 1751 | printf ("%s\n", error->message); |
| 1752 | g_error_free (error); |
| 1753 | error = NULL; |
| 1754 | |
| 1755 | fail_count++; |
| 1756 | } |
| 1757 | |
| 1758 | gettimeofday (&time_stop, NULL); |
| 1759 | timersub (&time_stop, &time_start, &time_elapsed); |
| 1760 | time_elapsed_usec = |
| 1761 | time_elapsed.tv_sec * 1000 * 1000 + time_elapsed.tv_usec; |
| 1762 | |
| 1763 | printf("Total time: %" PRIu64 " us\n", time_elapsed_usec); |
| 1764 | |
| 1765 | time_total_usec += time_elapsed_usec; |
| 1766 | if (time_elapsed_usec < time_min_usec) |
| 1767 | time_min_usec = time_elapsed_usec; |
| 1768 | if (time_elapsed_usec > time_max_usec) |
| 1769 | time_max_usec = time_elapsed_usec; |
| 1770 | |
| 1771 | thrift_transport_close (transport, &error); |
| 1772 | } |
| 1773 | else { |
| 1774 | printf ("Connect failed: %s\n", error->message); |
| 1775 | g_error_free (error); |
| 1776 | error = NULL; |
| 1777 | |
| 1778 | return 1; |
| 1779 | } |
| 1780 | } |
| 1781 | |
| 1782 | /* All done---output statistics */ |
| 1783 | puts ("\nAll tests done."); |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1784 | printf("Number of failures: %d\n", fail_count); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1785 | |
| 1786 | time_avg_usec = time_total_usec / num_tests; |
| 1787 | |
| 1788 | printf ("Min time: %" PRIu64 " us\n", time_min_usec); |
| 1789 | printf ("Max time: %" PRIu64 " us\n", time_max_usec); |
| 1790 | printf ("Avg time: %" PRIu64 " us\n", time_avg_usec); |
| 1791 | |
James E. King, III | 37aac3b | 2017-02-21 14:01:09 -0500 | [diff] [blame^] | 1792 | g_clear_object(&second_service); |
| 1793 | g_clear_object(&protocol2); |
| 1794 | g_clear_object(&test_client); |
| 1795 | g_clear_object(&protocol); |
| 1796 | g_clear_object(&transport); |
| 1797 | g_clear_object(&socket); |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1798 | |
James E. King, III | 36628a2 | 2017-02-13 15:25:41 -0500 | [diff] [blame] | 1799 | if (ssl) { |
| 1800 | thrift_ssl_socket_finalize_openssl(); |
| 1801 | } |
| 1802 | |
Roger Meier | b3c8409 | 2014-09-01 21:53:40 +0200 | [diff] [blame] | 1803 | return fail_count; |
| 1804 | } |