diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-09 22:34:49 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-09 22:34:49 +0000 |
commit | c0b81510ffe194dc662c3a6267d5e66a69873c4b (patch) | |
tree | 5ad5cc473d6993523be80bcf1430230e224d9216 /src/transport/test_transport_api_manipulation_send_tcp.c | |
parent | a7345f7436c421fd15e18e87ec399ea93b6dde03 (diff) | |
download | gnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.tar.gz gnunet-c0b81510ffe194dc662c3a6267d5e66a69873c4b.zip |
-start to refactor testcases for sanity
Diffstat (limited to 'src/transport/test_transport_api_manipulation_send_tcp.c')
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/transport/test_transport_api_manipulation_send_tcp.c b/src/transport/test_transport_api_manipulation_send_tcp.c index e031b7111..c5604ff08 100644 --- a/src/transport/test_transport_api_manipulation_send_tcp.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -63,15 +63,15 @@ static struct GNUNET_SCHEDULER_Task * die_task; | |||
63 | 63 | ||
64 | static struct GNUNET_SCHEDULER_Task * send_task; | 64 | static struct GNUNET_SCHEDULER_Task * send_task; |
65 | 65 | ||
66 | static struct PeerContext *p1; | 66 | static struct GNUNET_TRANSPORT_TESTING_PeerContext *p1; |
67 | 67 | ||
68 | static struct PeerContext *p2; | 68 | static struct GNUNET_TRANSPORT_TESTING_PeerContext *p2; |
69 | 69 | ||
70 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; | 70 | static struct GNUNET_TRANSPORT_TESTING_ConnectRequest * cc; |
71 | 71 | ||
72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; | 72 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 73 | ||
74 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; | 74 | static struct GNUNET_TRANSPORT_TESTING_Handle *tth; |
75 | 75 | ||
76 | static char *cfg_file_p1; | 76 | static char *cfg_file_p1; |
77 | 77 | ||
@@ -101,8 +101,8 @@ end () | |||
101 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 101 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
102 | th = NULL; | 102 | th = NULL; |
103 | 103 | ||
104 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 104 | GNUNET_TRANSPORT_TESTING_stop_peer (p1); |
105 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 105 | GNUNET_TRANSPORT_TESTING_stop_peer (p2); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
@@ -120,7 +120,7 @@ end_badly (void *cls) | |||
120 | if (cc != NULL) | 120 | if (cc != NULL) |
121 | { | 121 | { |
122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); | 122 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Fail! Could not connect peers\n")); |
123 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc); | 123 | GNUNET_TRANSPORT_TESTING_connect_peers_cancel (cc); |
124 | cc = NULL; | 124 | cc = NULL; |
125 | } | 125 | } |
126 | 126 | ||
@@ -147,11 +147,11 @@ end_badly (void *cls) | |||
147 | th = NULL; | 147 | th = NULL; |
148 | 148 | ||
149 | if (p1 != NULL) | 149 | if (p1 != NULL) |
150 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p1); | 150 | GNUNET_TRANSPORT_TESTING_stop_peer (p1); |
151 | else | 151 | else |
152 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); | 152 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 1 was not started\n")); |
153 | if (p2 != NULL) | 153 | if (p2 != NULL) |
154 | GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2); | 154 | GNUNET_TRANSPORT_TESTING_stop_peer (p2); |
155 | else | 155 | else |
156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); | 156 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Peer 2 was not started\n")); |
157 | 157 | ||
@@ -167,8 +167,8 @@ static void | |||
167 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | 167 | notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, |
168 | const struct GNUNET_MessageHeader *message) | 168 | const struct GNUNET_MessageHeader *message) |
169 | { | 169 | { |
170 | struct PeerContext *p = cls; | 170 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
171 | struct PeerContext *t = NULL; | 171 | struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL; |
172 | 172 | ||
173 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 173 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
174 | t = p1; | 174 | t = p1; |
@@ -244,7 +244,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
244 | static size_t | 244 | static size_t |
245 | notify_ready (void *cls, size_t size, void *buf) | 245 | notify_ready (void *cls, size_t size, void *buf) |
246 | { | 246 | { |
247 | struct PeerContext *p = cls; | 247 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
248 | struct GNUNET_MessageHeader *hdr; | 248 | struct GNUNET_MessageHeader *hdr; |
249 | 249 | ||
250 | th = NULL; | 250 | th = NULL; |
@@ -333,8 +333,8 @@ static void | |||
333 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | 333 | notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) |
334 | { | 334 | { |
335 | static int c; | 335 | static int c; |
336 | struct PeerContext *p = cls; | 336 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
337 | struct PeerContext *t = NULL; | 337 | struct GNUNET_TRANSPORT_TESTING_PeerContext *t = NULL; |
338 | 338 | ||
339 | c++; | 339 | c++; |
340 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) | 340 | if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity))) |
@@ -360,7 +360,7 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
360 | static void | 360 | static void |
361 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | 361 | notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) |
362 | { | 362 | { |
363 | struct PeerContext *p = cls; | 363 | struct GNUNET_TRANSPORT_TESTING_PeerContext *p = cls; |
364 | 364 | ||
365 | { | 365 | { |
366 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 366 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
@@ -382,7 +382,7 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
382 | 382 | ||
383 | 383 | ||
384 | static void | 384 | static void |
385 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 385 | testing_connect_cb (void *cls) |
386 | { | 386 | { |
387 | cc = NULL; | 387 | cc = NULL; |
388 | 388 | ||
@@ -404,7 +404,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
404 | 404 | ||
405 | 405 | ||
406 | static void | 406 | static void |
407 | start_cb (struct PeerContext *p, void *cls) | 407 | start_cb (struct GNUNET_TRANSPORT_TESTING_PeerContext *p, void *cls) |
408 | { | 408 | { |
409 | static int started; | 409 | static int started; |
410 | started++; | 410 | started++; |
@@ -424,7 +424,8 @@ start_cb (struct PeerContext *p, void *cls) | |||
424 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 424 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
425 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | 425 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); |
426 | GNUNET_free (sender_c); | 426 | GNUNET_free (sender_c); |
427 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, | 427 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (p1, |
428 | p2, | ||
428 | &testing_connect_cb, | 429 | &testing_connect_cb, |
429 | NULL); | 430 | NULL); |
430 | 431 | ||
@@ -441,12 +442,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
441 | s_connected = GNUNET_NO; | 442 | s_connected = GNUNET_NO; |
442 | s_sending = GNUNET_NO; | 443 | s_sending = GNUNET_NO; |
443 | 444 | ||
444 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p1, 1, | 445 | p1 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
446 | cfg_file_p1, 1, | ||
445 | ¬ify_receive, ¬ify_connect, | 447 | ¬ify_receive, ¬ify_connect, |
446 | ¬ify_disconnect, &start_cb, | 448 | ¬ify_disconnect, &start_cb, |
447 | NULL); | 449 | NULL); |
448 | 450 | ||
449 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, cfg_file_p2, 2, | 451 | p2 = GNUNET_TRANSPORT_TESTING_start_peer (tth, |
452 | cfg_file_p2, 2, | ||
450 | ¬ify_receive, ¬ify_connect, | 453 | ¬ify_receive, ¬ify_connect, |
451 | ¬ify_disconnect, &start_cb, | 454 | ¬ify_disconnect, &start_cb, |
452 | NULL); | 455 | NULL); |
@@ -488,18 +491,18 @@ main (int argc, char *argv[]) | |||
488 | { | 491 | { |
489 | int ret; | 492 | int ret; |
490 | 493 | ||
491 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | 494 | test_name = GNUNET_TRANSPORT_TESTING_get_test_name (argv[0]); |
492 | GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); | 495 | test_source = GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__); |
493 | GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, | 496 | test_plugin = GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], |
494 | &test_plugin); | 497 | test_source); |
495 | 498 | ||
496 | GNUNET_log_setup (test_name, | 499 | GNUNET_log_setup (test_name, |
497 | "WARNING", | 500 | "WARNING", |
498 | NULL); | 501 | NULL); |
499 | tth = GNUNET_TRANSPORT_TESTING_init (); | 502 | tth = GNUNET_TRANSPORT_TESTING_init (); |
500 | 503 | ||
501 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); | 504 | cfg_file_p1 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 1); |
502 | GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); | 505 | cfg_file_p2 = GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], 2); |
503 | 506 | ||
504 | ret = check (); | 507 | ret = check (); |
505 | 508 | ||