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
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file cadet/test_cadet_mq.c
23 * @author Christian Grothoff
24 * @brief Test for the cadet service using mq API.
28 #include "cadet_test_lib_new.h"
29 #include "gnunet_cadet_service.h"
30 #include "gnunet_statistics_service.h"
35 * Ugly workaround to unify data handlers on incoming and outgoing channels.
37 struct CadetTestChannelWrapper
42 struct GNUNET_CADET_Channel *ch;
46 * How many messages to send
48 #define TOTAL_PACKETS 500 /* Cannot exceed 64k! */
51 * How long until we give up on connecting the peers?
53 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
56 * Time to wait for stuff that should be rather fast
58 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
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 events have happened
92 * Number of events expected to conclude the test successfully.
97 * Size of each test packet's payload
99 static size_t size_payload = sizeof (uint32_t);
102 * Operation to get peer ids.
104 static struct GNUNET_TESTBED_Operation *t_op[2];
109 static struct GNUNET_PeerIdentity *p_id[2];
114 static struct GNUNET_HashCode port;
119 static unsigned int p_ids;
122 * Is the setup initialized?
124 static int initialized;
127 * Number of payload packes sent.
129 static int data_sent;
132 * Number of payload packets received.
134 static int data_received;
137 * Number of payload packed acknowledgements sent.
142 * Number of payload packed explicitly (app level) acknowledged.
144 static int ack_received;
147 * Total number of peers asked to run.
149 static unsigned long long peers_requested;
152 * Number of currently running peers (should be same as @c peers_requested).
154 static unsigned long long peers_running;
157 * Test context (to shut down).
159 struct GNUNET_CADET_TEST_Context *test_ctx;
162 * Task called to disconnect peers.
164 static struct GNUNET_SCHEDULER_Task *disconnect_task;
167 * Task To perform tests
169 static struct GNUNET_SCHEDULER_Task *test_task;
172 * Task runnining #send_next_msg().
174 static struct GNUNET_SCHEDULER_Task *send_next_msg_task;
177 * Cadet handle for the root peer
179 static struct GNUNET_CADET_Handle *h1;
182 * Cadet handle for the first leaf peer
184 static struct GNUNET_CADET_Handle *h2;
187 * Channel handle for the root peer
189 static struct GNUNET_CADET_Channel *outgoing_ch;
192 * Channel handle for the dest peer
194 static struct GNUNET_CADET_Channel *incoming_ch;
197 * Time we started the data transmission (after channel has been established
200 static struct GNUNET_TIME_Absolute start_time;
205 static struct GNUNET_TESTBED_Peer **testbed_peers;
208 * Statistics operation handle.
210 static struct GNUNET_TESTBED_Operation *stats_op;
215 static unsigned int ka_sent;
218 * Keepalives received.
220 static unsigned int ka_received;
223 * How many messages were dropped by CADET because of full buffers?
225 static unsigned int msg_dropped;
228 /******************************************************************************/
231 /******************************************************************************/
235 * Get the channel considered as the "target" or "receiver", depending on
236 * the test type and size.
238 * @return Channel handle of the target client, either 0 (for backward tests)
239 * or the last peer in the line (for other tests).
241 static struct GNUNET_CADET_Channel *
242 get_target_channel ()
244 if (SPEED == test && GNUNET_YES == test_backwards)
252 * Show the results of the test (banwidth acheived) and log them to GAUGER
257 static struct GNUNET_TIME_Absolute end_time;
258 static struct GNUNET_TIME_Relative total_time;
260 end_time = GNUNET_TIME_absolute_get ();
261 total_time = GNUNET_TIME_absolute_get_difference (start_time, end_time);
262 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
263 FPRINTF (stderr, "Test time %s\n",
264 GNUNET_STRINGS_relative_time_to_string (total_time, GNUNET_YES));
265 FPRINTF (stderr, "Test bandwidth: %f kb/s\n", 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
266 FPRINTF (stderr, "Test throughput: %f packets/s\n\n", TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
267 GAUGER ("CADET", test_name,
268 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
274 * Disconnect from cadet services af all peers, call shutdown.
276 * @param cls Closure (line number from which termination was requested).
277 * @param tc Task Context.
280 disconnect_cadet_peers (void *cls)
282 long line = (long) cls;
285 disconnect_task = NULL;
286 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
287 "disconnecting cadet service of peers, called from line %ld\n",
289 for (i = 0; i < 2; i++)
291 GNUNET_TESTBED_operation_done (t_op[i]);
293 if (NULL != outgoing_ch)
295 GNUNET_CADET_channel_destroy (outgoing_ch);
298 if (NULL != incoming_ch)
300 GNUNET_CADET_channel_destroy (incoming_ch);
303 GNUNET_CADET_TEST_cleanup (test_ctx);
304 GNUNET_SCHEDULER_shutdown ();
309 * Shut down peergroup, clean up.
311 * @param cls Closure (unused).
312 * @param tc Task Context.
315 shutdown_task (void *cls)
317 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
318 if (NULL != send_next_msg_task)
320 GNUNET_SCHEDULER_cancel (send_next_msg_task);
321 send_next_msg_task = NULL;
323 if (NULL != test_task)
325 GNUNET_SCHEDULER_cancel (test_task);
328 if (NULL != disconnect_task)
330 GNUNET_SCHEDULER_cancel (disconnect_task);
332 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) __LINE__);
338 * Stats callback. Finish the stats testbed operation and when all stats have
339 * been iterated, shutdown the test.
341 * @param cls Closure (line number from which termination was requested).
342 * @param op the operation that has been finished
343 * @param emsg error message in case the operation has failed; will be NULL if
344 * operation has executed successfully.
347 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
349 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
350 ka_sent, ka_received);
351 if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
356 GNUNET_TESTBED_operation_done (stats_op);
358 if (NULL != disconnect_task)
359 GNUNET_SCHEDULER_cancel (disconnect_task);
360 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, cls);
365 * Process statistic values.
367 * @param cls closure (line number, unused)
368 * @param peer the peer the statistic belong to
369 * @param subsystem name of subsystem that created the statistic
370 * @param name the name of the datum
371 * @param value the current value
372 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
373 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
376 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
377 const char *subsystem, const char *name, uint64_t value,
380 static const char *s_sent = "# keepalives sent";
381 static const char *s_recv = "# keepalives received";
382 static const char *rdrops = "# messages dropped due to full buffer";
383 static const char *cdrops = "# messages dropped due to slow client";
386 i = GNUNET_TESTBED_get_index (peer);
387 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n", i,
388 subsystem, name, (unsigned long long) value);
389 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
391 if (0 == strncmp (s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
393 if (0 == strncmp (rdrops, name, strlen (rdrops)))
394 msg_dropped += value;
395 if (0 == strncmp (cdrops, name, strlen (cdrops)))
396 msg_dropped += value;
403 * Task to gather all statistics.
405 * @param cls Closure (line from which the task was scheduled).
408 gather_stats_and_exit (void *cls)
412 disconnect_task = NULL;
413 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
414 "gathering statistics from line %ld\n",
416 if (NULL != outgoing_ch)
418 GNUNET_CADET_channel_destroy (outgoing_ch);
421 stats_op = GNUNET_TESTBED_get_statistics (peers_running,
433 * Abort test: schedule disconnect and shutdown immediately
435 * @param line Line in the code the abort is requested from (__LINE__).
438 abort_test (long line)
440 if (NULL != disconnect_task)
442 GNUNET_SCHEDULER_cancel (disconnect_task);
443 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
445 GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers, (void *) line);
451 * Send a message on the channel with the appropriate size and payload.
453 * Update the appropriate *_sent counter.
455 * @param channel Channel to send the message on.
458 send_test_message (struct GNUNET_CADET_Channel *channel)
460 struct GNUNET_MQ_Envelope *env;
461 struct GNUNET_MessageHeader *msg;
466 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
467 "Sending test message on channel %p\n",
470 if (GNUNET_NO == initialized)
472 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending INITIALIZER\n");
474 counter = &data_sent;
475 if (SPEED_ACK == test) // FIXME unify SPEED_ACK with an initializer
478 else if (SPEED == test || SPEED_ACK == test)
480 counter = get_target_channel() == channel ? &ack_sent : &data_sent;
482 *counter = *counter + 1;
483 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Sending message %u\n", *counter);
489 env = GNUNET_MQ_msg_extra (msg, size, GNUNET_MESSAGE_TYPE_DUMMY);
491 data = (uint32_t *) &msg[1];
492 *data = htonl (*counter);
493 GNUNET_MQ_send (GNUNET_CADET_get_mq (channel), env);
497 * Task to request a new data transmission in a SPEED test, without waiting
498 * for previous messages to be sent/arrrive.
500 * @param cls Closure (unused).
503 send_next_msg (void *cls)
505 struct GNUNET_CADET_Channel *channel;
507 send_next_msg_task = NULL;
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending next message: %d\n", data_sent);
510 channel = GNUNET_YES == test_backwards ? incoming_ch : outgoing_ch;
511 GNUNET_assert (NULL != channel);
512 GNUNET_assert (SPEED == test);
513 send_test_message (channel);
514 if (data_sent < TOTAL_PACKETS)
516 /* SPEED test: Send all messages as soon as possible */
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
518 "Scheduling message %d\n",
520 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
526 * Every few messages cancel the timeout task and re-schedule it again, to
527 * avoid timing out when traffic keeps coming.
529 * @param line Code line number to log if a timeout occurs.
532 reschedule_timeout_task (long line)
536 if (NULL != disconnect_task)
538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
539 " reschedule timeout every 10 messages\n");
540 GNUNET_SCHEDULER_cancel (disconnect_task);
541 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
542 &gather_stats_and_exit,
550 * Check if payload is sane (size contains payload).
552 * @param cls should match #ch
553 * @param message The actual message.
554 * @return #GNUNET_OK to keep the channel open,
555 * #GNUNET_SYSERR to close it (signal serious error).
558 check_data (void *cls, const struct GNUNET_MessageHeader *message)
560 if (sizeof (struct GNUNET_MessageHeader) >= ntohs (message->size))
561 return GNUNET_SYSERR;
562 return GNUNET_OK; /* all is well-formed */
567 * Function is called whenever a message is received.
569 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
570 * @param message the actual message
573 handle_data (void *cls, const struct GNUNET_MessageHeader *message)
575 struct CadetTestChannelWrapper *ch = cls;
576 struct GNUNET_CADET_Channel *channel = ch->ch;
582 counter = get_target_channel () == channel ? &data_received : &ack_received;
584 reschedule_timeout_task ((long) __LINE__);
586 if (channel == outgoing_ch)
588 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
590 else if (channel == incoming_ch)
592 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client got a message.\n");
596 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unknown channel %p.\n", channel);
600 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
601 data = (uint32_t *) &message[1];
602 payload = ntohl (*data);
603 if (payload == *counter)
605 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
609 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
610 " payload %u, expected: %u\n",
614 if (GNUNET_NO == initialized)
616 initialized = GNUNET_YES;
617 start_time = GNUNET_TIME_absolute_get ();
620 GNUNET_assert (incoming_ch == channel);
621 send_next_msg_task = GNUNET_SCHEDULER_add_now (&send_next_msg, NULL);
627 if (get_target_channel () == channel) /* Got "data" */
629 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
630 if (SPEED != test || (ok_goal - 2) == ok)
633 send_test_message (channel);
638 if (data_received < TOTAL_PACKETS)
644 if (SPEED_ACK == test || SPEED == test)
646 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
648 send_test_message (channel);
649 if (ack_received < TOTAL_PACKETS && SPEED != test)
651 if (ok == 2 && SPEED == test)
655 if (test == P2P_SIGNAL)
657 GNUNET_CADET_channel_destroy (incoming_ch);
662 GNUNET_CADET_channel_destroy (outgoing_ch);
670 * Method called whenever a peer connects to a port in MQ-based CADET.
672 * @param cls Closure from #GNUNET_CADET_open_porT (peer # as long).
673 * @param channel New handle to the channel.
674 * @param source Peer that started this channel.
675 * @return Closure for the incoming @a channel. It's given to:
676 * - The #GNUNET_CADET_DisconnectEventHandler (given to
677 * #GNUNET_CADET_open_porT) when the channel dies.
678 * - Each the #GNUNET_MQ_MessageCallback handlers for each message
679 * received on the @a channel.
682 connect_handler (void *cls, struct GNUNET_CADET_Channel *channel,
683 const struct GNUNET_PeerIdentity *source)
685 struct CadetTestChannelWrapper *ch;
686 long peer = (long) cls;
688 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Incoming channel from %s to peer %ld\n",
689 GNUNET_i2s (source), peer);
691 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
692 if (peer == peers_requested - 1)
694 if (NULL != incoming_ch)
696 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
697 "Duplicate incoming channel for client %lu\n", (long) cls);
700 incoming_ch = channel;
704 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
705 "Incoming channel for unexpected peer #%lu\n", (long) cls);
708 if (NULL != disconnect_task)
710 GNUNET_SCHEDULER_cancel (disconnect_task);
712 GNUNET_SCHEDULER_add_delayed (SHORT_TIME, &gather_stats_and_exit,
716 /* TODO: cannot return channel as-is, in order to unify the data handlers */
717 ch = GNUNET_new (struct CadetTestChannelWrapper);
725 * Function called whenever an MQ-channel is destroyed, even if the destruction
726 * was requested by #GNUNET_CADET_channel_destroy.
727 * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
729 * It should clean up any associated state, including cancelling any pending
730 * transmission on this channel.
732 * @param cls Channel closure.
733 * @param channel Connection to the other end (henceforth invalid).
736 disconnect_handler (void *cls, const struct GNUNET_CADET_Channel *channel)
740 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
741 "Channel disconnected at %p\n", cls);
742 if (peers_running - 1 == i)
745 GNUNET_break (channel == incoming_ch);
750 if (P2P_SIGNAL == test)
754 GNUNET_break (channel == outgoing_ch);
758 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unknown peer! %d\n", (int) i);
759 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
761 if (NULL != disconnect_task)
763 GNUNET_SCHEDULER_cancel (disconnect_task);
765 GNUNET_SCHEDULER_add_now (&gather_stats_and_exit, (void *) __LINE__);
771 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
773 * Testcase continues when the root receives confirmation of connected peers,
774 * on callback function ch.
776 * @param cls Closure (unused).
779 start_test (void *cls)
781 struct GNUNET_MQ_MessageHandler handlers[] = {
782 GNUNET_MQ_hd_var_size (data,
783 GNUNET_MESSAGE_TYPE_DUMMY,
784 struct GNUNET_MessageHeader,
786 GNUNET_MQ_handler_end ()
788 struct CadetTestChannelWrapper *ch;
789 enum GNUNET_CADET_ChannelOption flags;
792 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
793 if (NULL != disconnect_task)
795 GNUNET_SCHEDULER_cancel (disconnect_task);
796 disconnect_task = NULL;
799 flags = GNUNET_CADET_OPTION_DEFAULT;
800 if (SPEED_REL == test)
803 flags |= GNUNET_CADET_OPTION_RELIABLE;
806 ch = GNUNET_new (struct CadetTestChannelWrapper);
807 outgoing_ch = GNUNET_CADET_channel_creatE (h1,
815 ch->ch = outgoing_ch;
817 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
818 &gather_stats_and_exit,
820 if (KEEPALIVE == test)
821 return; /* Don't send any data. */
828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
829 send_test_message (outgoing_ch);
834 * Callback to be called when the requested peer information is available
836 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
837 * @param op the operation this callback corresponds to
838 * @param pinfo the result; will be NULL if the operation has failed
839 * @param emsg error message if the operation has failed;
840 * NULL if the operation is successfull
843 pi_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
844 const struct GNUNET_TESTBED_PeerInformation *pinfo, const char *emsg)
848 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ID callback for %ld\n", i);
850 if ((NULL == pinfo) || (NULL != emsg))
852 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
853 abort_test (__LINE__);
856 p_id[i] = pinfo->result.id;
857 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
861 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
862 test_task = GNUNET_SCHEDULER_add_now (&start_test, NULL);
867 * test main: start test when all peers are connected
869 * @param cls Closure.
870 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
871 * @param num_peers Number of peers that are running.
872 * @param peers Array of peers.
873 * @param cadets Handle to each of the CADETs of the peers.
877 struct GNUNET_CADET_TEST_Context *ctx,
878 unsigned int num_peers,
879 struct GNUNET_TESTBED_Peer **peers,
880 struct GNUNET_CADET_Handle **cadets)
882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
885 peers_running = num_peers;
886 GNUNET_assert (peers_running == peers_requested);
887 testbed_peers = peers;
889 h2 = cadets[num_peers - 1];
890 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
891 &disconnect_cadet_peers,
893 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
894 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
895 GNUNET_TESTBED_PIT_IDENTITY,
898 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
899 GNUNET_TESTBED_PIT_IDENTITY,
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
910 main (int argc, char *argv[])
912 struct GNUNET_MQ_MessageHandler handlers[] = {
913 GNUNET_MQ_hd_var_size (data,
914 GNUNET_MESSAGE_TYPE_DUMMY,
915 struct GNUNET_MessageHeader,
917 GNUNET_MQ_handler_end ()
920 initialized = GNUNET_NO;
921 static const struct GNUNET_HashCode *ports[2];
922 const char *config_file;
923 char port_id[] = "test port";
925 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
927 GNUNET_log_setup ("test", "DEBUG", NULL);
928 config_file = "test_cadet.conf";
930 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
932 /* Find out requested size */
933 if (strstr (argv[0], "_2_") != NULL)
935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
938 else if (strstr (argv[0], "_5_") != NULL)
940 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
945 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
949 /* Find out requested test */
950 if (strstr (argv[0], "_forward") != NULL)
952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
954 test_name = "unicast";
957 else if (strstr (argv[0], "_signal") != NULL)
959 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
961 test_name = "signal";
964 else if (strstr (argv[0], "_speed_ack") != NULL)
966 /* Test is supposed to generate the following callbacks:
967 * 1 incoming channel (@dest)
968 * TOTAL_PACKETS received data packet (@dest)
969 * TOTAL_PACKETS received data packet (@orig)
970 * 1 received channel destroy (@dest)
972 ok_goal = TOTAL_PACKETS * 2 + 2;
973 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
975 test_name = "speed ack";
977 else if (strstr (argv[0], "_speed") != NULL)
979 /* Test is supposed to generate the following callbacks:
980 * 1 incoming channel (@dest)
981 * 1 initial packet (@dest)
982 * TOTAL_PACKETS received data packet (@dest)
983 * 1 received data packet (@orig)
984 * 1 received channel destroy (@dest)
986 ok_goal = TOTAL_PACKETS + 4;
987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
988 if (strstr (argv[0], "_reliable") != NULL)
991 test_name = "speed reliable";
992 config_file = "test_cadet_drop.conf";
1000 else if (strstr (argv[0], "_keepalive") != NULL)
1003 /* Test is supposed to generate the following callbacks:
1004 * 1 incoming channel (@dest)
1006 * 1 received channel destroy (@dest)
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1017 if (strstr (argv[0], "backwards") != NULL)
1019 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1020 test_backwards = GNUNET_YES;
1021 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1027 GNUNET_CADET_TEST_ruN ("test_cadet_small",
1031 NULL, /* tmain cls */
1034 &disconnect_handler,
1037 if (NULL != strstr (argv[0], "_reliable"))
1038 msg_dropped = 0; /* dropped should be retransmitted */
1040 if (ok_goal > ok - msg_dropped)
1042 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "FAILED! (%d/%d)\n", ok, ok_goal);
1045 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1049 /* end of test_cadet.c */