diff options
author | t3sserakt <t3ss@posteo.de> | 2021-10-25 14:49:05 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-10-25 14:49:05 +0200 |
commit | 1609d627e509043a946f611d7589105cfae2364d (patch) | |
tree | d6022bea17730f96c7d87b0a1c8f602717edb25d /src | |
parent | 513f23e74650db9408267e82ef8bcb8f770d1015 (diff) | |
download | gnunet-1609d627e509043a946f611d7589105cfae2364d.tar.gz gnunet-1609d627e509043a946f611d7589105cfae2364d.zip |
changes to reflect the changes in testing_api_loop.c
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_testing_ng_lib.h | 34 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_local_test_finished.c | 1 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_local_test_prepared.c | 93 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_netjail_start_testsystem.c | 185 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_testsystem.c | 2 | ||||
-rw-r--r-- | src/testing/testing_api_cmd_send_peer_ready.c | 1 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_simple_send.c | 10 | ||||
-rw-r--r-- | src/transport/test_transport_plugin_cmd_udp_backchannel.c | 42 | ||||
-rw-r--r-- | src/transport/transport-testing-cmds.h | 25 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_backchannel_check.c | 51 | ||||
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 258 |
11 files changed, 297 insertions, 405 deletions
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 96e9af252..45e58299e 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -1046,6 +1046,23 @@ GNUNET_TESTING_make_trait_relative_time ( | |||
1046 | 1046 | ||
1047 | // FIXME: move these commands into a separate libgnunetestingnetjail lib or so! | 1047 | // FIXME: move these commands into a separate libgnunetestingnetjail lib or so! |
1048 | 1048 | ||
1049 | /** | ||
1050 | * Struct to hold information for callbacks. | ||
1051 | * | ||
1052 | */ | ||
1053 | struct LocalPreparedState | ||
1054 | { | ||
1055 | /** | ||
1056 | * Context for our asynchronous completion. | ||
1057 | */ | ||
1058 | struct GNUNET_TESTING_AsyncContext ac; | ||
1059 | |||
1060 | /** | ||
1061 | * Callback to write messages to the master loop. | ||
1062 | * | ||
1063 | */ | ||
1064 | TESTING_CMD_HELPER_write_cb write_message; | ||
1065 | }; | ||
1049 | 1066 | ||
1050 | /** | 1067 | /** |
1051 | * Create command. | 1068 | * Create command. |
@@ -1223,7 +1240,18 @@ GNUNET_TESTING_cmd_local_test_finished ( | |||
1223 | struct GNUNET_TESTING_Command | 1240 | struct GNUNET_TESTING_Command |
1224 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | 1241 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, |
1225 | TESTING_CMD_HELPER_write_cb | 1242 | TESTING_CMD_HELPER_write_cb |
1226 | write_message, | 1243 | write_message); |
1227 | unsigned int * | 1244 | |
1228 | all_local_tests_prepared); | 1245 | /** |
1246 | * Function to get the trait with the struct LocalPreparedState. | ||
1247 | * | ||
1248 | * @param[out] lfs struct LocalPreparedState. | ||
1249 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
1250 | * | ||
1251 | */ | ||
1252 | enum GNUNET_GenericReturnValue | ||
1253 | GNUNET_TESTING_get_trait_local_prepared_state ( | ||
1254 | const struct GNUNET_TESTING_Command *cmd, | ||
1255 | struct LocalPreparedState **lfs); | ||
1256 | |||
1229 | #endif | 1257 | #endif |
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c index 0e7e214dc..8f8a8230c 100644 --- a/src/testing/testing_api_cmd_local_test_finished.c +++ b/src/testing/testing_api_cmd_local_test_finished.c | |||
@@ -64,7 +64,6 @@ local_test_finished_cleanup (void *cls) | |||
64 | { | 64 | { |
65 | struct LocalFinishedState *lfs = cls; | 65 | struct LocalFinishedState *lfs = cls; |
66 | 66 | ||
67 | GNUNET_free (lfs->reply); | ||
68 | GNUNET_free (lfs); | 67 | GNUNET_free (lfs); |
69 | } | 68 | } |
70 | 69 | ||
diff --git a/src/testing/testing_api_cmd_local_test_prepared.c b/src/testing/testing_api_cmd_local_test_prepared.c index 4e915c7c0..2554d6fec 100644 --- a/src/testing/testing_api_cmd_local_test_prepared.c +++ b/src/testing/testing_api_cmd_local_test_prepared.c | |||
@@ -35,41 +35,47 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Struct to hold information for callbacks. | 38 | * This function prepares an array with traits. |
39 | * | 39 | * |
40 | */ | 40 | */ |
41 | struct LocalPreparedState | 41 | enum GNUNET_GenericReturnValue |
42 | local_test_prepared_traits (void *cls, | ||
43 | const void **ret, | ||
44 | const char *trait, | ||
45 | unsigned int index) | ||
42 | { | 46 | { |
43 | /** | 47 | struct LocalPreparedState *lfs = cls; |
44 | * Callback to write messages to the master loop. | 48 | struct GNUNET_TESTING_Trait traits[] = { |
45 | * | 49 | { |
46 | */ | 50 | .index = 0, |
47 | TESTING_CMD_HELPER_write_cb write_message; | 51 | .trait_name = "state", |
48 | 52 | .ptr = (const void *) lfs, | |
49 | /** | 53 | }, |
50 | * The message send back to the master loop. | 54 | GNUNET_TESTING_trait_end () |
51 | * | 55 | }; |
52 | */ | 56 | return GNUNET_TESTING_get_trait (traits, |
53 | struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply; | 57 | ret, |
54 | 58 | trait, | |
55 | /** | 59 | index); |
56 | * Flag indicating if all local tests finished. | 60 | } |
57 | */ | ||
58 | unsigned int *all_local_tests_prepared; | ||
59 | }; | ||
60 | 61 | ||
61 | 62 | ||
62 | /** | 63 | /** |
63 | * Trait function of this cmd does nothing. | 64 | * Function to get the trait with the struct LocalPreparedState. |
65 | * | ||
66 | * @param[out] lfs struct LocalPreparedState. | ||
67 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
64 | * | 68 | * |
65 | */ | 69 | */ |
66 | static int | 70 | enum GNUNET_GenericReturnValue |
67 | local_test_prepared_traits (void *cls, | 71 | GNUNET_TESTING_get_trait_local_prepared_state ( |
68 | const void **ret, | 72 | const struct GNUNET_TESTING_Command *cmd, |
69 | const char *trait, | 73 | struct LocalPreparedState **lfs) |
70 | unsigned int index) | ||
71 | { | 74 | { |
72 | return GNUNET_OK; | 75 | return cmd->traits (cmd->cls, |
76 | (const void **) lfs, | ||
77 | "state", | ||
78 | (unsigned int) 0); | ||
73 | } | 79 | } |
74 | 80 | ||
75 | 81 | ||
@@ -78,12 +84,10 @@ local_test_prepared_traits (void *cls, | |||
78 | * | 84 | * |
79 | */ | 85 | */ |
80 | static void | 86 | static void |
81 | local_test_prepared_cleanup (void *cls, | 87 | local_test_prepared_cleanup (void *cls) |
82 | const struct GNUNET_TESTING_Command *cmd) | ||
83 | { | 88 | { |
84 | struct LocalPreparedState *lfs = cls; | 89 | struct LocalPreparedState *lfs = cls; |
85 | 90 | ||
86 | GNUNET_free (lfs->reply); | ||
87 | GNUNET_free (lfs); | 91 | GNUNET_free (lfs); |
88 | } | 92 | } |
89 | 93 | ||
@@ -94,7 +98,6 @@ local_test_prepared_cleanup (void *cls, | |||
94 | */ | 98 | */ |
95 | static void | 99 | static void |
96 | local_test_prepared_run (void *cls, | 100 | local_test_prepared_run (void *cls, |
97 | const struct GNUNET_TESTING_Command *cmd, | ||
98 | struct GNUNET_TESTING_Interpreter *is) | 101 | struct GNUNET_TESTING_Interpreter *is) |
99 | { | 102 | { |
100 | struct LocalPreparedState *lfs = cls; | 103 | struct LocalPreparedState *lfs = cls; |
@@ -107,34 +110,11 @@ local_test_prepared_run (void *cls, | |||
107 | reply->header.type = htons ( | 110 | reply->header.type = htons ( |
108 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED); | 111 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED); |
109 | reply->header.size = htons ((uint16_t) msg_length); | 112 | reply->header.size = htons ((uint16_t) msg_length); |
110 | lfs->reply = reply; | ||
111 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | 113 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); |
112 | } | 114 | } |
113 | 115 | ||
114 | 116 | ||
115 | /** | 117 | /** |
116 | * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. | ||
117 | * | ||
118 | */ | ||
119 | static int | ||
120 | local_test_prepared_finish (void *cls, | ||
121 | GNUNET_SCHEDULER_TaskCallback cont, | ||
122 | void *cont_cls) | ||
123 | { | ||
124 | struct LocalPreparedState *lfs = cls; | ||
125 | unsigned int *ret = lfs->all_local_tests_prepared; | ||
126 | |||
127 | if (GNUNET_YES == *ret) | ||
128 | { | ||
129 | cont (cont_cls); | ||
130 | } | ||
131 | |||
132 | return *ret; | ||
133 | |||
134 | } | ||
135 | |||
136 | |||
137 | /** | ||
138 | * Create command. | 118 | * Create command. |
139 | * | 119 | * |
140 | * @param label name for command. | 120 | * @param label name for command. |
@@ -145,21 +125,18 @@ local_test_prepared_finish (void *cls, | |||
145 | struct GNUNET_TESTING_Command | 125 | struct GNUNET_TESTING_Command |
146 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, | 126 | GNUNET_TESTING_cmd_local_test_prepared (const char *label, |
147 | TESTING_CMD_HELPER_write_cb | 127 | TESTING_CMD_HELPER_write_cb |
148 | write_message, | 128 | write_message) |
149 | unsigned int * | ||
150 | all_local_tests_prepared) | ||
151 | { | 129 | { |
152 | struct LocalPreparedState *lfs; | 130 | struct LocalPreparedState *lfs; |
153 | 131 | ||
154 | lfs = GNUNET_new (struct LocalPreparedState); | 132 | lfs = GNUNET_new (struct LocalPreparedState); |
155 | lfs->write_message = write_message; | 133 | lfs->write_message = write_message; |
156 | lfs->all_local_tests_prepared = all_local_tests_prepared; | ||
157 | 134 | ||
158 | struct GNUNET_TESTING_Command cmd = { | 135 | struct GNUNET_TESTING_Command cmd = { |
159 | .cls = lfs, | 136 | .cls = lfs, |
160 | .label = label, | 137 | .label = label, |
161 | .run = &local_test_prepared_run, | 138 | .run = &local_test_prepared_run, |
162 | .finish = &local_test_prepared_finish, | 139 | .ac = &lfs->ac, |
163 | .cleanup = &local_test_prepared_cleanup, | 140 | .cleanup = &local_test_prepared_cleanup, |
164 | .traits = &local_test_prepared_traits | 141 | .traits = &local_test_prepared_traits |
165 | }; | 142 | }; |
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c index a1d71c436..9b567a01f 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c | |||
@@ -30,6 +30,11 @@ | |||
30 | #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh" | 30 | #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec.sh" |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Generic logging shortcut | ||
34 | */ | ||
35 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
36 | |||
37 | /** | ||
33 | * Struct to store messages send/received by the helper into a DLL | 38 | * Struct to store messages send/received by the helper into a DLL |
34 | * | 39 | * |
35 | */ | 40 | */ |
@@ -121,13 +126,13 @@ struct NetJailState | |||
121 | /** | 126 | /** |
122 | * The send handle for the helper | 127 | * The send handle for the helper |
123 | */ | 128 | */ |
124 | struct GNUNET_HELPER_SendHandle **shandle; | 129 | // struct GNUNET_HELPER_SendHandle **shandle; |
125 | 130 | ||
126 | /** | 131 | /** |
127 | * Size of the array NetJailState#shandle. | 132 | * Size of the array NetJailState#shandle. |
128 | * | 133 | * |
129 | */ | 134 | */ |
130 | unsigned int n_shandle; | 135 | // unsigned int n_shandle; |
131 | 136 | ||
132 | /** | 137 | /** |
133 | * The messages send to the helper. | 138 | * The messages send to the helper. |
@@ -156,7 +161,13 @@ struct NetJailState | |||
156 | * Number of local tests finished. | 161 | * Number of local tests finished. |
157 | * | 162 | * |
158 | */ | 163 | */ |
159 | unsigned int number_of_local_test_finished; | 164 | unsigned int number_of_local_tests_finished; |
165 | |||
166 | /** | ||
167 | * Number of local tests prepared to finish. | ||
168 | * | ||
169 | */ | ||
170 | unsigned int number_of_local_tests_prepared; | ||
160 | 171 | ||
161 | /** | 172 | /** |
162 | * Name of the test case plugin the helper will load. | 173 | * Name of the test case plugin the helper will load. |
@@ -194,6 +205,17 @@ struct TestingSystemCount | |||
194 | struct TestingSystemCount *prev; | 205 | struct TestingSystemCount *prev; |
195 | 206 | ||
196 | /** | 207 | /** |
208 | * The send handle for the helper | ||
209 | */ | ||
210 | struct GNUNET_HELPER_SendHandle *shandle;// **shandle; | ||
211 | |||
212 | /** | ||
213 | * Size of the array NetJailState#shandle. | ||
214 | * | ||
215 | */ | ||
216 | // unsigned int n_shandle; | ||
217 | |||
218 | /** | ||
197 | * The number of the test environment. | 219 | * The number of the test environment. |
198 | * | 220 | * |
199 | */ | 221 | */ |
@@ -306,47 +328,85 @@ clear_msg (void *cls, int result) | |||
306 | struct TestingSystemCount *tbc = cls; | 328 | struct TestingSystemCount *tbc = cls; |
307 | struct NetJailState *ns = tbc->ns; | 329 | struct NetJailState *ns = tbc->ns; |
308 | 330 | ||
309 | GNUNET_assert (NULL != ns->shandle[tbc->count - 1]); | 331 | GNUNET_assert (NULL != tbc->shandle);// [tbc->count - 1]); |
310 | ns->shandle[tbc->count - 1] = NULL; | 332 | tbc->shandle = NULL;// [tbc->count - 1] = NULL; |
311 | GNUNET_free (ns->msg[tbc->count - 1]); | 333 | GNUNET_free (ns->msg[tbc->count - 1]); |
312 | ns->msg[tbc->count - 1] = NULL; | 334 | ns->msg[tbc->count - 1] = NULL; |
313 | } | 335 | } |
314 | 336 | ||
315 | 337 | ||
316 | static void | 338 | static void |
317 | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | 339 | send_message_to_locals ( |
340 | unsigned int i, | ||
341 | unsigned int j, | ||
342 | struct NetJailState *ns, | ||
343 | struct GNUNET_MessageHeader *header | ||
344 | ) | ||
318 | { | 345 | { |
319 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | 346 | // unsigned int total_number = ns->local_m * ns->global_n + ns->known; |
320 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
321 | size_t msg_length; | ||
322 | struct GNUNET_HELPER_Handle *helper; | 347 | struct GNUNET_HELPER_Handle *helper; |
323 | struct TestingSystemCount *tbc; | 348 | struct TestingSystemCount *tbc; |
324 | 349 | ||
350 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
351 | "send message of type %u to locals\n", | ||
352 | header->type); | ||
325 | tbc = GNUNET_new (struct TestingSystemCount); | 353 | tbc = GNUNET_new (struct TestingSystemCount); |
326 | tbc->ns = ns; | 354 | tbc->ns = ns; |
327 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | 355 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. |
328 | if (0 == i) | 356 | if (0 == i) |
329 | tbc->count = j + total_number; | 357 | tbc->count = j; // + total_number; |
330 | else | 358 | else |
331 | tbc->count = (i - 1) * ns->local_m + j + total_number + ns->known; | 359 | tbc->count = (i - 1) * ns->local_m + j + ns->known; // + total_number ; |
332 | 360 | ||
333 | helper = ns->helper[tbc->count - 1 - total_number]; | 361 | helper = ns->helper[tbc->count - 1];// - total_number]; |
334 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
335 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
336 | reply->header.type = htons ( | ||
337 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
338 | reply->header.size = htons ((uint16_t) msg_length); | ||
339 | 362 | ||
340 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | 363 | GNUNET_array_append (ns->msg, ns->n_msg, header); |
341 | 364 | ||
342 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | 365 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( |
343 | helper, | 366 | helper, |
344 | &reply->header, | 367 | header, |
345 | GNUNET_NO, | 368 | GNUNET_NO, |
346 | &clear_msg, | 369 | &clear_msg, |
347 | tbc); | 370 | tbc); |
348 | 371 | ||
349 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | 372 | tbc->shandle = sh; |
373 | // GNUNET_array_append (tbc->shandle, tbc->n_shandle, sh); | ||
374 | } | ||
375 | |||
376 | |||
377 | static void | ||
378 | send_all_local_tests_prepared (unsigned int i, unsigned int j, struct | ||
379 | NetJailState *ns) | ||
380 | { | ||
381 | struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED *reply; | ||
382 | size_t msg_length; | ||
383 | |||
384 | |||
385 | msg_length = sizeof(struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); | ||
386 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); | ||
387 | reply->header.type = htons ( | ||
388 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED); | ||
389 | reply->header.size = htons ((uint16_t) msg_length); | ||
390 | |||
391 | send_message_to_locals (i, j, ns, &reply->header); | ||
392 | } | ||
393 | |||
394 | |||
395 | static void | ||
396 | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | ||
397 | { | ||
398 | |||
399 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
400 | size_t msg_length; | ||
401 | |||
402 | |||
403 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
404 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
405 | reply->header.type = htons ( | ||
406 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
407 | reply->header.size = htons ((uint16_t) msg_length); | ||
408 | |||
409 | send_message_to_locals (i, j, ns, &reply->header); | ||
350 | } | 410 | } |
351 | 411 | ||
352 | 412 | ||
@@ -365,11 +425,22 @@ send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | |||
365 | static int | 425 | static int |
366 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | 426 | helper_mst (void *cls, const struct GNUNET_MessageHeader *message) |
367 | { | 427 | { |
368 | struct TestingSystemCount *tbc = cls; | 428 | // struct TestingSystemCount *tbc = cls; |
369 | struct NetJailState *ns = tbc->ns; | 429 | struct NetJailState *ns = cls;// tbc->ns; |
370 | struct HelperMessage *hp_msg; | 430 | struct HelperMessage *hp_msg; |
371 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | 431 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; |
372 | 432 | ||
433 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
434 | "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", | ||
435 | total_number, | ||
436 | ns->number_of_testsystems_started, | ||
437 | ns->number_of_peers_started, | ||
438 | ns->number_of_local_tests_prepared, | ||
439 | ns->number_of_local_tests_finished, | ||
440 | ns->local_m, | ||
441 | ns->global_n, | ||
442 | ns->known); | ||
443 | |||
373 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | 444 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) |
374 | { | 445 | { |
375 | ns->number_of_testsystems_started++; | 446 | ns->number_of_testsystems_started++; |
@@ -395,11 +466,31 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
395 | ns->number_of_peers_started = 0; | 466 | ns->number_of_peers_started = 0; |
396 | } | 467 | } |
397 | } | 468 | } |
469 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs ( | ||
470 | message->type)) | ||
471 | { | ||
472 | ns->number_of_local_tests_prepared++; | ||
473 | if (ns->number_of_local_tests_prepared == total_number) | ||
474 | { | ||
475 | for (int i = 1; i <= ns->known; i++) | ||
476 | { | ||
477 | send_all_local_tests_prepared (0,i, ns); | ||
478 | } | ||
479 | |||
480 | for (int i = 1; i <= ns->global_n; i++) | ||
481 | { | ||
482 | for (int j = 1; j <= ns->local_m; j++) | ||
483 | { | ||
484 | send_all_local_tests_prepared (i,j, ns); | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | } | ||
398 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( | 489 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( |
399 | message->type)) | 490 | message->type)) |
400 | { | 491 | { |
401 | ns->number_of_local_test_finished++; | 492 | ns->number_of_local_tests_finished++; |
402 | if (ns->number_of_local_test_finished == total_number) | 493 | if (ns->number_of_local_tests_finished == total_number) |
403 | { | 494 | { |
404 | GNUNET_TESTING_async_finish (&ns->ac); | 495 | GNUNET_TESTING_async_finish (&ns->ac); |
405 | } | 496 | } |
@@ -477,8 +568,13 @@ start_helper (struct NetJailState *ns, struct | |||
477 | struct GNUNET_HELPER_Handle *helper; | 568 | struct GNUNET_HELPER_Handle *helper; |
478 | struct GNUNET_CMDS_HelperInit *msg; | 569 | struct GNUNET_CMDS_HelperInit *msg; |
479 | struct TestingSystemCount *tbc; | 570 | struct TestingSystemCount *tbc; |
480 | char *m_char, *n_char, *global_n_char, *local_m_char, *known_char, *node_id, | 571 | char *m_char; |
481 | *plugin; | 572 | char *n_char; |
573 | char *global_n_char; | ||
574 | char *local_m_char; | ||
575 | char *known_char; | ||
576 | char *node_id; | ||
577 | char *plugin; | ||
482 | pid_t pid; | 578 | pid_t pid; |
483 | unsigned int script_num; | 579 | unsigned int script_num; |
484 | struct GNUNET_ShortHashCode *hkey; | 580 | struct GNUNET_ShortHashCode *hkey; |
@@ -486,6 +582,7 @@ start_helper (struct NetJailState *ns, struct | |||
486 | struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; | 582 | struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; |
487 | struct GNUNET_TESTING_NetjailNode *node; | 583 | struct GNUNET_TESTING_NetjailNode *node; |
488 | struct GNUNET_TESTING_NetjailNamespace *namespace; | 584 | struct GNUNET_TESTING_NetjailNamespace *namespace; |
585 | unsigned int *rv = ns->rv; | ||
489 | 586 | ||
490 | 587 | ||
491 | if (0 == n) | 588 | if (0 == n) |
@@ -526,7 +623,8 @@ start_helper (struct NetJailState *ns, struct | |||
526 | else | 623 | else |
527 | tbc->count = (n - 1) * ns->local_m + m + ns->known; | 624 | tbc->count = (n - 1) * ns->local_m + m + ns->known; |
528 | 625 | ||
529 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, | 626 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, |
627 | ns->tbcs_tail, | ||
530 | tbc); | 628 | tbc); |
531 | 629 | ||
532 | 630 | ||
@@ -535,23 +633,33 @@ start_helper (struct NetJailState *ns, struct | |||
535 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 633 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
536 | "No SUID for %s!\n", | 634 | "No SUID for %s!\n", |
537 | NETJAIL_EXEC_SCRIPT); | 635 | NETJAIL_EXEC_SCRIPT); |
538 | GNUNET_TESTING_interpreter_fail (ns->ac.is); | 636 | *rv = 1; |
539 | } | 637 | } |
540 | else if (GNUNET_NO == helper_check) | 638 | else if (GNUNET_NO == helper_check) |
541 | { | 639 | { |
542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 640 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
543 | "%s not found!\n", | 641 | "%s not found!\n", |
544 | NETJAIL_EXEC_SCRIPT); | 642 | NETJAIL_EXEC_SCRIPT); |
545 | GNUNET_TESTING_interpreter_fail (ns->ac.is); | 643 | *rv = 1; |
546 | } | 644 | } |
547 | 645 | ||
646 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
647 | "sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", | ||
648 | ns->number_of_testsystems_started, | ||
649 | ns->number_of_peers_started, | ||
650 | ns->number_of_local_tests_prepared, | ||
651 | ns->number_of_local_tests_finished, | ||
652 | ns->local_m, | ||
653 | ns->global_n, | ||
654 | ns->known); | ||
655 | |||
548 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( | 656 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( |
549 | GNUNET_YES, | 657 | GNUNET_YES, |
550 | NETJAIL_EXEC_SCRIPT, | 658 | NETJAIL_EXEC_SCRIPT, |
551 | script_argv, | 659 | script_argv, |
552 | &helper_mst, | 660 | &helper_mst, |
553 | &exp_cb, | 661 | &exp_cb, |
554 | tbc)); | 662 | ns)); |
555 | 663 | ||
556 | helper = ns->helper[tbc->count - 1]; | 664 | helper = ns->helper[tbc->count - 1]; |
557 | 665 | ||
@@ -608,19 +716,20 @@ start_helper (struct NetJailState *ns, struct | |||
608 | 716 | ||
609 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | 717 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); |
610 | 718 | ||
611 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | 719 | // GNUNET_array_append (tbc->shandle, tbc->n_shandle, |
612 | helper, | 720 | tbc->shandle = GNUNET_HELPER_send ( |
613 | &msg->header, | 721 | helper, |
614 | GNUNET_NO, | 722 | &msg->header, |
615 | &clear_msg, | 723 | GNUNET_NO, |
616 | tbc)); | 724 | &clear_msg, |
725 | tbc); // ); | ||
617 | 726 | ||
618 | if (NULL == ns->shandle[tbc->count - 1]) | 727 | if (NULL == tbc->shandle)// [tbc->count - 1]) |
619 | { | 728 | { |
620 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 729 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
621 | "Send handle is NULL!\n"); | 730 | "Send handle is NULL!\n"); |
622 | GNUNET_free (msg); | 731 | GNUNET_free (msg); |
623 | GNUNET_TESTING_interpreter_fail (ns->ac.is); | 732 | *rv = 1; |
624 | } | 733 | } |
625 | } | 734 | } |
626 | 735 | ||
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c index d3754153d..33792f1b0 100644 --- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c | |||
@@ -95,7 +95,7 @@ stop_testing_system_run (void *cls, | |||
95 | struct GNUNET_HELPER_Handle **helper; | 95 | struct GNUNET_HELPER_Handle **helper; |
96 | const struct GNUNET_TESTING_Command *start_helper_cmd; | 96 | const struct GNUNET_TESTING_Command *start_helper_cmd; |
97 | 97 | ||
98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (NULL, | 98 | start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
99 | shs-> | 99 | shs-> |
100 | helper_start_label); | 100 | helper_start_label); |
101 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, | 101 | GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd, |
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c index 8b4c11deb..8eef1d8f1 100644 --- a/src/testing/testing_api_cmd_send_peer_ready.c +++ b/src/testing/testing_api_cmd_send_peer_ready.c | |||
@@ -72,7 +72,6 @@ send_peer_ready_cleanup (void *cls) | |||
72 | { | 72 | { |
73 | struct SendPeerReadyState *sprs = cls; | 73 | struct SendPeerReadyState *sprs = cls; |
74 | 74 | ||
75 | GNUNET_free (sprs->reply); | ||
76 | GNUNET_free (sprs); | 75 | GNUNET_free (sprs); |
77 | } | 76 | } |
78 | 77 | ||
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c index 8889f9d06..f0b47084b 100644 --- a/src/transport/test_transport_plugin_cmd_simple_send.c +++ b/src/transport/test_transport_plugin_cmd_simple_send.c | |||
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #define BASE_DIR "testdir" | 38 | #define BASE_DIR "testdir" |
39 | 39 | ||
40 | #define TOPOLOGY_CONFIG "test_transport_simple_send_topo.conf" | ||
40 | 41 | ||
41 | struct TestState | 42 | struct TestState |
42 | { | 43 | { |
@@ -154,8 +155,8 @@ notify_connect (void *cls, | |||
154 | { | 155 | { |
155 | struct ConnectPeersState *cps; | 156 | struct ConnectPeersState *cps; |
156 | 157 | ||
157 | GNUNET_TESTING_get_trait_connect_peer_state (&connect_peers, | 158 | GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers, |
158 | &cps); | 159 | &cps); |
159 | void *ret = NULL; | 160 | void *ret = NULL; |
160 | 161 | ||
161 | cps->notify_connect (cps, | 162 | cps->notify_connect (cps, |
@@ -203,7 +204,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
203 | "start-peer", | 204 | "start-peer", |
204 | "system-create", | 205 | "system-create", |
205 | num, | 206 | num, |
206 | NULL); | 207 | topology); |
207 | 208 | ||
208 | 209 | ||
209 | 210 | ||
@@ -257,7 +258,8 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
257 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 258 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
258 | "start-peer"), | 259 | "start-peer"), |
259 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 260 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
260 | "system-create") | 261 | "system-create"), |
262 | GNUNET_TESTING_cmd_end () | ||
261 | }; | 263 | }; |
262 | 264 | ||
263 | GNUNET_TESTING_run (commands, | 265 | GNUNET_TESTING_run (commands, |
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index b0ca37447..ee6dc0274 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c | |||
@@ -62,9 +62,8 @@ struct TestState | |||
62 | 62 | ||
63 | static struct GNUNET_TESTING_Command block_send; | 63 | static struct GNUNET_TESTING_Command block_send; |
64 | 64 | ||
65 | static struct GNUNET_TESTING_Command block_receive; | ||
66 | |||
67 | static struct GNUNET_TESTING_Command connect_peers; | 65 | static struct GNUNET_TESTING_Command connect_peers; |
66 | static struct GNUNET_TESTING_Command local_prepared; | ||
68 | 67 | ||
69 | 68 | ||
70 | /** | 69 | /** |
@@ -89,14 +88,14 @@ static void | |||
89 | handle_test (void *cls, | 88 | handle_test (void *cls, |
90 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) | 89 | const struct GNUNET_TRANSPORT_TESTING_TestMessage *message) |
91 | { | 90 | { |
92 | struct GNUNET_TESTING_AsyncContext *ac; | 91 | // struct GNUNET_TESTING_AsyncContext *ac; |
93 | 92 | ||
94 | GNUNET_TESTING_get_trait_async_context (&block_receive, | 93 | /*GNUNET_TESTING_get_trait_async_context (&block_receive, |
95 | &ac); | 94 | &ac); |
96 | if ((NULL == ac) || (NULL == ac->cont)) | 95 | if ((NULL == ac) || (NULL == ac->cont)) |
97 | GNUNET_TESTING_async_fail (ac); | 96 | GNUNET_TESTING_async_fail (ac); |
98 | else | 97 | else |
99 | GNUNET_TESTING_async_finish (ac); | 98 | GNUNET_TESTING_async_finish (ac);*/ |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
@@ -136,8 +135,11 @@ handle_result (void *cls, | |||
136 | rv); | 135 | rv); |
137 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); | 136 | reply = GNUNET_TESTING_send_local_test_finished_msg (rv); |
138 | 137 | ||
138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
139 | "message prepared\n"); | ||
139 | ts->write_message (reply, | 140 | ts->write_message (reply, |
140 | ntohs (reply->size)); | 141 | ntohs (reply->size)); |
142 | |||
141 | GNUNET_free (ts->testdir); | 143 | GNUNET_free (ts->testdir); |
142 | GNUNET_free (ts->cfgname); | 144 | GNUNET_free (ts->cfgname); |
143 | GNUNET_free (ts); | 145 | GNUNET_free (ts); |
@@ -155,8 +157,8 @@ notify_connect (void *cls, | |||
155 | { | 157 | { |
156 | struct ConnectPeersState *cps; | 158 | struct ConnectPeersState *cps; |
157 | 159 | ||
158 | GNUNET_TESTING_get_trait_connect_peer_state (&connect_peers, | 160 | GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers, |
159 | &cps); | 161 | &cps); |
160 | void *ret = NULL; | 162 | void *ret = NULL; |
161 | 163 | ||
162 | cps->notify_connect (cps, | 164 | cps->notify_connect (cps, |
@@ -171,7 +173,14 @@ notify_connect (void *cls, | |||
171 | static void | 173 | static void |
172 | all_local_tests_prepared () | 174 | all_local_tests_prepared () |
173 | { | 175 | { |
174 | are_all_local_tests_prepared = GNUNET_YES; | 176 | struct LocalPreparedState *lfs; |
177 | GNUNET_TESTING_get_trait_local_prepared_state (&local_prepared, | ||
178 | &lfs); | ||
179 | |||
180 | if ((NULL == &lfs->ac) || (NULL == lfs->ac.cont)) | ||
181 | GNUNET_TESTING_async_fail (&lfs->ac); | ||
182 | else | ||
183 | GNUNET_TESTING_async_finish (&lfs->ac); | ||
175 | } | 184 | } |
176 | 185 | ||
177 | /** | 186 | /** |
@@ -212,13 +221,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
212 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; | 221 | num = (n_int - 1) * local_m_int + m_int + topology->nodes_x; |
213 | 222 | ||
214 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); | 223 | block_send = GNUNET_TESTING_cmd_block_until_external_trigger ("block"); |
215 | block_receive = GNUNET_TESTING_cmd_block_until_external_trigger ( | ||
216 | "block-receive"); | ||
217 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", | 224 | connect_peers = GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers", |
218 | "start-peer", | 225 | "start-peer", |
219 | "system-create", | 226 | "system-create", |
220 | num, | 227 | num, |
221 | NULL); | 228 | topology); |
229 | local_prepared = GNUNET_TESTING_cmd_local_test_prepared ( | ||
230 | "local-test-prepared", | ||
231 | write_message); | ||
222 | 232 | ||
223 | GNUNET_asprintf (&ts->cfgname, | 233 | GNUNET_asprintf (&ts->cfgname, |
224 | "test_transport_api2_tcp_node1.conf"); | 234 | "test_transport_api2_tcp_node1.conf"); |
@@ -266,16 +276,16 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip, | |||
266 | m_int, | 276 | m_int, |
267 | n_int, | 277 | n_int, |
268 | topology), | 278 | topology), |
269 | GNUNET_TESTING_cmd_local_test_prepared ("local-test-prepared", | 279 | local_prepared, |
270 | write_message, | ||
271 | &are_all_local_tests_prepared), | ||
272 | block_receive, | ||
273 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", | 280 | GNUNET_TRANSPORT_cmd_stop_peer ("stop-peer", |
274 | "start-peer"), | 281 | "start-peer"), |
275 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", | 282 | GNUNET_TESTING_cmd_system_destroy ("system-destroy", |
276 | "system-create") | 283 | "system-create"), |
284 | GNUNET_TESTING_cmd_end () | ||
277 | }; | 285 | }; |
278 | 286 | ||
287 | ts->write_message = write_message; | ||
288 | |||
279 | GNUNET_TESTING_run (commands, | 289 | GNUNET_TESTING_run (commands, |
280 | GNUNET_TIME_UNIT_FOREVER_REL, | 290 | GNUNET_TIME_UNIT_FOREVER_REL, |
281 | &handle_result, | 291 | &handle_result, |
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index f6e34df62..d6bb46f7d 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h | |||
@@ -182,7 +182,7 @@ struct StartPeerState | |||
182 | * | 182 | * |
183 | */ | 183 | */ |
184 | int | 184 | int |
185 | GNUNET_TESTING_get_trait_connect_peer_state ( | 185 | GNUNET_TRANSPORT_get_trait_connect_peer_state ( |
186 | const struct GNUNET_TESTING_Command *cmd, | 186 | const struct GNUNET_TESTING_Command *cmd, |
187 | struct ConnectPeersState **cps); | 187 | struct ConnectPeersState **cps); |
188 | 188 | ||
@@ -234,6 +234,29 @@ GNUNET_TRANSPORT_cmd_send_simple (const char *label, | |||
234 | uint32_t num); | 234 | uint32_t num); |
235 | 235 | ||
236 | 236 | ||
237 | /** | ||
238 | * Create command. | ||
239 | * | ||
240 | * @param label name for command. | ||
241 | * @param start_peer_label Label of the cmd to start a peer. | ||
242 | * @param create_label Label of the cmd to create the testing system. | ||
243 | * @param num Number globally identifying the node. | ||
244 | * @param node_n The number of the node in a network namespace. | ||
245 | * @param namespace_n The number of the network namespace. | ||
246 | * @param The topology for the test setup. | ||
247 | * @return command. | ||
248 | */ | ||
249 | struct GNUNET_TESTING_Command | ||
250 | GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | ||
251 | const char *start_peer_label, | ||
252 | const char *create_label, | ||
253 | uint32_t num, | ||
254 | unsigned int node_n, | ||
255 | unsigned int namespace_n, | ||
256 | struct GNUNET_TESTING_NetjailTopology * | ||
257 | topology); | ||
258 | |||
259 | |||
237 | 260 | ||
238 | 261 | ||
239 | 262 | ||
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index 5cc13dbfa..03b231347 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c | |||
@@ -51,6 +51,11 @@ | |||
51 | struct CheckState | 51 | struct CheckState |
52 | { | 52 | { |
53 | /** | 53 | /** |
54 | * Context for our asynchronous completion. | ||
55 | */ | ||
56 | struct GNUNET_TESTING_AsyncContext ac; | ||
57 | |||
58 | /** | ||
54 | * The number of the node in a network namespace. | 59 | * The number of the node in a network namespace. |
55 | */ | 60 | */ |
56 | unsigned int node_n; | 61 | unsigned int node_n; |
@@ -119,11 +124,6 @@ struct CheckState | |||
119 | * Stream to read log file lines. | 124 | * Stream to read log file lines. |
120 | */ | 125 | */ |
121 | FILE *stream; | 126 | FILE *stream; |
122 | |||
123 | /** | ||
124 | * Did we get all bachchannel messages. | ||
125 | */ | ||
126 | enum GNUNET_GenericReturnValue finished; | ||
127 | }; | 127 | }; |
128 | 128 | ||
129 | /** | 129 | /** |
@@ -195,7 +195,7 @@ read_from_log (void *cls) | |||
195 | strcmp ( | 195 | strcmp ( |
196 | "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp", | 196 | "Delivering backchannel message from 4TTC to F7B5 of type 1460 to udp", |
197 | cs->search_string[i])); | 197 | cs->search_string[i])); |
198 | cs->finished = GNUNET_YES; | 198 | GNUNET_TESTING_async_finish (&cs->ac); |
199 | fclose (cs->stream); | 199 | fclose (cs->stream); |
200 | return; | 200 | return; |
201 | } | 201 | } |
@@ -396,7 +396,6 @@ add_search_string (struct CheckState *cs, const struct | |||
396 | */ | 396 | */ |
397 | static void | 397 | static void |
398 | backchannel_check_run (void *cls, | 398 | backchannel_check_run (void *cls, |
399 | const struct GNUNET_TESTING_Command *cmd, | ||
400 | struct GNUNET_TESTING_Interpreter *is) | 399 | struct GNUNET_TESTING_Interpreter *is) |
401 | { | 400 | { |
402 | struct CheckState *cs = cls; | 401 | struct CheckState *cs = cls; |
@@ -418,12 +417,13 @@ backchannel_check_run (void *cls, | |||
418 | const struct GNUNET_TESTING_NetjailNode *node; | 417 | const struct GNUNET_TESTING_NetjailNode *node; |
419 | const struct GNUNET_TESTING_NetjailNamespace *namespace; | 418 | const struct GNUNET_TESTING_NetjailNamespace *namespace; |
420 | 419 | ||
421 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command ( | 420 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
422 | cs->start_peer_label); | 421 | cs->start_peer_label); |
423 | GNUNET_TRANSPORT_get_trait_application_handle_v2 (peer1_cmd, | 422 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, |
424 | &ah); | 423 | &ah); |
425 | 424 | ||
426 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cs->create_label); | 425 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
426 | cs->create_label); | ||
427 | GNUNET_TESTING_get_trait_test_system (system_cmd, | 427 | GNUNET_TESTING_get_trait_test_system (system_cmd, |
428 | &tl_system); | 428 | &tl_system); |
429 | 429 | ||
@@ -524,28 +524,8 @@ backchannel_check_run (void *cls, | |||
524 | cs); | 524 | cs); |
525 | } | 525 | } |
526 | else | 526 | else |
527 | cs->finished = GNUNET_YES; | 527 | GNUNET_TESTING_async_finish (&cs->ac); |
528 | |||
529 | } | ||
530 | |||
531 | 528 | ||
532 | /** | ||
533 | * The finish function of this cmd will check if the peers we are trying to | ||
534 | * connect to are in the connected peers map of the start peer cmd for this peer. | ||
535 | * | ||
536 | */ | ||
537 | static int | ||
538 | backchannel_check_finish (void *cls, | ||
539 | GNUNET_SCHEDULER_TaskCallback cont, | ||
540 | void *cont_cls) | ||
541 | { | ||
542 | struct CheckState *cs = cls; | ||
543 | |||
544 | if (cs->finished) | ||
545 | { | ||
546 | cont (cont_cls); | ||
547 | } | ||
548 | return cs->finished; | ||
549 | } | 529 | } |
550 | 530 | ||
551 | 531 | ||
@@ -568,8 +548,7 @@ backchannel_check_traits (void *cls, | |||
568 | * | 548 | * |
569 | */ | 549 | */ |
570 | static void | 550 | static void |
571 | backchannel_check_cleanup (void *cls, | 551 | backchannel_check_cleanup (void *cls) |
572 | const struct GNUNET_TESTING_Command *cmd) | ||
573 | { | 552 | { |
574 | struct ConnectPeersState *cs = cls; | 553 | struct ConnectPeersState *cs = cls; |
575 | 554 | ||
@@ -613,7 +592,7 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, | |||
613 | .cls = cs, | 592 | .cls = cs, |
614 | .label = label, | 593 | .label = label, |
615 | .run = &backchannel_check_run, | 594 | .run = &backchannel_check_run, |
616 | .finish = &backchannel_check_finish, | 595 | .ac = &cs->ac, |
617 | .cleanup = &backchannel_check_cleanup, | 596 | .cleanup = &backchannel_check_cleanup, |
618 | .traits = &backchannel_check_traits | 597 | .traits = &backchannel_check_traits |
619 | }; | 598 | }; |
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 2e51363f6..017d1bca3 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -36,242 +36,6 @@ | |||
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
38 | 38 | ||
39 | #define CONNECT_ADDRESS_TEMPLATE_TCP "tcp-192.168.15.%u:60002" | ||
40 | |||
41 | #define CONNECT_ADDRESS_TEMPLATE_UDP "udp-192.168.15.%u:60002" | ||
42 | |||
43 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.150.%u:60002" | ||
44 | |||
45 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.150.%u:60002" | ||
46 | |||
47 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.151.%u:60002" | ||
48 | |||
49 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.151.%u:60002" | ||
50 | |||
51 | #define PREFIX_TCP "tcp" | ||
52 | |||
53 | #define PREFIX_UDP "udp" | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | static struct GNUNET_PeerIdentity * | ||
59 | get_pub_key (unsigned int num, struct GNUNET_TESTING_System *tl_system) | ||
60 | { | ||
61 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
62 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct | ||
63 | GNUNET_CRYPTO_EddsaPublicKey); | ||
64 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct | ||
65 | GNUNET_CRYPTO_EddsaPrivateKey); | ||
66 | |||
67 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, | ||
68 | num, | ||
69 | peer); | ||
70 | |||
71 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, | ||
72 | pub_key); | ||
73 | peer->public_key = *pub_key; | ||
74 | return peer; | ||
75 | } | ||
76 | |||
77 | |||
78 | static int | ||
79 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
80 | { | ||
81 | struct GNUNET_TESTING_NetjailNode *node = value; | ||
82 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
83 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | ||
84 | |||
85 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
86 | "plugin: %s space: %u node: %u global: %u\n", | ||
87 | node->plugin, | ||
88 | node->namespace_n, | ||
89 | node->node_n, | ||
90 | node->is_global); | ||
91 | |||
92 | for (pos_connection = node->node_connections_head; NULL != pos_connection; | ||
93 | pos_connection = pos_connection->next) | ||
94 | { | ||
95 | |||
96 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
97 | "namespace_n: %u node_n: %u node_type: %u\n", | ||
98 | pos_connection->namespace_n, | ||
99 | pos_connection->node_n, | ||
100 | pos_connection->node_type); | ||
101 | |||
102 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
103 | pos_prefix = | ||
104 | pos_prefix->next) | ||
105 | { | ||
106 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
107 | "prefix: %s\n", | ||
108 | pos_prefix->address_prefix); | ||
109 | } | ||
110 | } | ||
111 | return GNUNET_YES; | ||
112 | } | ||
113 | |||
114 | |||
115 | static int | ||
116 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
117 | { | ||
118 | struct GNUNET_TESTING_NetjailNamespace *namespace = value; | ||
119 | struct GNUNET_TESTING_NetjailRouter *router = namespace->router; | ||
120 | |||
121 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
122 | "router_tcp: %u router_udp: %u spaces: %u\n", | ||
123 | router->tcp_port, | ||
124 | router->udp_port, | ||
125 | namespace->namespace_n); | ||
126 | GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL); | ||
127 | return GNUNET_YES; | ||
128 | } | ||
129 | |||
130 | |||
131 | static int | ||
132 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) | ||
133 | { | ||
134 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
135 | "plugin: %s spaces: %u nodes: %u known: %u\n", | ||
136 | topology->plugin, | ||
137 | topology->namespaces_n, | ||
138 | topology->nodes_m, | ||
139 | topology->nodes_x); | ||
140 | |||
141 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, | ||
142 | log_namespaces, NULL); | ||
143 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, &log_nodes, | ||
144 | NULL); | ||
145 | return GNUNET_YES; | ||
146 | } | ||
147 | |||
148 | |||
149 | static struct GNUNET_TESTING_NodeConnection * | ||
150 | get_connections (unsigned int num, struct | ||
151 | GNUNET_TESTING_NetjailTopology *topology) | ||
152 | { | ||
153 | struct GNUNET_TESTING_NetjailNode *node; | ||
154 | struct GNUNET_ShortHashCode *hkey; | ||
155 | struct GNUNET_HashCode hc; | ||
156 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
157 | unsigned int namespace_n, node_m; | ||
158 | |||
159 | log_topo (topology); | ||
160 | |||
161 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
162 | if (topology->nodes_x >= num) | ||
163 | { | ||
164 | |||
165 | GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); | ||
166 | memcpy (hkey, | ||
167 | &hc, | ||
168 | sizeof (*hkey)); | ||
169 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
170 | hkey); | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | namespace_n = (unsigned int) floor ((num - topology->nodes_x) | ||
175 | / topology->nodes_m); | ||
176 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
177 | "num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", | ||
178 | num, | ||
179 | topology->nodes_x, | ||
180 | topology->nodes_m, | ||
181 | namespace_n); | ||
182 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
183 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); | ||
184 | memcpy (hkey, | ||
185 | &hc, | ||
186 | sizeof (*hkey)); | ||
187 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
188 | hkey); | ||
189 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); | ||
190 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
191 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); | ||
192 | memcpy (hkey, | ||
193 | &hc, | ||
194 | sizeof (*hkey)); | ||
195 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
196 | hkey); | ||
197 | } | ||
198 | |||
199 | |||
200 | return node->node_connections_head; | ||
201 | } | ||
202 | |||
203 | |||
204 | static unsigned int | ||
205 | calculate_num (struct GNUNET_TESTING_NodeConnection *node_connection, | ||
206 | struct GNUNET_TESTING_NetjailTopology *topology) | ||
207 | { | ||
208 | unsigned int n, m, num; | ||
209 | |||
210 | n = node_connection->namespace_n; | ||
211 | m = node_connection->node_n; | ||
212 | |||
213 | if (0 == n) | ||
214 | num = m; | ||
215 | else | ||
216 | num = (n - 1) * topology->nodes_m + m + topology->nodes_x; | ||
217 | |||
218 | return num; | ||
219 | } | ||
220 | |||
221 | |||
222 | static char * | ||
223 | get_address (struct GNUNET_TESTING_NodeConnection *connection, | ||
224 | char *prefix) | ||
225 | { | ||
226 | struct GNUNET_TESTING_NetjailNode *node; | ||
227 | char *addr; | ||
228 | |||
229 | node = connection->node; | ||
230 | if (connection->namespace_n == node->namespace_n) | ||
231 | { | ||
232 | if (0 == strcmp (PREFIX_TCP, prefix)) | ||
233 | { | ||
234 | |||
235 | GNUNET_asprintf (&addr, | ||
236 | CONNECT_ADDRESS_TEMPLATE_TCP, | ||
237 | connection->node_n); | ||
238 | } | ||
239 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
240 | { | ||
241 | GNUNET_asprintf (&addr, | ||
242 | CONNECT_ADDRESS_TEMPLATE_UDP, | ||
243 | connection->node_n); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | GNUNET_break (0); | ||
248 | } | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | if (0 == strcmp (PREFIX_TCP, prefix)) | ||
253 | { | ||
254 | |||
255 | GNUNET_asprintf (&addr, | ||
256 | ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP, | ||
257 | connection->namespace_n); | ||
258 | } | ||
259 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
260 | { | ||
261 | GNUNET_asprintf (&addr, | ||
262 | ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP, | ||
263 | connection->namespace_n); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | GNUNET_break (0); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | return addr; | ||
272 | } | ||
273 | |||
274 | |||
275 | /** | 39 | /** |
276 | * The run method of this cmd will connect to peers. | 40 | * The run method of this cmd will connect to peers. |
277 | * | 41 | * |
@@ -292,7 +56,7 @@ connect_peers_run (void *cls, | |||
292 | enum GNUNET_NetworkType nt = 0; | 56 | enum GNUNET_NetworkType nt = 0; |
293 | uint32_t num; | 57 | uint32_t num; |
294 | struct GNUNET_TESTING_NodeConnection *pos_connection; | 58 | struct GNUNET_TESTING_NodeConnection *pos_connection; |
295 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | 59 | struct GNUNET_TESTING_AddressPrefix *pos_prefix; |
296 | unsigned int con_num = 0; | 60 | unsigned int con_num = 0; |
297 | 61 | ||
298 | cps->is = is; | 62 | cps->is = is; |
@@ -308,13 +72,14 @@ connect_peers_run (void *cls, | |||
308 | 72 | ||
309 | cps->tl_system = tl_system; | 73 | cps->tl_system = tl_system; |
310 | 74 | ||
311 | cps->node_connections_head = get_connections (cps->num, cps->topology); | 75 | cps->node_connections_head = GNUNET_TESTING_get_connections (cps->num, |
76 | cps->topology); | ||
312 | 77 | ||
313 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | 78 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
314 | pos_connection = pos_connection->next) | 79 | pos_connection = pos_connection->next) |
315 | { | 80 | { |
316 | con_num++; | 81 | con_num++; |
317 | num = calculate_num (pos_connection, cps->topology); | 82 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); |
318 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | 83 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; |
319 | pos_prefix = | 84 | pos_prefix = |
320 | pos_prefix->next) | 85 | pos_prefix->next) |
@@ -324,9 +89,10 @@ connect_peers_run (void *cls, | |||
324 | "prefix: %s\n", | 89 | "prefix: %s\n", |
325 | pos_prefix->address_prefix); | 90 | pos_prefix->address_prefix); |
326 | 91 | ||
327 | addr = get_address (pos_connection, pos_prefix->address_prefix); | 92 | addr = GNUNET_TESTING_get_address (pos_connection, |
93 | pos_prefix->address_prefix); | ||
328 | 94 | ||
329 | peer = get_pub_key (num, tl_system); | 95 | peer = GNUNET_TESTING_get_pub_key (num, tl_system); |
330 | 96 | ||
331 | LOG (GNUNET_ERROR_TYPE_ERROR, | 97 | LOG (GNUNET_ERROR_TYPE_ERROR, |
332 | "num: %u pub_key %s addr: %s\n", | 98 | "num: %u pub_key %s addr: %s\n", |
@@ -365,8 +131,8 @@ notify_connect (void *cls, | |||
365 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | 131 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
366 | pos_connection = pos_connection->next) | 132 | pos_connection = pos_connection->next) |
367 | { | 133 | { |
368 | num = calculate_num (pos_connection, cps->topology); | 134 | num = GNUNET_TESTING_calculate_num (pos_connection, cps->topology); |
369 | peer_connection = get_pub_key (num, cps->tl_system); | 135 | peer_connection = GNUNET_TESTING_get_pub_key (num, cps->tl_system); |
370 | if (0 == GNUNET_memcmp (peer, | 136 | if (0 == GNUNET_memcmp (peer, |
371 | peer_connection)) | 137 | peer_connection)) |
372 | con_num++; | 138 | con_num++; |
@@ -399,7 +165,7 @@ connect_peers_cleanup (void *cls) | |||
399 | * This function prepares an array with traits. | 165 | * This function prepares an array with traits. |
400 | * | 166 | * |
401 | */ | 167 | */ |
402 | static int | 168 | enum GNUNET_GenericReturnValue |
403 | connect_peers_traits (void *cls, | 169 | connect_peers_traits (void *cls, |
404 | const void **ret, | 170 | const void **ret, |
405 | const char *trait, | 171 | const char *trait, |
@@ -428,8 +194,8 @@ connect_peers_traits (void *cls, | |||
428 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | 194 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. |
429 | * | 195 | * |
430 | */ | 196 | */ |
431 | int | 197 | enum GNUNET_GenericReturnValue |
432 | GNUNET_TESTING_get_trait_connect_peer_state ( | 198 | GNUNET_TRANSPORT_get_trait_connect_peer_state ( |
433 | const struct GNUNET_TESTING_Command *cmd, | 199 | const struct GNUNET_TESTING_Command *cmd, |
434 | struct ConnectPeersState **cps) | 200 | struct ConnectPeersState **cps) |
435 | { | 201 | { |