2 This file is part of GNUnet.
3 Copyright (C) 2011 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.c
23 * @brief Test for the cadet service: retransmission of traffic.
27 #include "cadet_test_lib.h"
28 #include "gnunet_cadet_service.h"
29 #include "gnunet_statistics_service.h"
34 * How many messages to send
36 #define TOTAL_PACKETS 200 /* Cannot exceed 64k! */
39 * How long until we give up on connecting the peers?
41 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
44 * Time to wait for stuff that should be rather fast
46 #define SHORT_TIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
49 * DIFFERENT TESTS TO RUN
60 * Which test are we running?
65 * String with test name
70 * Flag to send traffic leaf->root in speed tests to test BCK_ACK logic.
72 static int test_backwards = GNUNET_NO;
75 * How many events have happened
80 * Number of events expected to conclude the test successfully.
85 * Size of each test packet
87 size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
90 * Operation to get peer ids.
92 struct GNUNET_TESTBED_Operation *t_op[2];
97 struct GNUNET_PeerIdentity *p_id[2];
105 * Is the setup initialized?
107 static int initialized;
110 * Number of payload packes sent.
112 static int data_sent;
115 * Number of payload packets received.
117 static int data_received;
120 * Number of payload packed acknowledgements sent.
125 * Number of payload packed explicitly (app level) acknowledged.
127 static int ack_received;
130 * Total number of peers asked to run.
132 static unsigned long long peers_requested;
135 * Number of currently running peers (should be same as @c peers_requested).
137 static unsigned long long peers_running;
140 * Test context (to shut down).
142 struct GNUNET_CADET_TEST_Context *test_ctx;
145 * Task called to disconnect peers.
147 static struct GNUNET_SCHEDULER_Task *disconnect_task;
150 * Task To perform tests
152 static struct GNUNET_SCHEDULER_Task *test_task;
155 * Task runnining #data_task().
157 static struct GNUNET_SCHEDULER_Task *data_job;
160 * Cadet handle for the root peer
162 static struct GNUNET_CADET_Handle *h1;
165 * Cadet handle for the first leaf peer
167 static struct GNUNET_CADET_Handle *h2;
170 * Channel handle for the root peer
172 static struct GNUNET_CADET_Channel *ch;
175 * Channel handle for the dest peer
177 static struct GNUNET_CADET_Channel *incoming_ch;
180 * Transmit handle for root data calls
182 static struct GNUNET_CADET_TransmitHandle *th;
185 * Transmit handle for root data calls
187 static struct GNUNET_CADET_TransmitHandle *incoming_th;
191 * Time we started the data transmission (after channel has been established
194 static struct GNUNET_TIME_Absolute start_time;
199 static struct GNUNET_TESTBED_Peer **testbed_peers;
202 * Statistics operation handle.
204 static struct GNUNET_TESTBED_Operation *stats_op;
209 static unsigned int ka_sent;
212 * Keepalives received.
214 static unsigned int ka_received;
218 * Get the client number considered as the "target" or "receiver", depending on
219 * the test type and size.
221 * @return Peer # of the target client, either 0 (for backward tests) or
222 * the last peer in the line (for other tests).
225 get_expected_target ()
227 if (SPEED == test && GNUNET_YES == test_backwards)
230 return peers_requested - 1;
235 * Show the results of the test (banwidth acheived) and log them to GAUGER
240 static struct GNUNET_TIME_Absolute end_time;
241 static struct GNUNET_TIME_Relative total_time;
243 end_time = GNUNET_TIME_absolute_get();
244 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
245 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
246 FPRINTF (stderr, "Test time %s\n",
247 GNUNET_STRINGS_relative_time_to_string (total_time,
249 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
250 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
251 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
252 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
253 GAUGER ("CADET", test_name,
254 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
260 * Disconnect from cadet services af all peers, call shutdown.
262 * @param cls Closure (line number from which termination was requested).
263 * @param tc Task Context.
266 disconnect_cadet_peers (void *cls)
268 long line = (long) cls;
271 disconnect_task = NULL;
272 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
273 "disconnecting cadet service of peers, called from line %ld\n",
275 for (i = 0; i < 2; i++)
277 GNUNET_TESTBED_operation_done (t_op[i]);
283 GNUNET_CADET_notify_transmit_ready_cancel (th);
286 GNUNET_CADET_channel_destroy (ch);
289 if (NULL != incoming_ch)
291 if (NULL != incoming_th)
293 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
296 GNUNET_CADET_channel_destroy (incoming_ch);
299 GNUNET_CADET_TEST_cleanup (test_ctx);
300 GNUNET_SCHEDULER_shutdown ();
305 * Shut down peergroup, clean up.
307 * @param cls Closure (unused).
308 * @param tc Task Context.
311 shutdown_task (void *cls)
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
314 if (NULL != data_job)
316 GNUNET_SCHEDULER_cancel (data_job);
319 if (NULL != test_task)
321 GNUNET_SCHEDULER_cancel (test_task);
324 if (NULL != disconnect_task)
326 GNUNET_SCHEDULER_cancel (disconnect_task);
327 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
334 * Stats callback. Finish the stats testbed operation and when all stats have
335 * been iterated, shutdown the test.
337 * @param cls Closure (line number from which termination was requested).
338 * @param op the operation that has been finished
339 * @param emsg error message in case the operation has failed; will be NULL if
340 * operation has executed successfully.
343 stats_cont (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
345 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " KA sent: %u, KA received: %u\n",
346 ka_sent, ka_received);
347 if (KEEPALIVE == test && (ka_sent < 2 || ka_sent > ka_received + 1))
349 GNUNET_TESTBED_operation_done (stats_op);
351 if (NULL != disconnect_task)
352 GNUNET_SCHEDULER_cancel (disconnect_task);
353 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
359 * Process statistic values.
361 * @param cls closure (line number, unused)
362 * @param peer the peer the statistic belong to
363 * @param subsystem name of subsystem that created the statistic
364 * @param name the name of the datum
365 * @param value the current value
366 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
367 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
370 stats_iterator (void *cls, const struct GNUNET_TESTBED_Peer *peer,
371 const char *subsystem, const char *name,
372 uint64_t value, int is_persistent)
374 static const char *s_sent = "# keepalives sent";
375 static const char *s_recv = "# keepalives received";
378 i = GNUNET_TESTBED_get_index (peer);
379 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "STATS PEER %u - %s [%s]: %llu\n",
380 i, subsystem, name, value);
381 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
384 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
392 * Task to gather all statistics.
394 * @param cls Closure (NULL).
397 gather_stats_and_exit (void *cls)
401 disconnect_task = NULL;
402 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
403 "gathering statistics from line %d\n",
409 GNUNET_CADET_notify_transmit_ready_cancel (th);
412 GNUNET_CADET_channel_destroy (ch);
415 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
417 stats_iterator, stats_cont, cls);
423 * Abort test: schedule disconnect and shutdown immediately
425 * @param line Line in the code the abort is requested from (__LINE__).
428 abort_test (long line)
430 if (disconnect_task != NULL)
432 GNUNET_SCHEDULER_cancel (disconnect_task);
433 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Aborting test from %ld\n", line);
434 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
440 * Transmit ready callback.
442 * @param cls Closure (message type).
443 * @param size Size of the tranmist buffer.
444 * @param buf Pointer to the beginning of the buffer.
446 * @return Number of bytes written to buf.
449 tmt_rdy (void *cls, size_t size, void *buf);
453 * Task to request a new data transmission.
455 * @param cls Closure (peer #).
458 data_task (void *cls)
460 struct GNUNET_CADET_Channel *channel;
461 static struct GNUNET_CADET_TransmitHandle **pth;
465 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
466 if (GNUNET_YES == test_backwards)
468 channel = incoming_ch;
470 src = peers_requested - 1;
479 GNUNET_assert (NULL != channel);
480 GNUNET_assert (NULL == *pth);
482 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
483 GNUNET_TIME_UNIT_FOREVER_REL,
484 size_payload + data_sent,
485 &tmt_rdy, (void *) src);
488 unsigned long i = (unsigned long) cls;
490 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
493 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
494 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
495 &data_task, (void *) 1L);
500 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "in %u ms\n", i);
501 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
503 &data_task, (void *) i);
510 * Transmit ready callback
512 * @param cls Closure (peer # which is sending the data).
513 * @param size Size of the buffer we have.
514 * @param buf Buffer to copy data to.
517 tmt_rdy (void *cls, size_t size, void *buf)
519 struct GNUNET_MessageHeader *msg = buf;
522 long id = (long) cls;
523 unsigned int counter;
525 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tmt_rdy on %ld, filling buffer\n", id);
528 else if ((peers_requested - 1) == id)
532 counter = get_expected_target () == id ? ack_sent : data_sent;
533 msg_size = size_payload + counter;
534 if (size < msg_size || NULL == buf)
536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
537 "size %u, buf %p, data_sent %u, ack_received %u\n",
538 size, buf, data_sent, ack_received);
539 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
540 GNUNET_break (ok >= ok_goal - 2);
544 msg->size = htons (msg_size);
545 msg->type = htons (1);
546 data = (uint32_t *) &msg[1];
547 *data = htonl (counter);
548 if (GNUNET_NO == initialized)
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sending initializer\n");
551 msg_size = size_payload + 1000;
552 if (SPEED_ACK == test)
555 else if (SPEED == test || SPEED_ACK == test)
557 if (get_expected_target() == id)
562 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " Sent message %d size %u\n",
564 if (data_sent < TOTAL_PACKETS && SPEED == test)
566 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Scheduling message %d\n",
568 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
577 * Function is called whenever a message is received.
579 * @param cls closure (set from GNUNET_CADET_connect, peer number)
580 * @param channel connection to the other end
581 * @param channel_ctx place to store local state associated with the channel
582 * @param message the actual message
583 * @return GNUNET_OK to keep the connection open,
584 * GNUNET_SYSERR to close it (signal serious error)
587 data_callback (void *cls, struct GNUNET_CADET_Channel *channel,
589 const struct GNUNET_MessageHeader *message)
591 struct GNUNET_CADET_TransmitHandle **pth;
592 long client = (long) cls;
593 long expected_target_client;
596 unsigned int counter;
599 counter = get_expected_target () == client ? data_received : ack_received;
601 GNUNET_CADET_receive_done (channel);
605 if (NULL != disconnect_task)
607 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " reschedule timeout\n");
608 GNUNET_SCHEDULER_cancel (disconnect_task);
609 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
610 &gather_stats_and_exit,
618 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
619 GNUNET_assert (channel == ch);
624 GNUNET_assert (client == peers_requested - 1);
625 GNUNET_assert (channel == incoming_ch);
627 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
631 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
634 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
635 data = (uint32_t *) &message[1];
636 payload = ntohl (*data);
637 if (payload == counter)
639 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
643 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
646 expected_target_client = get_expected_target ();
648 if (GNUNET_NO == initialized)
650 initialized = GNUNET_YES;
651 start_time = GNUNET_TIME_absolute_get ();
654 GNUNET_assert (peers_requested - 1 == client);
655 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
661 if (client == expected_target_client) /* Normally 4 */
664 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
665 if (SPEED != test || (ok_goal - 2) == ok)
668 GNUNET_assert (NULL == *pth);
669 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
670 GNUNET_TIME_UNIT_FOREVER_REL,
671 size_payload + ack_sent,
672 &tmt_rdy, (void *) client);
677 if (data_received < TOTAL_PACKETS)
681 else /* Normally 0 */
683 if (SPEED_ACK == test || SPEED == test)
686 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
688 GNUNET_assert (NULL == *pth);
689 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
690 GNUNET_TIME_UNIT_FOREVER_REL,
691 size_payload + data_sent,
692 &tmt_rdy, (void *) client);
693 if (ack_received < TOTAL_PACKETS && SPEED != test)
695 if (ok == 2 && SPEED == test)
699 if (test == P2P_SIGNAL)
701 if (NULL != incoming_th)
703 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
706 GNUNET_CADET_channel_destroy (incoming_ch);
713 GNUNET_CADET_notify_transmit_ready_cancel (th);
716 GNUNET_CADET_channel_destroy (ch);
726 * Data handlers for every message type of CADET's payload.
727 * {callback_function, message_type, size_expected}
729 static struct GNUNET_CADET_MessageHandler handlers[] = {
730 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
736 * Method called whenever another peer has added us to a channel
737 * the other peer initiated.
739 * @param cls Closure.
740 * @param channel New handle to the channel.
741 * @param initiator Peer that started the channel.
742 * @param port Port this channel is connected to.
743 * @param options channel option flags
744 * @return Initial channel context for the channel
745 * (can be NULL -- that's not an error).
748 incoming_channel (void *cls, struct GNUNET_CADET_Channel *channel,
749 const struct GNUNET_PeerIdentity *initiator,
750 uint32_t port, enum GNUNET_CADET_ChannelOption options)
752 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
753 "Incoming channel from %s to peer %d\n",
754 GNUNET_i2s (initiator), (long) cls);
756 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
757 if ((long) cls == peers_requested - 1)
758 incoming_ch = channel;
761 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
762 "Incoming channel for unknown client %lu\n", (long) cls);
765 if (NULL != disconnect_task)
767 GNUNET_SCHEDULER_cancel (disconnect_task);
768 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
769 &gather_stats_and_exit,
777 * Function called whenever an inbound channel is destroyed. Should clean up
778 * any associated state.
780 * @param cls closure (set from GNUNET_CADET_connect, peer number)
781 * @param channel connection to the other end (henceforth invalid)
782 * @param channel_ctx place where local state associated
783 * with the channel is stored
786 channel_cleaner (void *cls, const struct GNUNET_CADET_Channel *channel,
791 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
792 "Incoming channel disconnected at peer %ld\n", i);
793 if (peers_running - 1 == i)
796 GNUNET_break (channel == incoming_ch);
801 if (P2P_SIGNAL == test)
805 GNUNET_break (channel == ch);
809 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
810 "Unknown peer! %d\n", i);
811 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
813 if (NULL != disconnect_task)
815 GNUNET_SCHEDULER_cancel (disconnect_task);
816 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
825 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
827 * Testcase continues when the root receives confirmation of connected peers,
828 * on callback function ch.
830 * @param cls Closure (unused).
835 enum GNUNET_CADET_ChannelOption flags;
838 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "do_test\n");
840 if (NULL != disconnect_task)
842 GNUNET_SCHEDULER_cancel (disconnect_task);
843 disconnect_task = NULL;
846 flags = GNUNET_CADET_OPTION_DEFAULT;
847 if (SPEED_REL == test)
850 flags |= GNUNET_CADET_OPTION_RELIABLE;
852 ch = GNUNET_CADET_channel_create (h1, NULL, p_id[1], 1, flags);
854 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
855 &gather_stats_and_exit,
857 if (KEEPALIVE == test)
858 return; /* Don't send any data. */
860 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending data initializer...\n");
865 th = GNUNET_CADET_notify_transmit_ready (ch, GNUNET_NO,
866 GNUNET_TIME_UNIT_FOREVER_REL,
868 &tmt_rdy, (void *) 0L);
873 * Callback to be called when the requested peer information is available
875 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
876 * @param op the operation this callback corresponds to
877 * @param pinfo the result; will be NULL if the operation has failed
878 * @param emsg error message if the operation has failed;
879 * NULL if the operation is successfull
883 struct GNUNET_TESTBED_Operation *op,
884 const struct GNUNET_TESTBED_PeerInformation *pinfo,
889 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
891 if (NULL == pinfo || NULL != emsg)
893 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
894 abort_test (__LINE__);
897 p_id[i] = pinfo->result.id;
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
903 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
908 * test main: start test when all peers are connected
910 * @param cls Closure.
911 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
912 * @param num_peers Number of peers that are running.
913 * @param peers Array of peers.
914 * @param cadetes Handle to each of the CADETs of the peers.
918 struct GNUNET_CADET_TEST_Context *ctx,
919 unsigned int num_peers,
920 struct GNUNET_TESTBED_Peer **peers,
921 struct GNUNET_CADET_Handle **cadets)
923 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
926 peers_running = num_peers;
927 GNUNET_assert (peers_running == peers_requested);
928 testbed_peers = peers;
930 h2 = cadets[num_peers - 1];
931 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
932 &disconnect_cadet_peers,
934 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
935 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
936 GNUNET_TESTBED_PIT_IDENTITY,
937 &pi_cb, (void *) 0L);
938 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
939 GNUNET_TESTBED_PIT_IDENTITY,
940 &pi_cb, (void *) 1L);
941 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
949 main (int argc, char *argv[])
951 initialized = GNUNET_NO;
952 static uint32_t ports[2];
953 const char *config_file;
955 GNUNET_log_setup ("test", "DEBUG", NULL);
956 config_file = "test_cadet.conf";
958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
960 /* Find out requested size */
961 if (strstr (argv[0], "_2_") != NULL)
963 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
966 else if (strstr (argv[0], "_5_") != NULL)
968 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
973 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
977 /* Find out requested test */
978 if (strstr (argv[0], "_forward") != NULL)
980 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
982 test_name = "unicast";
985 else if (strstr (argv[0], "_signal") != NULL)
987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
989 test_name = "signal";
992 else if (strstr (argv[0], "_speed_ack") != NULL)
994 /* Test is supposed to generate the following callbacks:
995 * 1 incoming channel (@dest)
996 * TOTAL_PACKETS received data packet (@dest)
997 * TOTAL_PACKETS received data packet (@orig)
998 * 1 received channel destroy (@dest)
1000 ok_goal = TOTAL_PACKETS * 2 + 2;
1001 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1003 test_name = "speed ack";
1005 else if (strstr (argv[0], "_speed") != NULL)
1007 /* Test is supposed to generate the following callbacks:
1008 * 1 incoming channel (@dest)
1009 * 1 initial packet (@dest)
1010 * TOTAL_PACKETS received data packet (@dest)
1011 * 1 received data packet (@orig)
1012 * 1 received channel destroy (@dest)
1014 ok_goal = TOTAL_PACKETS + 4;
1015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1016 if (strstr (argv[0], "_reliable") != NULL)
1019 test_name = "speed reliable";
1020 config_file = "test_cadet_drop.conf";
1025 test_name = "speed";
1028 else if (strstr (argv[0], "_keepalive") != NULL)
1031 /* Test is supposed to generate the following callbacks:
1032 * 1 incoming channel (@dest)
1034 * 1 received channel destroy (@dest)
1040 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1045 if (strstr (argv[0], "backwards") != NULL)
1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1048 test_backwards = GNUNET_YES;
1049 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1055 GNUNET_CADET_TEST_run ("test_cadet_small",
1059 NULL, /* tmain cls */
1067 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1068 "FAILED! (%d/%d)\n", ok, ok_goal);
1071 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1075 /* end of test_cadet.c */