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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file cadet/test_cadet.c
21 * @author Christian Grothoff
22 * @brief Test for the cadet service using mq API.
26 #include "cadet_test_lib.h"
27 #include "gnunet_cadet_service.h"
28 #include "gnunet_statistics_service.h"
33 * Ugly workaround to unify data handlers on incoming and outgoing channels.
35 struct CadetTestChannelWrapper
40 struct GNUNET_CADET_Channel *ch;
44 * How many messages to send by default.
46 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
49 * How long until we give up on connecting the peers?
51 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
54 * Time to wait by default for stuff that should be rather fast.
56 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
59 * How fast do we send messages?
61 #define SEND_INTERVAL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10)
64 * DIFFERENT TESTS TO RUN
75 * Which test are we running?
80 * String with test name
82 static char *test_name;
85 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
87 static int test_backwards = GNUNET_NO;
90 * How many packets to send.
92 static unsigned int total_packets;
95 * Time to wait for fast operations.
97 static struct GNUNET_TIME_Relative short_time;
100 * How many events have happened
105 * Number of events expected to conclude the test successfully.
110 * Size of each test packet's payload
112 static size_t size_payload = sizeof (uint32_t);
115 * Operation to get peer ids.
117 static struct GNUNET_TESTBED_Operation *t_op[2];
122 static struct GNUNET_PeerIdentity *p_id[2];
127 static struct GNUNET_HashCode port;
132 static unsigned int p_ids;
135 * Is the setup initialized?
137 static int initialized;
140 * Number of payload packes sent.
142 static int data_sent;
145 * Number of payload packets received.
147 static int data_received;
150 * Number of payload packed acknowledgements sent.
155 * Number of payload packed explicitly (app level) acknowledged.
157 static int ack_received;
160 * Total number of peers asked to run.
162 static unsigned long long peers_requested;
165 * Number of currently running peers (should be same as @c peers_requested).
167 static unsigned long long peers_running;
170 * Test context (to shut down).
172 struct GNUNET_CADET_TEST_Context *test_ctx;
175 * Task called to disconnect peers.
177 static struct GNUNET_SCHEDULER_Task *disconnect_task;
180 * Task To perform tests
182 static struct GNUNET_SCHEDULER_Task *test_task;
185 * Task runnining #send_next_msg().
187 static struct GNUNET_SCHEDULER_Task *send_next_msg_task;
190 * Cadet handle for the root peer
192 static struct GNUNET_CADET_Handle *h1;
195 * Cadet handle for the first leaf peer
197 static struct GNUNET_CADET_Handle *h2;
200 * Channel handle for the root peer
202 static struct GNUNET_CADET_Channel *outgoing_ch;
205 * Channel handle for the dest peer
207 static struct GNUNET_CADET_Channel *incoming_ch;
210 * Time we started the data transmission (after channel has been established
213 static struct GNUNET_TIME_Absolute start_time;
218 static struct GNUNET_TESTBED_Peer **testbed_peers;
221 * Statistics operation handle.
223 static struct GNUNET_TESTBED_Operation *stats_op;
228 static unsigned int ka_sent;
231 * Keepalives received.
233 static unsigned int ka_received;
236 * How many messages were dropped by CADET because of full buffers?
238 static unsigned int msg_dropped;
241 /******************************************************************************/
244 /******************************************************************************/
248 * Get the channel considered as the "target" or "receiver", depending on
249 * the test type and size.
251 * @return Channel handle of the target client, either 0 (for backward tests)
252 * or the last peer in the line (for other tests).
254 static struct GNUNET_CADET_Channel *
255 get_target_channel ()
257 if (SPEED == test && GNUNET_YES == test_backwards)
265 * Show the results of the test (banwidth acheived) and log them to GAUGER
270 static struct GNUNET_TIME_Absolute end_time;
271 static struct GNUNET_TIME_Relative total_time;
273 end_time = GNUNET_TIME_absolute_get ();
274 total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
276 "\nResults of test \"%s\"\n",
280 GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
282 "Test bandwidth: %f kb/s\n",
283 4 * total_packets * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
285 "Test throughput: %f packets/s\n\n",
286 total_packets * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
289 total_packets * 1000.0 / (total_time.rel_value_us / 1000),
295 * Disconnect from cadet services af all peers, call shutdown.
297 * @param cls Closure (line number from which termination was requested).
298 * @param tc Task Context.
301 disconnect_cadet_peers (void *cls)
303 long line = (long) cls;
305 disconnect_task = NULL;
306 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
307 "disconnecting cadet service of peers, called from line %ld\n",
309 for (unsigned int i = 0; i < 2; i++)
311 GNUNET_TESTBED_operation_done (t_op[i]);
313 if (NULL != outgoing_ch)
315 GNUNET_CADET_channel_destroy (outgoing_ch);
318 if (NULL != incoming_ch)
320 GNUNET_CADET_channel_destroy (incoming_ch);
323 GNUNET_CADET_TEST_cleanup (test_ctx);
324 GNUNET_SCHEDULER_shutdown ();
329 * Shut down peergroup, clean up.
331 * @param cls Closure (unused).
332 * @param tc Task Context.
335 shutdown_task (void *cls)
337 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
339 if (NULL != send_next_msg_task)
341 GNUNET_SCHEDULER_cancel (send_next_msg_task);
342 send_next_msg_task = NULL;
344 if (NULL != test_task)
346 GNUNET_SCHEDULER_cancel (test_task);
349 if (NULL != disconnect_task)
351 GNUNET_SCHEDULER_cancel (disconnect_task);
353 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
360 * Stats callback. Finish the stats testbed operation and when all stats have
361 * been iterated, shutdown the test.
363 * @param cls Closure (line number from which termination was requested).
364 * @param op the operation that has been finished
365 * @param emsg error message in case the operation has failed; will be NULL if
366 * operation has executed successfully.
369 stats_cont (void *cls,
370 struct GNUNET_TESTBED_Operation *op,
373 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
374 "KA sent: %u, KA received: %u\n",
377 if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
382 GNUNET_TESTBED_operation_done (stats_op);
384 if (NULL != disconnect_task)
385 GNUNET_SCHEDULER_cancel (disconnect_task);
386 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
392 * Process statistic values.
394 * @param cls closure (line number, unused)
395 * @param peer the peer the statistic belong to
396 * @param subsystem name of subsystem that created the statistic
397 * @param name the name of the datum
398 * @param value the current value
399 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
400 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
403 stats_iterator (void *cls,
404 const struct GNUNET_TESTBED_Peer *peer,
405 const char *subsystem,
410 static const char *s_sent = "# keepalives sent";
411 static const char *s_recv = "# keepalives received";
412 static const char *rdrops = "# messages dropped due to full buffer";
413 static const char *cdrops = "# messages dropped due to slow client";
416 i = GNUNET_TESTBED_get_index (peer);
417 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n", i,
418 subsystem, name, (unsigned long long) value);
419 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
421 if (0 == strncmp (s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
423 if (0 == strncmp (rdrops, name, strlen (rdrops)))
424 msg_dropped += value;
425 if (0 == strncmp (cdrops, name, strlen (cdrops)))
426 msg_dropped += value;
433 * Task to gather all statistics.
435 * @param cls Closure (line from which the task was scheduled).
438 gather_stats_and_exit (void *cls)
442 disconnect_task = NULL;
443 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
444 "gathering statistics from line %ld\n",
446 if (NULL != outgoing_ch)
448 GNUNET_CADET_channel_destroy (outgoing_ch);
451 stats_op = GNUNET_TESTBED_get_statistics (peers_running,
462 * Abort test: schedule disconnect and shutdown immediately
464 * @param line Line in the code the abort is requested from (__LINE__).
467 abort_test (long line)
469 if (NULL != disconnect_task)
471 GNUNET_SCHEDULER_cancel (disconnect_task);
472 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
473 "Aborting test from %ld\n",
476 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
483 * Send a message on the channel with the appropriate size and payload.
485 * Update the appropriate *_sent counter.
487 * @param channel Channel to send the message on.
490 send_test_message (struct GNUNET_CADET_Channel *channel)
492 struct GNUNET_MQ_Envelope *env;
493 struct GNUNET_MessageHeader *msg;
498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
499 "Sending test message on channel %p\n",
502 if (GNUNET_NO == initialized)
504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n");
507 if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer
510 else if (SPEED == test || SPEED_ACK == test)
512 if (get_target_channel() == channel)
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
518 "Sending ACK %u [%d bytes]\n",
526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
527 "Sending DATA %u [%d bytes]\n",
531 else if (FORWARD == test)
535 else if (P2P_SIGNAL == test)
543 env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY);
545 data = (uint32_t *) &msg[1];
546 *data = htonl (payload);
547 GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env);
552 * Task to request a new data transmission in a SPEED test, without waiting
553 * for previous messages to be sent/arrrive.
555 * @param cls Closure (unused).
558 send_next_msg (void *cls)
560 struct GNUNET_CADET_Channel *channel;
562 send_next_msg_task = NULL;
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
564 "Sending next message: %d\n",
567 channel = GNUNET_YES == test_backwards ? incoming_ch : outgoing_ch;
568 GNUNET_assert (NULL != channel);
569 GNUNET_assert (SPEED == test);
570 send_test_message (channel);
571 if (data_sent < total_packets)
573 /* SPEED test: Send all messages as soon as possible */
574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
575 "Scheduling message %d\n",
578 GNUNET_SCHEDULER_add_delayed (SEND_INTERVAL,
586 * Every few messages cancel the timeout task and re-schedule it again, to
587 * avoid timing out when traffic keeps coming.
589 * @param line Code line number to log if a timeout occurs.
592 reschedule_timeout_task (long line)
596 if (NULL != disconnect_task)
598 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
599 "reschedule timeout every 10 messages\n");
600 GNUNET_SCHEDULER_cancel (disconnect_task);
601 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
602 &gather_stats_and_exit,
610 * Check if payload is sane (size contains payload).
612 * @param cls should match #ch
613 * @param message The actual message.
614 * @return #GNUNET_OK to keep the channel open,
615 * #GNUNET_SYSERR to close it (signal serious error).
618 check_data (void *cls,
619 const struct GNUNET_MessageHeader *message)
621 return GNUNET_OK; /* all is well-formed */
626 * Function is called whenever a message is received.
628 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
629 * @param message the actual message
632 handle_data (void *cls,
633 const struct GNUNET_MessageHeader *message)
635 struct CadetTestChannelWrapper *ch = cls;
636 struct GNUNET_CADET_Channel *channel = ch->ch;
642 GNUNET_CADET_receive_done (channel);
643 counter = get_target_channel () == channel ? &data_received : &ack_received;
645 reschedule_timeout_task ((long) __LINE__);
647 if (channel == outgoing_ch)
649 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
650 "Root client got a message.\n");
652 else if (channel == incoming_ch)
654 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
655 "Leaf client got a message.\n");
659 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
660 "Unknown channel %p.\n",
665 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
669 data = (uint32_t *) &message[1];
670 payload = ntohl (*data);
671 if (payload == *counter)
673 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
674 " payload as expected: %u\n",
679 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
680 " payload %u, expected: %u\n",
684 if (GNUNET_NO == initialized)
686 initialized = GNUNET_YES;
687 start_time = GNUNET_TIME_absolute_get ();
690 GNUNET_assert (incoming_ch == channel);
691 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg,
698 if (get_target_channel () == channel) /* Got "data" */
700 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
701 if (SPEED != test || (ok_goal - 2) == ok)
704 send_test_message (channel);
709 if (data_received < total_packets)
715 if (SPEED_ACK == test || SPEED == test)
717 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
719 send_test_message (channel);
720 if (ack_received < total_packets && SPEED != test)
722 if (ok == 2 && SPEED == test)
726 if (test == P2P_SIGNAL)
728 GNUNET_CADET_channel_destroy (incoming_ch);
733 GNUNET_CADET_channel_destroy (outgoing_ch);
741 * Method called whenever a peer connects to a port in MQ-based CADET.
743 * @param cls Closure from #GNUNET_CADET_open_port (peer # as long).
744 * @param channel New handle to the channel.
745 * @param source Peer that started this channel.
746 * @return Closure for the incoming @a channel. It's given to:
747 * - The #GNUNET_CADET_DisconnectEventHandler (given to
748 * #GNUNET_CADET_open_port) when the channel dies.
749 * - Each the #GNUNET_MQ_MessageCallback handlers for each message
750 * received on the @a channel.
753 connect_handler (void *cls,
754 struct GNUNET_CADET_Channel *channel,
755 const struct GNUNET_PeerIdentity *source)
757 struct CadetTestChannelWrapper *ch;
758 long peer = (long) cls;
760 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
761 "Incoming channel from %s to %ld: %p\n",
766 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
769 if (peer == peers_requested - 1)
771 if (NULL != incoming_ch)
773 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
774 "Duplicate incoming channel for client %lu\n",
778 incoming_ch = channel;
782 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
783 "Incoming channel for unexpected peer #%lu\n",
787 if (NULL != disconnect_task)
789 GNUNET_SCHEDULER_cancel (disconnect_task);
790 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
791 &gather_stats_and_exit,
795 /* TODO: cannot return channel as-is, in order to unify the data handlers */
796 ch = GNUNET_new (struct CadetTestChannelWrapper);
804 * Function called whenever an MQ-channel is destroyed, even if the destruction
805 * was requested by #GNUNET_CADET_channel_destroy.
806 * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
808 * It should clean up any associated state, including cancelling any pending
809 * transmission on this channel.
811 * @param cls Channel closure (channel wrapper).
812 * @param channel Connection to the other end (henceforth invalid).
815 disconnect_handler (void *cls,
816 const struct GNUNET_CADET_Channel *channel)
818 struct CadetTestChannelWrapper *ch_w = cls;
820 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
821 "Channel disconnected at %d\n",
823 GNUNET_assert (ch_w->ch == channel);
824 if (channel == incoming_ch)
829 else if (outgoing_ch == channel)
831 if (P2P_SIGNAL == test)
838 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
839 "Unknown channel! %p\n",
841 if (NULL != disconnect_task)
843 GNUNET_SCHEDULER_cancel (disconnect_task);
845 GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
853 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
855 * Testcase continues when the root receives confirmation of connected peers,
856 * on callback function ch.
858 * @param cls Closure (unused).
861 start_test (void *cls)
863 struct GNUNET_MQ_MessageHandler handlers[] = {
864 GNUNET_MQ_hd_var_size (data,
865 GNUNET_MESSAGE_TYPE_DUMMY,
866 struct GNUNET_MessageHeader,
868 GNUNET_MQ_handler_end ()
870 struct CadetTestChannelWrapper *ch;
871 enum GNUNET_CADET_ChannelOption flags;
874 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
875 if (NULL != disconnect_task)
877 GNUNET_SCHEDULER_cancel (disconnect_task);
878 disconnect_task = NULL;
881 flags = GNUNET_CADET_OPTION_DEFAULT;
882 if (SPEED_REL == test)
885 flags |= GNUNET_CADET_OPTION_RELIABLE;
888 ch = GNUNET_new (struct CadetTestChannelWrapper);
889 outgoing_ch = GNUNET_CADET_channel_create (h1,
898 ch->ch = outgoing_ch;
900 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
901 &gather_stats_and_exit,
903 if (KEEPALIVE == test)
904 return; /* Don't send any data. */
911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
912 "Sending data initializer on channel %p...\n",
914 send_test_message (outgoing_ch);
919 * Callback to be called when the requested peer information is available
921 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
922 * @param op the operation this callback corresponds to
923 * @param pinfo the result; will be NULL if the operation has failed
924 * @param emsg error message if the operation has failed;
925 * NULL if the operation is successfull
929 struct GNUNET_TESTBED_Operation *op,
930 const struct GNUNET_TESTBED_PeerInformation *pinfo,
935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
936 "ID callback for %ld\n",
938 if ( (NULL == pinfo) ||
941 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
944 abort_test (__LINE__);
947 p_id[i] = pinfo->result.id;
948 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
950 GNUNET_i2s (p_id[i]));
954 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
955 "Got all IDs, starting test\n");
956 test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
961 * test main: start test when all peers are connected
963 * @param cls Closure.
964 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
965 * @param num_peers Number of peers that are running.
966 * @param peers Array of peers.
967 * @param cadets Handle to each of the CADETs of the peers.
971 struct GNUNET_CADET_TEST_Context *ctx,
972 unsigned int num_peers,
973 struct GNUNET_TESTBED_Peer **peers,
974 struct GNUNET_CADET_Handle **cadets)
976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
979 peers_running = num_peers;
980 GNUNET_assert (peers_running == peers_requested);
981 testbed_peers = peers;
983 h2 = cadets[num_peers - 1];
984 disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
985 &disconnect_cadet_peers,
987 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
989 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
990 GNUNET_TESTBED_PIT_IDENTITY,
993 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
994 GNUNET_TESTBED_PIT_IDENTITY,
997 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1005 main (int argc, char *argv[])
1007 static const struct GNUNET_HashCode *ports[2];
1008 struct GNUNET_MQ_MessageHandler handlers[] = {
1009 GNUNET_MQ_hd_var_size (data,
1010 GNUNET_MESSAGE_TYPE_DUMMY,
1011 struct GNUNET_MessageHeader,
1013 GNUNET_MQ_handler_end ()
1015 const char *config_file;
1016 char port_id[] = "test port";
1017 struct GNUNET_GETOPT_CommandLineOption options[] = {
1018 GNUNET_GETOPT_option_relative_time ('t',
1021 gettext_noop ("set short timeout"),
1023 GNUNET_GETOPT_option_uint ('m',
1026 gettext_noop ("set number of messages to send"),
1029 GNUNET_GETOPT_OPTION_END
1033 initialized = GNUNET_NO;
1034 GNUNET_log_setup ("test", "DEBUG", NULL);
1036 total_packets = TOTAL_PACKETS;
1037 short_time = SHORT_TIME;
1038 if (-1 == GNUNET_GETOPT_run (argv[0], options, argc, argv))
1040 FPRINTF (stderr, "test failed: problem with CLI parameters\n");
1044 config_file = "test_cadet.conf";
1045 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1047 /* Find out requested size */
1048 if (strstr (argv[0], "_2_") != NULL)
1050 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1051 peers_requested = 2;
1053 else if (strstr (argv[0], "_5_") != NULL)
1055 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1056 peers_requested = 5;
1060 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1061 peers_requested = 2;
1064 /* Find out requested test */
1065 if (strstr (argv[0], "_forward") != NULL)
1067 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1069 test_name = "unicast";
1072 else if (strstr (argv[0], "_signal") != NULL)
1074 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1076 test_name = "signal";
1079 else if (strstr (argv[0], "_speed_ack") != NULL)
1081 /* Test is supposed to generate the following callbacks:
1082 * 1 incoming channel (@dest)
1083 * total_packets received data packet (@dest)
1084 * total_packets received data packet (@orig)
1085 * 1 received channel destroy (@dest)
1087 ok_goal = total_packets * 2 + 2;
1088 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1090 test_name = "speed ack";
1092 else if (strstr (argv[0], "_speed") != NULL)
1094 /* Test is supposed to generate the following callbacks:
1095 * 1 incoming channel (@dest)
1096 * 1 initial packet (@dest)
1097 * total_packets received data packet (@dest)
1098 * 1 received data packet (@orig)
1099 * 1 received channel destroy (@dest)
1101 ok_goal = total_packets + 4;
1102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1103 if (strstr (argv[0], "_reliable") != NULL)
1106 test_name = "speed reliable";
1107 config_file = "test_cadet_drop.conf";
1112 test_name = "speed";
1115 else if (strstr (argv[0], "_keepalive") != NULL)
1118 /* Test is supposed to generate the following callbacks:
1119 * 1 incoming channel (@dest)
1121 * 1 received channel destroy (@dest)
1127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1132 if (strstr (argv[0], "backwards") != NULL)
1134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1135 test_backwards = GNUNET_YES;
1136 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1142 GNUNET_CADET_TEST_ruN ("test_cadet_small",
1146 NULL, /* tmain cls */
1149 &disconnect_handler,
1152 if (NULL != strstr (argv[0], "_reliable"))
1153 msg_dropped = 0; /* dropped should be retransmitted */
1155 if (ok_goal > ok - msg_dropped)
1157 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1164 /* end of test_cadet.c */