diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/jaegertracing/thrift/lib/c_glib/test/testthrifttest.c | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | src/jaegertracing/thrift/lib/c_glib/test/testthrifttest.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/jaegertracing/thrift/lib/c_glib/test/testthrifttest.c b/src/jaegertracing/thrift/lib/c_glib/test/testthrifttest.c new file mode 100755 index 000000000..23a934db9 --- /dev/null +++ b/src/jaegertracing/thrift/lib/c_glib/test/testthrifttest.c @@ -0,0 +1,112 @@ +#include <netdb.h> + +#include <thrift/c_glib/thrift.h> +#include <thrift/c_glib/transport/thrift_server_transport.h> +#include <thrift/c_glib/transport/thrift_server_socket.h> + +#include "t_test_thrift_test_types.h" +#include "thrift_test_handler.h" + +static const char TEST_ADDRESS[] = "localhost"; +static const int TEST_PORT = 64444; + +static void +test_thrift_server (void) +{ + ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET, + "port", TEST_PORT, NULL); + + g_object_unref (tsocket); +} + +static void +set_indicator (gpointer data, GObject *where_the_object_was) { + THRIFT_UNUSED_VAR(where_the_object_was); + + *(gboolean *) data = TRUE; +} + +static void +test_thrift_handler (void) +{ + GError *error; + GHashTable *_return; + TTestInsanity *argument; + gboolean indicator; + + TTestXtruct *xtruct, *xtruct2; + TTestNumberz numberz; + TTestNumberz numberz2; + TTestUserId user_id, *user_id_ptr, *user_id_ptr2; + GHashTable *user_map; + GPtrArray *xtructs; + + error = NULL; + indicator = FALSE; + + user_map = NULL; + xtructs = NULL; + + argument = g_object_new (T_TEST_TYPE_INSANITY, NULL); + g_object_get (argument, + "userMap", &user_map, + "xtructs", &xtructs, + NULL); + + numberz = T_TEST_NUMBERZ_FIVE; + numberz2 = T_TEST_NUMBERZ_EIGHT; + user_id_ptr = g_malloc (sizeof *user_id_ptr); + *user_id_ptr = 5; + user_id_ptr2 = g_malloc (sizeof *user_id_ptr); + *user_id_ptr2 = 8; + g_hash_table_insert (user_map, (gpointer)numberz, user_id_ptr); + g_hash_table_insert (user_map, (gpointer)numberz2, user_id_ptr2); + g_hash_table_unref (user_map); + + xtruct = g_object_new (T_TEST_TYPE_XTRUCT, + "string_thing", "Hello2", + "byte_thing", 2, + "i32_thing", 2, + "i64_thing", 2LL, + NULL); + xtruct2 = g_object_new (T_TEST_TYPE_XTRUCT, + "string_thing", "Goodbye4", + "byte_thing", 4, + "i32_thing", 4, + "i64_thing", 4LL, + NULL); + g_ptr_array_add (xtructs, xtruct2); + g_ptr_array_add (xtructs, xtruct); + g_ptr_array_unref (xtructs); + + _return = g_hash_table_new_full (g_int64_hash, + g_int64_equal, + g_free, + (GDestroyNotify)g_hash_table_unref); + + g_object_weak_ref (G_OBJECT (argument), set_indicator, (gpointer) &indicator); + + g_assert (thrift_test_handler_test_insanity (NULL, &_return, argument, &error)); + g_assert (! indicator); + + g_hash_table_unref (_return); + g_assert (! indicator); + + g_object_unref (argument); + g_assert (indicator); +} + +int +main(int argc, char *argv[]) +{ +#if (!GLIB_CHECK_VERSION (2, 36, 0)) + g_type_init(); +#endif + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/testthrift/Server", test_thrift_server); + g_test_add_func ("/testthrift/Handler", test_thrift_handler); + + return g_test_run (); +} |