From 4f46e2f2e72a07871b14c0a9aed70438616c4dd5 Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Fri, 9 Dec 2022 12:07:26 +0900 Subject: TESTING: Fix TESTING-NG API to follow naming conventions Rename structs and functions to follow GNUnet naming conventions. Some structs may actually also be private, a review is necessary. The barrier API was modified in order to untangle Barriers and lists of Barriers. This is a rough draft, it needs fixes wrt memory leaks. --- src/transport/test_transport_plugin_cmd_nat_upnp.c | 40 ++++++++++++---------- .../test_transport_plugin_cmd_simple_send.c | 16 ++++----- ...st_transport_plugin_cmd_simple_send_broadcast.c | 20 +++++------ .../test_transport_plugin_cmd_simple_send_dv.c | 20 +++++------ .../test_transport_plugin_cmd_udp_backchannel.c | 16 ++++----- 5 files changed, 54 insertions(+), 58 deletions(-) (limited to 'src/transport') diff --git a/src/transport/test_transport_plugin_cmd_nat_upnp.c b/src/transport/test_transport_plugin_cmd_nat_upnp.c index 73380e03c..3fef41d87 100644 --- a/src/transport/test_transport_plugin_cmd_nat_upnp.c +++ b/src/transport/test_transport_plugin_cmd_nat_upnp.c @@ -87,21 +87,25 @@ handle_test (void *cls, } -struct GNUNET_TESTING_Barrier * +struct GNUNET_TESTING_BarrierList* get_waiting_for_barriers () { - struct GNUNET_TESTING_Barrier *barriers_head; - struct GNUNET_TESTING_Barrier *barriers_tail; - struct GNUNET_TESTING_Barrier *ready_to_connect; - struct GNUNET_TESTING_Barrier *test_case_finished; - - ready_to_connect = GNUNET_new (struct GNUNET_TESTING_Barrier); - ready_to_connect->name = "ready-to-connect"; - test_case_finished = GNUNET_new (struct GNUNET_TESTING_Barrier); - test_case_finished->name = "test-case-finished"; - GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail, ready_to_connect); - GNUNET_CONTAINER_DLL_insert (barriers_head, barriers_tail, test_case_finished); - return barriers_head; + struct GNUNET_TESTING_BarrierList* barriers; + struct GNUNET_TESTING_BarrierListEntry *ble; + + barriers = GNUNET_new (struct GNUNET_TESTING_BarrierList); + ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry); + ble->barrier = GNUNET_TESTING_barrier_new ("ready-to-connect"); + GNUNET_CONTAINER_DLL_insert (barriers->head, + barriers->tail, + ble); + + ble = GNUNET_new (struct GNUNET_TESTING_BarrierListEntry); + ble->barrier = GNUNET_TESTING_barrier_new ("test-case-finished"); + GNUNET_CONTAINER_DLL_insert (barriers->head, + barriers->tail, + ble); + return barriers; } @@ -143,7 +147,7 @@ static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv) { - struct TestState *ts = cls; + struct GNUNET_TESTING_TestState *ts = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local test exits with status %d\n", @@ -186,7 +190,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, static void all_local_tests_prepared () { - const struct LocalPreparedState *lfs; + const struct GNUNET_TESTING_LocalPreparedState *lfs; GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, &lfs); @@ -210,7 +214,7 @@ all_local_tests_prepared () * @param local_m The number of nodes in a network namespace. */ static void -start_testcase (TESTING_CMD_HELPER_write_cb write_message, +start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, @@ -218,14 +222,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, const char *local_m, const char *topology_data, unsigned int *read_file, - TESTING_CMD_HELPER_finish_cb finished_cb) + GNUNET_TESTING_cmd_helper_finish_cb finished_cb) { unsigned int n_int; unsigned int m_int; unsigned int local_m_int; unsigned int num; - struct TestState *ts = GNUNET_new (struct TestState); + struct GNUNET_TESTING_TestState *ts = GNUNET_new (struct GNUNET_TESTING_TestState); struct GNUNET_TESTING_NetjailTopology *topology; unsigned int sscanf_ret = 0; diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index de923cbdd..e94667593 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c @@ -87,13 +87,11 @@ handle_test (void *cls, } -struct GNUNET_TESTING_Barrier * +struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers () { - struct GNUNET_TESTING_Barrier *barrier; - //No Barrier - return NULL; + return GNUNET_new (struct GNUNET_TESTING_BarrierList); } @@ -135,7 +133,7 @@ static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv) { - struct TestState *ts = cls; + struct GNUNET_TESTING_TestState *ts = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local test exits with status %d\n", @@ -178,7 +176,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, static void all_local_tests_prepared () { - const struct LocalPreparedState *lfs; + const struct GNUNET_TESTING_LocalPreparedState *lfs; GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, &lfs); @@ -202,7 +200,7 @@ all_local_tests_prepared () * @param local_m The number of nodes in a network namespace. */ static void -start_testcase (TESTING_CMD_HELPER_write_cb write_message, +start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, @@ -210,14 +208,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, const char *local_m, const char *topology_data, unsigned int *read_file, - TESTING_CMD_HELPER_finish_cb finished_cb) + GNUNET_TESTING_cmd_helper_finish_cb finished_cb) { unsigned int n_int; unsigned int m_int; unsigned int local_m_int; unsigned int num; - struct TestState *ts = GNUNET_new (struct TestState); + struct GNUNET_TESTING_TestState *ts = GNUNET_new (struct GNUNET_TESTING_TestState); struct GNUNET_TESTING_NetjailTopology *topology; unsigned int sscanf_ret = 0; diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c index ff6f0def9..4eeb25ec8 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c @@ -87,13 +87,11 @@ handle_test (void *cls, } -struct GNUNET_TESTING_Barrier * +struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers () { - struct GNUNET_TESTING_Barrier *barrier; - //No Barrier - return NULL; + return GNUNET_new (struct GNUNET_TESTING_BarrierList); } @@ -137,7 +135,7 @@ static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv) { - struct TestState *ts = cls; + struct GNUNET_TESTING_TestState *ts = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local test exits with status %d\n", @@ -161,7 +159,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, const struct GNUNET_TESTING_AsyncContext *ac; void *ret = NULL; const struct GNUNET_TESTING_Command *cmd; - struct BlockState *bs; + struct GNUNET_TESTING_BlockState *bs; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -190,7 +188,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, cmd->label); GNUNET_TESTING_get_trait_block_state ( cmd, - (const struct BlockState **) &bs); + (const struct GNUNET_TESTING_BlockState **) &bs); LOG (GNUNET_ERROR_TYPE_DEBUG, "block state %u\n", @@ -211,7 +209,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, static void all_local_tests_prepared () { - const struct LocalPreparedState *lfs; + const struct GNUNET_TESTING_LocalPreparedState *lfs; GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, &lfs); @@ -235,7 +233,7 @@ all_local_tests_prepared () * @param local_m The number of nodes in a network namespace. */ static void -start_testcase (TESTING_CMD_HELPER_write_cb write_message, +start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, @@ -243,13 +241,13 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, const char *local_m, const char *topology_data, unsigned int *read_file, - TESTING_CMD_HELPER_finish_cb finished_cb) + GNUNET_TESTING_cmd_helper_finish_cb finished_cb) { unsigned int n_int; unsigned int m_int; unsigned int local_m_int; unsigned int num; - struct TestState *ts = GNUNET_new (struct TestState); + struct GNUNET_TESTING_TestState *ts = GNUNET_new (struct GNUNET_TESTING_TestState); struct GNUNET_TESTING_NetjailTopology *topology; unsigned int sscanf_ret = 0; diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c b/src/transport/test_transport_plugin_cmd_simple_send_dv.c index adbb3cc0b..fe2c04401 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c +++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c @@ -87,7 +87,7 @@ handle_test (void *cls, const struct GNUNET_TESTING_AsyncContext *ac_block; const struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; unsigned int connected; - struct BlockState *bs; + struct GNUNET_TESTING_BlockState *bs; struct GNUNET_TRANSPORT_CoreHandle *ch; const struct StartPeerState *sps; @@ -129,7 +129,7 @@ handle_test (void *cls, { GNUNET_TESTING_get_trait_block_state ( &block_receive, - (const struct BlockState **) &bs); + (const struct GNUNET_TESTING_BlockState **) &bs); bs->asynchronous_finish = GNUNET_YES; } @@ -139,13 +139,11 @@ handle_test (void *cls, } -struct GNUNET_TESTING_Barrier * +struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers () { - struct GNUNET_TESTING_Barrier *barrier; - //No Barrier - return NULL; + return GNUNET_new (struct GNUNET_TESTING_BarrierList); } @@ -189,7 +187,7 @@ static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv) { - struct TestState *ts = cls; + struct GNUNET_TESTING_TestState *ts = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local test exits with status %d\n", @@ -234,7 +232,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, static void all_local_tests_prepared () { - const struct LocalPreparedState *lfs; + const struct GNUNET_TESTING_LocalPreparedState *lfs; GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, &lfs); @@ -258,7 +256,7 @@ all_local_tests_prepared () * @param local_m The number of nodes in a network namespace. */ static void -start_testcase (TESTING_CMD_HELPER_write_cb write_message, +start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, @@ -266,13 +264,13 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, const char *local_m, const char *topology_data, unsigned int *read_file, - TESTING_CMD_HELPER_finish_cb finished_cb) + GNUNET_TESTING_cmd_helper_finish_cb finished_cb) { unsigned int n_int; unsigned int m_int; unsigned int local_m_int; unsigned int num; - struct TestState *ts = GNUNET_new (struct TestState); + struct GNUNET_TESTING_TestState *ts = GNUNET_new (struct GNUNET_TESTING_TestState); struct GNUNET_TESTING_NetjailTopology *topology; struct GNUNET_MQ_MessageHandler handlers[] = { GNUNET_MQ_hd_var_size (test, diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 1bc965848..f96a25e80 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c @@ -85,13 +85,11 @@ handle_test (void *cls, } -struct GNUNET_TESTING_Barrier * +struct GNUNET_TESTING_BarrierList * get_waiting_for_barriers () { - struct GNUNET_TESTING_Barrier *barrier; - // No Barrier - return NULL; + return GNUNET_new (struct GNUNET_TESTING_BarrierList); } @@ -134,7 +132,7 @@ static void handle_result (void *cls, enum GNUNET_GenericReturnValue rv) { - struct TestState *ts = cls; + struct GNUNET_TESTING_TestState *ts = cls; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Local test exits with status %d\n", @@ -173,7 +171,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is, static void all_local_tests_prepared () { - const struct LocalPreparedState *lfs; + const struct GNUNET_TESTING_LocalPreparedState *lfs; GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, &lfs); @@ -196,7 +194,7 @@ all_local_tests_prepared () * @param local_m The number of nodes in a network namespace. */ static void -start_testcase (TESTING_CMD_HELPER_write_cb write_message, +start_testcase (GNUNET_TESTING_cmd_helper_write_cb write_message, const char *router_ip, const char *node_ip, const char *m, @@ -204,14 +202,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, const char *local_m, const char *topology_data, unsigned int *read_file, - TESTING_CMD_HELPER_finish_cb finished_cb) + GNUNET_TESTING_cmd_helper_finish_cb finished_cb) { unsigned int n_int; unsigned int m_int; unsigned int local_m_int; unsigned int num; - struct TestState *ts = GNUNET_new (struct TestState); + struct GNUNET_TESTING_TestState *ts = GNUNET_new (struct GNUNET_TESTING_TestState); struct GNUNET_TESTING_NetjailTopology *topology; unsigned int sscanf_ret = 0; -- cgit v1.2.3