2 This file is part of GNUnet.
3 Copyright (C) 2011, 2017 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
16 * @file cadet/test_cadet.c
18 * @author Christian Grothoff
19 * @brief Test for the cadet service using mq API.
23 #include "cadet_test_lib.h"
24 #include "gnunet_cadet_service.h"
25 #include "gnunet_statistics_service.h"
30 * Ugly workaround to unify data handlers on incoming and outgoing channels.
32 struct CadetTestChannelWrapper
37 struct GNUNET_CADET_Channel *ch;
41 * How many messages to send by default.
43 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
46 * How long until we give up on connecting the peers?
48 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
51 * Time to wait by default for stuff that should be rather fast.
53 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
56 * How fast do we send messages?
58 #define SEND_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10)
61 * DIFFERENT TESTS TO RUN
72 * Which test are we running?
77 * String with test name
79 static char *test_name;
82 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
84 static int test_backwards = GNUNET_NO;
87 * How many packets to send.
89 static unsigned int total_packets;
92 * Time to wait for fast operations.
94 static struct GNUNET_TIME_Relative short_time;
97 * How many events have happened
102 * Number of events expected to conclude the test successfully.
107 * Size of each test packet's payload
109 static size_t size_payload = sizeof (uint32_t);
112 * Operation to get peer ids.
114 static struct GNUNET_TESTBED_Operation *t_op[2];
119 static struct GNUNET_PeerIdentity *p_id[2];
124 static struct GNUNET_HashCode port;
129 static unsigned int p_ids;
132 * Is the setup initialized?
134 static int initialized;
137 * Number of payload packes sent.
139 static int data_sent;
142 * Number of payload packets received.
144 static int data_received;
147 * Number of payload packed acknowledgements sent.
152 * Number of payload packed explicitly (app level) acknowledged.
154 static int ack_received;
157 * Total number of peers asked to run.
159 static unsigned long long peers_requested;
162 * Number of currently running peers (should be same as @c peers_requested).
164 static unsigned long long peers_running;
167 * Test context (to shut down).
169 struct GNUNET_CADET_TEST_Context *test_ctx;
172 * Task called to disconnect peers.
174 static struct GNUNET_SCHEDULER_Task *disconnect_task;
177 * Task To perform tests
179 static struct GNUNET_SCHEDULER_Task *test_task;
182 * Task runnining #send_next_msg().
184 static struct GNUNET_SCHEDULER_Task *send_next_msg_task;
187 * Cadet handle for the root peer
189 static struct GNUNET_CADET_Handle *h1;
192 * Cadet handle for the first leaf peer
194 static struct GNUNET_CADET_Handle *h2;
197 * Channel handle for the root peer
199 static struct GNUNET_CADET_Channel *outgoing_ch;
202 * Channel handle for the dest peer
204 static struct GNUNET_CADET_Channel *incoming_ch;
207 * Time we started the data transmission (after channel has been established
210 static struct GNUNET_TIME_Absolute start_time;
215 static struct GNUNET_TESTBED_Peer **testbed_peers;
218 * Statistics operation handle.
220 static struct GNUNET_TESTBED_Operation *stats_op;
225 static unsigned int ka_sent;
228 * Keepalives received.
230 static unsigned int ka_received;
233 * How many messages were dropped by CADET because of full buffers?
235 static unsigned int msg_dropped;
238 /******************************************************************************/
241 /******************************************************************************/
245 * Get the channel considered as the "target" or "receiver", depending on
246 * the test type and size.
248 * @return Channel handle of the target client, either 0 (for backward tests)
249 * or the last peer in the line (for other tests).
251 static struct GNUNET_CADET_Channel *
252 get_target_channel ()
254 if (SPEED == test && GNUNET_YES == test_backwards)
262 * Show the results of the test (banwidth acheived) and log them to GAUGER
267 static struct GNUNET_TIME_Absolute end_time;
268 static struct GNUNET_TIME_Relative total_time;
270 end_time = GNUNET_TIME_absolute_get ();
271 total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
273 "\nResults of test \"%s\"\n",
277 GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
279 "Test bandwidth: %f kb/s\n",
280 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
282 "Test throughput: %f packets/s\n\n",
283 total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
286 total_packets * 1000.0 / (total_time.rel_value_us / 1000),
292 * Disconnect from cadet services af all peers, call shutdown.
294 * @param cls Closure (line number from which termination was requested).
295 * @param tc Task Context.
298 disconnect_cadet_peers (void *cls)
300 long line = (long) cls;
302 disconnect_task = NULL;
303 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
304 "disconnecting cadet service of peers, called from line %ld\n",
306 for (unsigned int i = 0; i < 2; i++)
308 GNUNET_TESTBED_operation_done (t_op[i]);
310 if (NULL != outgoing_ch)
312 GNUNET_CADET_channel_destroy (outgoing_ch);
315 if (NULL != incoming_ch)
317 GNUNET_CADET_channel_destroy (incoming_ch);
320 GNUNET_CADET_TEST_cleanup (test_ctx);
321 GNUNET_SCHEDULER_shutdown ();
326 * Shut down peergroup, clean up.
328 * @param cls Closure (unused).
329 * @param tc Task Context.
332 shutdown_task (void *cls)
334 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
336 if (NULL != send_next_msg_task)
338 GNUNET_SCHEDULER_cancel (send_next_msg_task);
339 send_next_msg_task = NULL;
341 if (NULL != test_task)
343 GNUNET_SCHEDULER_cancel (test_task);
346 if (NULL != disconnect_task)
348 GNUNET_SCHEDULER_cancel (disconnect_task);
350 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
357 * Stats callback. Finish the stats testbed operation and when all stats have
358 * been iterated, shutdown the test.
360 * @param cls Closure (line number from which termination was requested).
361 * @param op the operation that has been finished
362 * @param emsg error message in case the operation has failed; will be NULL if
363 * operation has executed successfully.
366 stats_cont (void *cls,
367 struct GNUNET_TESTBED_Operation *op,
370 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
371 "KA sent: %u, KA received: %u\n",
374 if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
379 GNUNET_TESTBED_operation_done (stats_op);
381 if (NULL != disconnect_task)
382 GNUNET_SCHEDULER_cancel (disconnect_task);
383 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
389 * Process statistic values.
391 * @param cls closure (line number, unused)
392 * @param peer the peer the statistic belong to
393 * @param subsystem name of subsystem that created the statistic
394 * @param name the name of the datum
395 * @param value the current value
396 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
397 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
400 stats_iterator (void *cls,
401 const struct GNUNET_TESTBED_Peer *peer,
402 const char *subsystem,
407 static const char *s_sent = "# keepalives sent";
408 static const char *s_recv = "# keepalives received";
409 static const char *rdrops = "# messages dropped due to full buffer";
410 static const char *cdrops = "# messages dropped due to slow client";
413 i = GNUNET_TESTBED_get_index (peer);
414 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n", i,
415 subsystem, name, (unsigned long long) value);
416 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
418 if (0 == strncmp (s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
420 if (0 == strncmp (rdrops, name, strlen (rdrops)))
421 msg_dropped += value;
422 if (0 == strncmp (cdrops, name, strlen (cdrops)))
423 msg_dropped += value;
430 * Task to gather all statistics.
432 * @param cls Closure (line from which the task was scheduled).
435 gather_stats_and_exit (void *cls)
439 disconnect_task = NULL;
440 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
441 "gathering statistics from line %ld\n",
443 if (NULL != outgoing_ch)
445 GNUNET_CADET_channel_destroy (outgoing_ch);
448 stats_op = GNUNET_TESTBED_get_statistics (peers_running,
459 * Abort test: schedule disconnect and shutdown immediately
461 * @param line Line in the code the abort is requested from (__LINE__).
464 abort_test (long line)
466 if (NULL != disconnect_task)
468 GNUNET_SCHEDULER_cancel (disconnect_task);
469 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
470 "Aborting test from %ld\n",
473 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
480 * Send a message on the channel with the appropriate size and payload.
482 * Update the appropriate *_sent counter.
484 * @param channel Channel to send the message on.
487 send_test_message (struct GNUNET_CADET_Channel *channel)
489 struct GNUNET_MQ_Envelope *env;
490 struct GNUNET_MessageHeader *msg;
495 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
496 "Sending test message on channel %p\n",
499 if (GNUNET_NO == initialized)
501 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n");
504 if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer
507 else if (SPEED == test || SPEED_ACK == test)
509 if (get_target_channel() == channel)
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
515 "Sending ACK %u [%d bytes]\n",
523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
524 "Sending DATA %u [%d bytes]\n",
528 else if (FORWARD == test)
532 else if (P2P_SIGNAL == test)
540 env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY);
542 data = (uint32_t *) &msg[1];
543 *data = htonl (payload);
544 GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env);
549 * Task to request a new data transmission in a SPEED test, without waiting
550 * for previous messages to be sent/arrrive.
552 * @param cls Closure (unused).
555 send_next_msg (void *cls)
557 struct GNUNET_CADET_Channel *channel;
559 send_next_msg_task = NULL;
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "Sending next message: %d\n",
564 channel = GNUNET_YES == test_backwards ? incoming_ch : outgoing_ch;
565 GNUNET_assert (NULL != channel);
566 GNUNET_assert (SPEED == test);
567 send_test_message (channel);
568 if (data_sent < total_packets)
570 /* SPEED test: Send all messages as soon as possible */
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Scheduling message %d\n",
575 GNUNET_SCHEDULER_add_delayed (SEND_INTERVAL,
583 * Every few messages cancel the timeout task and re-schedule it again, to
584 * avoid timing out when traffic keeps coming.
586 * @param line Code line number to log if a timeout occurs.
589 reschedule_timeout_task (long line)
593 if (NULL != disconnect_task)
595 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
596 "reschedule timeout every 10 messages\n");
597 GNUNET_SCHEDULER_cancel (disconnect_task);
598 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
599 &gather_stats_and_exit,
607 * Check if payload is sane (size contains payload).
609 * @param cls should match #ch
610 * @param message The actual message.
611 * @return #GNUNET_OK to keep the channel open,
612 * #GNUNET_SYSERR to close it (signal serious error).
615 check_data (void *cls,
616 const struct GNUNET_MessageHeader *message)
618 return GNUNET_OK; /* all is well-formed */
623 * Function is called whenever a message is received.
625 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
626 * @param message the actual message
629 handle_data (void *cls,
630 const struct GNUNET_MessageHeader *message)
632 struct CadetTestChannelWrapper *ch = cls;
633 struct GNUNET_CADET_Channel *channel = ch->ch;
639 GNUNET_CADET_receive_done (channel);
640 counter = get_target_channel () == channel ? &data_received : &ack_received;
642 reschedule_timeout_task ((long) __LINE__);
644 if (channel == outgoing_ch)
646 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
647 "Root client got a message.\n");
649 else if (channel == incoming_ch)
651 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
652 "Leaf client got a message.\n");
656 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
657 "Unknown channel %p.\n",
662 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
666 data = (uint32_t *) &message[1];
667 payload = ntohl (*data);
668 if (payload == *counter)
670 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
671 " payload as expected: %u\n",
676 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
677 " payload %u, expected: %u\n",
681 if (GNUNET_NO == initialized)
683 initialized = GNUNET_YES;
684 start_time = GNUNET_TIME_absolute_get ();
687 GNUNET_assert (incoming_ch == channel);
688 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg,
695 if (get_target_channel () == channel) /* Got "data" */
697 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
698 if (SPEED != test || (ok_goal - 2) == ok)
701 send_test_message (channel);
706 if (data_received < total_packets)
712 if (SPEED_ACK == test || SPEED == test)
714 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
716 send_test_message (channel);
717 if (ack_received < total_packets && SPEED != test)
719 if (ok == 2 && SPEED == test)
723 if (test == P2P_SIGNAL)
725 GNUNET_CADET_channel_destroy (incoming_ch);
730 GNUNET_CADET_channel_destroy (outgoing_ch);
738 * Method called whenever a peer connects to a port in MQ-based CADET.
740 * @param cls Closure from #GNUNET_CADET_open_port (peer # as long).
741 * @param channel New handle to the channel.
742 * @param source Peer that started this channel.
743 * @return Closure for the incoming @a channel. It's given to:
744 * - The #GNUNET_CADET_DisconnectEventHandler (given to
745 * #GNUNET_CADET_open_port) when the channel dies.
746 * - Each the #GNUNET_MQ_MessageCallback handlers for each message
747 * received on the @a channel.
750 connect_handler (void *cls,
751 struct GNUNET_CADET_Channel *channel,
752 const struct GNUNET_PeerIdentity *source)
754 struct CadetTestChannelWrapper *ch;
755 long peer = (long) cls;
757 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
758 "Incoming channel from %s to %ld: %p\n",
763 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
766 if (peer == peers_requested - 1)
768 if (NULL != incoming_ch)
770 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
771 "Duplicate incoming channel for client %lu\n",
775 incoming_ch = channel;
779 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
780 "Incoming channel for unexpected peer #%lu\n",
784 if (NULL != disconnect_task)
786 GNUNET_SCHEDULER_cancel (disconnect_task);
787 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
788 &gather_stats_and_exit,
792 /* TODO: cannot return channel as-is, in order to unify the data handlers */
793 ch = GNUNET_new (struct CadetTestChannelWrapper);
801 * Function called whenever an MQ-channel is destroyed, even if the destruction
802 * was requested by #GNUNET_CADET_channel_destroy.
803 * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
805 * It should clean up any associated state, including cancelling any pending
806 * transmission on this channel.
808 * @param cls Channel closure (channel wrapper).
809 * @param channel Connection to the other end (henceforth invalid).
812 disconnect_handler (void *cls,
813 const struct GNUNET_CADET_Channel *channel)
815 struct CadetTestChannelWrapper *ch_w = cls;
817 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
818 "Channel disconnected at %d\n",
820 GNUNET_assert (ch_w->ch == channel);
821 if (channel == incoming_ch)
826 else if (outgoing_ch == channel)
828 if (P2P_SIGNAL == test)
835 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
836 "Unknown channel! %p\n",
838 if (NULL != disconnect_task)
840 GNUNET_SCHEDULER_cancel (disconnect_task);
842 GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
850 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
852 * Testcase continues when the root receives confirmation of connected peers,
853 * on callback function ch.
855 * @param cls Closure (unused).
858 start_test (void *cls)
860 struct GNUNET_MQ_MessageHandler handlers[] = {
861 GNUNET_MQ_hd_var_size (data,
862 GNUNET_MESSAGE_TYPE_DUMMY,
863 struct GNUNET_MessageHeader,
865 GNUNET_MQ_handler_end ()
867 struct CadetTestChannelWrapper *ch;
868 enum GNUNET_CADET_ChannelOption flags;
871 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
872 if (NULL != disconnect_task)
874 GNUNET_SCHEDULER_cancel (disconnect_task);
875 disconnect_task = NULL;
878 flags = GNUNET_CADET_OPTION_DEFAULT;
879 if (SPEED_REL == test)
882 flags |= GNUNET_CADET_OPTION_RELIABLE;
885 ch = GNUNET_new (struct CadetTestChannelWrapper);
886 outgoing_ch = GNUNET_CADET_channel_create (h1,
895 ch->ch = outgoing_ch;
897 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
898 &gather_stats_and_exit,
900 if (KEEPALIVE == test)
901 return; /* Don't send any data. */
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
909 "Sending data initializer on channel %p...\n",
911 send_test_message (outgoing_ch);
916 * Callback to be called when the requested peer information is available
918 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
919 * @param op the operation this callback corresponds to
920 * @param pinfo the result; will be NULL if the operation has failed
921 * @param emsg error message if the operation has failed;
922 * NULL if the operation is successfull
926 struct GNUNET_TESTBED_Operation *op,
927 const struct GNUNET_TESTBED_PeerInformation *pinfo,
932 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
933 "ID callback for %ld\n",
935 if ( (NULL == pinfo) ||
938 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
941 abort_test (__LINE__);
944 p_id[i] = pinfo->result.id;
945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
947 GNUNET_i2s (p_id[i]));
951 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
952 "Got all IDs, starting test\n");
953 test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
958 * test main: start test when all peers are connected
960 * @param cls Closure.
961 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
962 * @param num_peers Number of peers that are running.
963 * @param peers Array of peers.
964 * @param cadets Handle to each of the CADETs of the peers.
968 struct GNUNET_CADET_TEST_Context *ctx,
969 unsigned int num_peers,
970 struct GNUNET_TESTBED_Peer **peers,
971 struct GNUNET_CADET_Handle **cadets)
973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
976 peers_running = num_peers;
977 GNUNET_assert (peers_running == peers_requested);
978 testbed_peers = peers;
980 h2 = cadets[num_peers - 1];
981 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
982 &disconnect_cadet_peers,
984 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
986 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
987 GNUNET_TESTBED_PIT_IDENTITY,
990 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
991 GNUNET_TESTBED_PIT_IDENTITY,
994 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1002 main (int argc, char *argv[])
1004 static const struct GNUNET_HashCode *ports[2];
1005 struct GNUNET_MQ_MessageHandler handlers[] = {
1006 GNUNET_MQ_hd_var_size (data,
1007 GNUNET_MESSAGE_TYPE_DUMMY,
1008 struct GNUNET_MessageHeader,
1010 GNUNET_MQ_handler_end ()
1012 const char *config_file;
1013 char port_id[] = "test port";
1014 struct GNUNET_GETOPT_CommandLineOption options[] = {
1015 GNUNET_GETOPT_option_relative_time ('t',
1018 gettext_noop ("set short timeout"),
1020 GNUNET_GETOPT_option_uint ('m',
1023 gettext_noop ("set number of messages to send"),
1026 GNUNET_GETOPT_OPTION_END
1030 initialized = GNUNET_NO;
1031 GNUNET_log_setup ("test", "DEBUG", NULL);
1033 total_packets = TOTAL_PACKETS;
1034 short_time = SHORT_TIME;
1035 if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
1037 FPRINTF (stderr, "test failed: problem with CLI parameters\n");
1041 config_file = "test_cadet.conf";
1042 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1044 /* Find out requested size */
1045 if (strstr (argv[0], "_2_") != NULL)
1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1048 peers_requested = 2;
1050 else if (strstr (argv[0], "_5_") != NULL)
1052 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1053 peers_requested = 5;
1057 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1058 peers_requested = 2;
1061 /* Find out requested test */
1062 if (strstr (argv[0], "_forward") != NULL)
1064 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1066 test_name = "unicast";
1069 else if (strstr (argv[0], "_signal") != NULL)
1071 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1073 test_name = "signal";
1076 else if (strstr (argv[0], "_speed_ack") != NULL)
1078 /* Test is supposed to generate the following callbacks:
1079 * 1 incoming channel (@dest)
1080 * total_packets received data packet (@dest)
1081 * total_packets received data packet (@orig)
1082 * 1 received channel destroy (@dest)
1084 ok_goal = total_packets * 2 + 2;
1085 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1087 test_name = "speed ack";
1089 else if (strstr (argv[0], "_speed") != NULL)
1091 /* Test is supposed to generate the following callbacks:
1092 * 1 incoming channel (@dest)
1093 * 1 initial packet (@dest)
1094 * total_packets received data packet (@dest)
1095 * 1 received data packet (@orig)
1096 * 1 received channel destroy (@dest)
1098 ok_goal = total_packets + 4;
1099 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1100 if (strstr (argv[0], "_reliable") != NULL)
1103 test_name = "speed reliable";
1104 config_file = "test_cadet_drop.conf";
1109 test_name = "speed";
1112 else if (strstr (argv[0], "_keepalive") != NULL)
1115 /* Test is supposed to generate the following callbacks:
1116 * 1 incoming channel (@dest)
1118 * 1 received channel destroy (@dest)
1124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1129 if (strstr (argv[0], "backwards") != NULL)
1131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1132 test_backwards = GNUNET_YES;
1133 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1139 GNUNET_CADET_TEST_ruN ("test_cadet_small",
1143 NULL, /* tmain cls */
1146 &disconnect_handler,
1149 if (NULL != strstr (argv[0], "_reliable"))
1150 msg_dropped = 0; /* dropped should be retransmitted */
1152 if (ok_goal > ok - msg_dropped)
1154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
1157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1161 /* end of test_cadet.c */