diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-22 22:52:08 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-22 22:52:08 +0900 |
commit | 5402016fcb271bbfa9c9470bd281d73b72e75bca (patch) | |
tree | 7b6ea446c5e537b0484070ae022ddde2aad3e5dd /src/transport | |
parent | 61a8f2c46ddd10d86e568dd8fe2f533ae31a6c81 (diff) | |
download | gnunet-5402016fcb271bbfa9c9470bd281d73b72e75bca.tar.gz gnunet-5402016fcb271bbfa9c9470bd281d73b72e75bca.zip |
basic tests
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/Makefile.am | 8 | ||||
-rw-r--r-- | src/transport/test_communicator_basic.c (renamed from src/transport/test_communicator.c) | 58 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 35 |
3 files changed, 67 insertions, 34 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index ff9d7aec7..5d0ba2218 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -588,7 +588,7 @@ check_PROGRAMS += \ | |||
588 | test_transport_api_slow_ats | 588 | test_transport_api_slow_ats |
589 | endif | 589 | endif |
590 | check_PROGRAMS += \ | 590 | check_PROGRAMS += \ |
591 | test_communicator_unix | 591 | test_communicator_basic_unix |
592 | if HAVE_EXPERIMENTAL | 592 | if HAVE_EXPERIMENTAL |
593 | check_PROGRAMS += \ | 593 | check_PROGRAMS += \ |
594 | test_transport_address_switch_udp \ | 594 | test_transport_address_switch_udp \ |
@@ -782,9 +782,9 @@ test_plugin_udp_LDADD = \ | |||
782 | libgnunettransporttesting.la | 782 | libgnunettransporttesting.la |
783 | endif | 783 | endif |
784 | 784 | ||
785 | test_communicator_unix_SOURCES = \ | 785 | test_communicator_basic_unix_SOURCES = \ |
786 | test_communicator.c | 786 | test_communicator_basic.c |
787 | test_communicator_unix_LDADD = \ | 787 | test_communicator_basic_unix_LDADD = \ |
788 | libgnunettransporttesting2.la \ | 788 | libgnunettransporttesting2.la \ |
789 | $(top_builddir)/src/testing/libgnunettesting.la \ | 789 | $(top_builddir)/src/testing/libgnunettesting.la \ |
790 | $(top_builddir)/src/util/libgnunetutil.la | 790 | $(top_builddir)/src/util/libgnunetutil.la |
diff --git a/src/transport/test_communicator.c b/src/transport/test_communicator_basic.c index d77128b09..ef18d6a81 100644 --- a/src/transport/test_communicator.c +++ b/src/transport/test_communicator_basic.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file transport/test_communicator.c | 22 | * @file transport/test_communicator_basic.c |
23 | * @brief test the communicators | 23 | * @brief test the communicators |
24 | * @author Julius Bünger | 24 | * @author Julius Bünger |
25 | * @author Martin Schanzenbach | 25 | * @author Martin Schanzenbach |
@@ -80,6 +80,10 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc; | |||
80 | 80 | ||
81 | #define SIZE_CHECK 2 | 81 | #define SIZE_CHECK 2 |
82 | 82 | ||
83 | #define MAX_BUF_LEN 10 | ||
84 | |||
85 | static int buf_len = 0; | ||
86 | |||
83 | static char short_payload[SHORT_MESSAGE_SIZE]; | 87 | static char short_payload[SHORT_MESSAGE_SIZE]; |
84 | 88 | ||
85 | static char long_payload[LONG_MESSAGE_SIZE]; | 89 | static char long_payload[LONG_MESSAGE_SIZE]; |
@@ -163,19 +167,18 @@ static void | |||
163 | size_test (void *cls) | 167 | size_test (void *cls) |
164 | { | 168 | { |
165 | char payload[ack]; | 169 | char payload[ack]; |
170 | phase = SIZE_CHECK; | ||
166 | 171 | ||
167 | memset (payload, 0, ack); | 172 | memset (payload, 0, ack); |
168 | if (ack < UINT16_MAX) | 173 | if (ack < 64000) //Leave some room for our protocol. |
169 | { | 174 | { |
170 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 175 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
171 | &payload, | 176 | &payload, |
172 | sizeof(payload)); | 177 | sizeof(payload)); |
173 | return; | 178 | return; |
174 | } | 179 | } |
175 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
176 | "LONG Goodput (bytes/s): %lu\n", | 181 | "Finished\n"); |
177 | (LONG_MESSAGE_SIZE * long_received) / LONG_BURST_SECONDS); | ||
178 | ret = 0; | ||
179 | GNUNET_SCHEDULER_shutdown (); | 182 | GNUNET_SCHEDULER_shutdown (); |
180 | // Finished! | 183 | // Finished! |
181 | } | 184 | } |
@@ -188,15 +191,22 @@ long_test (void *cls) | |||
188 | start_long); | 191 | start_long); |
189 | if (LONG_BURST_WINDOW.rel_value_us > duration.rel_value_us) | 192 | if (LONG_BURST_WINDOW.rel_value_us > duration.rel_value_us) |
190 | { | 193 | { |
191 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 194 | if (buf_len < MAX_BUF_LEN) |
192 | &long_payload, | 195 | { |
193 | sizeof(long_payload)); | 196 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
197 | &long_payload, | ||
198 | sizeof(long_payload)); | ||
199 | buf_len++; | ||
200 | } | ||
194 | GNUNET_SCHEDULER_add_now (&long_test, NULL); | 201 | GNUNET_SCHEDULER_add_now (&long_test, NULL); |
195 | return; | 202 | return; |
196 | } | 203 | } |
197 | phase = SIZE_CHECK; | 204 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
205 | "LONG Goodput (bytes/s): %lu - received packets: %lu\n", | ||
206 | (LONG_MESSAGE_SIZE * long_received) / LONG_BURST_SECONDS, | ||
207 | long_received); | ||
198 | ack = 5; | 208 | ack = 5; |
199 | GNUNET_SCHEDULER_add_now (&size_test, NULL); | 209 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &size_test, NULL); |
200 | } | 210 | } |
201 | 211 | ||
202 | 212 | ||
@@ -207,10 +217,13 @@ short_test (void *cls) | |||
207 | start_short); | 217 | start_short); |
208 | if (SHORT_BURST_WINDOW.rel_value_us > duration.rel_value_us) | 218 | if (SHORT_BURST_WINDOW.rel_value_us > duration.rel_value_us) |
209 | { | 219 | { |
210 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, | 220 | if (buf_len < MAX_BUF_LEN) |
211 | &short_payload, | 221 | { |
212 | sizeof(short_payload)); | 222 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (my_tc, |
213 | 223 | &short_payload, | |
224 | sizeof(short_payload)); | ||
225 | buf_len++; | ||
226 | } | ||
214 | GNUNET_SCHEDULER_add_now (&short_test, NULL); | 227 | GNUNET_SCHEDULER_add_now (&short_test, NULL); |
215 | return; | 228 | return; |
216 | } | 229 | } |
@@ -222,6 +235,7 @@ short_test (void *cls) | |||
222 | short_received); | 235 | short_received); |
223 | start_long = GNUNET_TIME_absolute_get (); | 236 | start_long = GNUNET_TIME_absolute_get (); |
224 | phase = BURST_LONG; | 237 | phase = BURST_LONG; |
238 | buf_len = 0; | ||
225 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &long_test, NULL); | 239 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &long_test, NULL); |
226 | } | 240 | } |
227 | 241 | ||
@@ -249,6 +263,7 @@ add_queue_cb (void *cls, | |||
249 | "Queue established, starting test...\n"); | 263 | "Queue established, starting test...\n"); |
250 | start_short = GNUNET_TIME_absolute_get (); | 264 | start_short = GNUNET_TIME_absolute_get (); |
251 | my_tc = tc_queue; | 265 | my_tc = tc_queue; |
266 | buf_len = 0; | ||
252 | phase = BURST_SHORT; | 267 | phase = BURST_SHORT; |
253 | GNUNET_SCHEDULER_add_now (&short_test, tc_queue); | 268 | GNUNET_SCHEDULER_add_now (&short_test, tc_queue); |
254 | } | 269 | } |
@@ -270,23 +285,25 @@ incoming_message_cb (void *cls, | |||
270 | const char*payload, | 285 | const char*payload, |
271 | size_t payload_len) | 286 | size_t payload_len) |
272 | { | 287 | { |
273 | //GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
274 | // "Receiving payload with size %lu...\n", payload_len); | ||
275 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) | 288 | if (0 != strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) |
276 | return; // TODO? | 289 | return; // TODO? |
277 | if (phase == BURST_SHORT) | 290 | if (phase == BURST_SHORT) |
278 | { | 291 | { |
279 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); | 292 | GNUNET_assert (SHORT_MESSAGE_SIZE == payload_len); |
280 | short_received++; | 293 | short_received++; |
294 | buf_len--; | ||
281 | } | 295 | } |
282 | else if (phase == BURST_LONG) | 296 | else if (phase == BURST_LONG) |
283 | { | 297 | { |
284 | if (LONG_MESSAGE_SIZE != payload_len) | 298 | if (LONG_MESSAGE_SIZE != payload_len) |
285 | return; //Ignore | 299 | return; // Ignore |
286 | long_received++; | 300 | long_received++; |
301 | buf_len--; | ||
287 | } | 302 | } |
288 | else // if (phase == SIZE_CHECK) { | 303 | else // if (phase == SIZE_CHECK) { |
289 | { | 304 | { |
305 | // GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
306 | // "Receiving payload with size %lu...\n", payload_len); | ||
290 | if (ack != payload_len) | 307 | if (ack != payload_len) |
291 | { | 308 | { |
292 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -309,6 +326,7 @@ incoming_message_cb (void *cls, | |||
309 | static void | 326 | static void |
310 | run (void *cls) | 327 | run (void *cls) |
311 | { | 328 | { |
329 | ret = 0; | ||
312 | memset (long_payload, 0, LONG_MESSAGE_SIZE); | 330 | memset (long_payload, 0, LONG_MESSAGE_SIZE); |
313 | memset (short_payload, 0, SHORT_MESSAGE_SIZE); | 331 | memset (short_payload, 0, SHORT_MESSAGE_SIZE); |
314 | for (int i = 0; i < NUM_PEERS; i++) | 332 | for (int i = 0; i < NUM_PEERS; i++) |
@@ -340,9 +358,9 @@ main (int argc, | |||
340 | GNUNET_asprintf (&communicator_binary, "gnunet-communicator-%s", | 358 | GNUNET_asprintf (&communicator_binary, "gnunet-communicator-%s", |
341 | communicator_name); | 359 | communicator_name); |
342 | cfg_peers_name = GNUNET_malloc (sizeof(char*) * NUM_PEERS); | 360 | cfg_peers_name = GNUNET_malloc (sizeof(char*) * NUM_PEERS); |
343 | if (GNUNET_OK != GNUNET_log_setup ("test_communicator", | 361 | if (GNUNET_OK != GNUNET_log_setup ("test_communicator_basic", |
344 | "DEBUG", | 362 | "DEBUG", |
345 | "test_communicator.log")) | 363 | "test_communicator_basic.log")) |
346 | { | 364 | { |
347 | fprintf (stderr, "Unable to setup log\n"); | 365 | fprintf (stderr, "Unable to setup log\n"); |
348 | GNUNET_break (0); | 366 | GNUNET_break (0); |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 230c35b4f..547f8611b 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -280,8 +280,6 @@ static int | |||
280 | check_add_address (void *cls, | 280 | check_add_address (void *cls, |
281 | const struct GNUNET_TRANSPORT_AddAddressMessage *msg) | 281 | const struct GNUNET_TRANSPORT_AddAddressMessage *msg) |
282 | { | 282 | { |
283 | struct TransportClient *tc = cls; | ||
284 | |||
285 | // if (CT_COMMUNICATOR != tc->type) | 283 | // if (CT_COMMUNICATOR != tc->type) |
286 | // { | 284 | // { |
287 | // GNUNET_break (0); | 285 | // GNUNET_break (0); |
@@ -568,6 +566,22 @@ disconnect_cb (void *cls, | |||
568 | tc_h->client = NULL; | 566 | tc_h->client = NULL; |
569 | } | 567 | } |
570 | 568 | ||
569 | /** | ||
570 | * Message was transmitted. Process the request. | ||
571 | * | ||
572 | * @param cls the client | ||
573 | * @param sma the send message that was sent | ||
574 | */ | ||
575 | static void | ||
576 | handle_send_message_ack (void *cls, | ||
577 | const struct GNUNET_TRANSPORT_SendMessageToAck *sma) | ||
578 | { | ||
579 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
580 | GNUNET_SERVICE_client_continue (tc_h->client); | ||
581 | //NOP | ||
582 | } | ||
583 | |||
584 | |||
571 | 585 | ||
572 | /** | 586 | /** |
573 | * @brief Start the communicator part of the transport service | 587 | * @brief Start the communicator part of the transport service |
@@ -584,7 +598,7 @@ transport_communicator_start ( | |||
584 | GNUNET_MQ_hd_var_size (communicator_available, | 598 | GNUNET_MQ_hd_var_size (communicator_available, |
585 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, | 599 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, |
586 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, | 600 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, |
587 | &tc_h), | 601 | tc_h), |
588 | // GNUNET_MQ_hd_var_size (communicator_backchannel, | 602 | // GNUNET_MQ_hd_var_size (communicator_backchannel, |
589 | // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, | 603 | // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, |
590 | // struct GNUNET_TRANSPORT_CommunicatorBackchannel, | 604 | // struct GNUNET_TRANSPORT_CommunicatorBackchannel, |
@@ -592,7 +606,7 @@ transport_communicator_start ( | |||
592 | GNUNET_MQ_hd_var_size (add_address, | 606 | GNUNET_MQ_hd_var_size (add_address, |
593 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, | 607 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, |
594 | struct GNUNET_TRANSPORT_AddAddressMessage, | 608 | struct GNUNET_TRANSPORT_AddAddressMessage, |
595 | &tc_h), | 609 | tc_h), |
596 | // GNUNET_MQ_hd_fixed_size (del_address, | 610 | // GNUNET_MQ_hd_fixed_size (del_address, |
597 | // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, | 611 | // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, |
598 | // struct GNUNET_TRANSPORT_DelAddressMessage, | 612 | // struct GNUNET_TRANSPORT_DelAddressMessage, |
@@ -600,7 +614,7 @@ transport_communicator_start ( | |||
600 | GNUNET_MQ_hd_var_size (incoming_msg, | 614 | GNUNET_MQ_hd_var_size (incoming_msg, |
601 | GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, | 615 | GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, |
602 | struct GNUNET_TRANSPORT_IncomingMessage, | 616 | struct GNUNET_TRANSPORT_IncomingMessage, |
603 | NULL), | 617 | tc_h), |
604 | GNUNET_MQ_hd_fixed_size (queue_create_ok, | 618 | GNUNET_MQ_hd_fixed_size (queue_create_ok, |
605 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, | 619 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, |
606 | struct GNUNET_TRANSPORT_CreateQueueResponse, | 620 | struct GNUNET_TRANSPORT_CreateQueueResponse, |
@@ -612,15 +626,16 @@ transport_communicator_start ( | |||
612 | GNUNET_MQ_hd_var_size (add_queue_message, | 626 | GNUNET_MQ_hd_var_size (add_queue_message, |
613 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, | 627 | GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP, |
614 | struct GNUNET_TRANSPORT_AddQueueMessage, | 628 | struct GNUNET_TRANSPORT_AddQueueMessage, |
615 | NULL), | 629 | tc_h), |
616 | // GNUNET_MQ_hd_fixed_size (del_queue_message, | 630 | // GNUNET_MQ_hd_fixed_size (del_queue_message, |
617 | // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, | 631 | // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN, |
618 | // struct GNUNET_TRANSPORT_DelQueueMessage, | 632 | // struct GNUNET_TRANSPORT_DelQueueMessage, |
619 | // NULL), | 633 | // NULL), |
620 | // GNUNET_MQ_hd_fixed_size (send_message_ack, | 634 | GNUNET_MQ_hd_fixed_size (send_message_ack, |
621 | // GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, | 635 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK, |
622 | // struct GNUNET_TRANSPORT_SendMessageToAck, | 636 | struct GNUNET_TRANSPORT_SendMessageToAck, |
623 | // NULL), | 637 | tc_h), |
638 | GNUNET_MQ_handler_end () | ||
624 | }; | 639 | }; |
625 | struct GNUNET_SERVICE_Handle *h; | 640 | struct GNUNET_SERVICE_Handle *h; |
626 | 641 | ||