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.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 500 /* 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
67 static char *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 static size_t size_payload = sizeof (struct GNUNET_MessageHeader) + sizeof (uint32_t);
90 * Operation to get peer ids.
92 static struct GNUNET_TESTBED_Operation *t_op[2];
97 static struct GNUNET_PeerIdentity *p_id[2];
102 static struct GNUNET_HashCode port;
107 static unsigned int p_ids;
110 * Is the setup initialized?
112 static int initialized;
115 * Number of payload packes sent.
117 static int data_sent;
120 * Number of payload packets received.
122 static int data_received;
125 * Number of payload packed acknowledgements sent.
130 * Number of payload packed explicitly (app level) acknowledged.
132 static int ack_received;
135 * Total number of peers asked to run.
137 static unsigned long long peers_requested;
140 * Number of currently running peers (should be same as @c peers_requested).
142 static unsigned long long peers_running;
145 * Test context (to shut down).
147 struct GNUNET_CADET_TEST_Context *test_ctx;
150 * Task called to disconnect peers.
152 static struct GNUNET_SCHEDULER_Task *disconnect_task;
155 * Task To perform tests
157 static struct GNUNET_SCHEDULER_Task *test_task;
160 * Task runnining #data_task().
162 static struct GNUNET_SCHEDULER_Task *data_job;
165 * Cadet handle for the root peer
167 static struct GNUNET_CADET_Handle *h1;
170 * Cadet handle for the first leaf peer
172 static struct GNUNET_CADET_Handle *h2;
175 * Channel handle for the root peer
177 static struct GNUNET_CADET_Channel *ch;
180 * Channel handle for the dest peer
182 static struct GNUNET_CADET_Channel *incoming_ch;
185 * Transmit handle for root data calls
187 static struct GNUNET_CADET_TransmitHandle *th;
190 * Transmit handle for root data calls
192 static struct GNUNET_CADET_TransmitHandle *incoming_th;
196 * Time we started the data transmission (after channel has been established
199 static struct GNUNET_TIME_Absolute start_time;
204 static struct GNUNET_TESTBED_Peer **testbed_peers;
207 * Statistics operation handle.
209 static struct GNUNET_TESTBED_Operation *stats_op;
214 static unsigned int ka_sent;
217 * Keepalives received.
219 static unsigned int ka_received;
223 * Get the client number considered as the "target" or "receiver", depending on
224 * the test type and size.
226 * @return Peer # of the target client, either 0 (for backward tests) or
227 * the last peer in the line (for other tests).
230 get_expected_target ()
232 if (SPEED == test && GNUNET_YES == test_backwards)
235 return peers_requested - 1;
240 * Show the results of the test (banwidth acheived) and log them to GAUGER
245 static struct GNUNET_TIME_Absolute end_time;
246 static struct GNUNET_TIME_Relative total_time;
248 end_time = GNUNET_TIME_absolute_get();
249 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
250 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
251 FPRINTF (stderr, "Test time %s\n",
252 GNUNET_STRINGS_relative_time_to_string (total_time,
254 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
255 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
256 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
257 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
258 GAUGER ("CADET", test_name,
259 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
265 * Disconnect from cadet services af all peers, call shutdown.
267 * @param cls Closure (line number from which termination was requested).
268 * @param tc Task Context.
271 disconnect_cadet_peers (void *cls)
273 long line = (long) cls;
276 disconnect_task = NULL;
277 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
278 "disconnecting cadet service of peers, called from line %ld\n",
280 for (i = 0; i < 2; i++)
282 GNUNET_TESTBED_operation_done (t_op[i]);
288 GNUNET_CADET_notify_transmit_ready_cancel (th);
291 GNUNET_CADET_channel_destroy (ch);
294 if (NULL != incoming_ch)
296 if (NULL != incoming_th)
298 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
301 GNUNET_CADET_channel_destroy (incoming_ch);
304 GNUNET_CADET_TEST_cleanup (test_ctx);
305 GNUNET_SCHEDULER_shutdown ();
310 * Shut down peergroup, clean up.
312 * @param cls Closure (unused).
313 * @param tc Task Context.
316 shutdown_task (void *cls)
318 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
319 if (NULL != data_job)
321 GNUNET_SCHEDULER_cancel (data_job);
324 if (NULL != test_task)
326 GNUNET_SCHEDULER_cancel (test_task);
329 if (NULL != disconnect_task)
331 GNUNET_SCHEDULER_cancel (disconnect_task);
332 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
339 * Stats callback. Finish the stats testbed operation and when all stats have
340 * been iterated, shutdown the test.
342 * @param cls Closure (line number from which termination was requested).
343 * @param op the operation that has been finished
344 * @param emsg error message in case the operation has failed; will be NULL if
345 * operation has executed successfully.
348 stats_cont (void *cls,
349 struct GNUNET_TESTBED_Operation *op,
352 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
353 " KA sent: %u, KA received: %u\n",
356 if ( (KEEPALIVE == test) &&
358 (ka_sent > ka_received + 1)) )
363 GNUNET_TESTBED_operation_done (stats_op);
365 if (NULL != disconnect_task)
366 GNUNET_SCHEDULER_cancel (disconnect_task);
367 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
373 * Process statistic values.
375 * @param cls closure (line number, unused)
376 * @param peer the peer the statistic belong to
377 * @param subsystem name of subsystem that created the statistic
378 * @param name the name of the datum
379 * @param value the current value
380 * @param is_persistent #GNUNET_YES if the value is persistent, #GNUNET_NO if not
381 * @return #GNUNET_OK to continue, #GNUNET_SYSERR to abort iteration
384 stats_iterator (void *cls,
385 const struct GNUNET_TESTBED_Peer *peer,
386 const char *subsystem,
391 static const char *s_sent = "# keepalives sent";
392 static const char *s_recv = "# keepalives received";
395 i = GNUNET_TESTBED_get_index (peer);
396 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
397 "STATS PEER %u - %s [%s]: %llu\n",
401 (unsigned long long) value);
402 if (0 == strncmp (s_sent, name, strlen (s_sent)) && 0 == i)
405 if (0 == strncmp(s_recv, name, strlen (s_recv)) && peers_requested - 1 == i)
413 * Task to gather all statistics.
415 * @param cls Closure (NULL).
418 gather_stats_and_exit (void *cls)
422 disconnect_task = NULL;
423 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
424 "gathering statistics from line %d\n",
430 GNUNET_CADET_notify_transmit_ready_cancel (th);
433 GNUNET_CADET_channel_destroy (ch);
436 stats_op = GNUNET_TESTBED_get_statistics (peers_running, testbed_peers,
438 stats_iterator, stats_cont, cls);
444 * Abort test: schedule disconnect and shutdown immediately
446 * @param line Line in the code the abort is requested from (__LINE__).
449 abort_test (long line)
451 if (NULL != disconnect_task)
453 GNUNET_SCHEDULER_cancel (disconnect_task);
454 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
455 "Aborting test from %ld\n", line);
456 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cadet_peers,
462 * Transmit ready callback.
464 * @param cls Closure (message type).
465 * @param size Size of the tranmist buffer.
466 * @param buf Pointer to the beginning of the buffer.
468 * @return Number of bytes written to buf.
471 tmt_rdy (void *cls, size_t size, void *buf);
475 * Task to request a new data transmission.
477 * @param cls Closure (peer #).
480 data_task (void *cls)
482 struct GNUNET_CADET_Channel *channel;
483 static struct GNUNET_CADET_TransmitHandle **pth;
487 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
488 if (GNUNET_YES == test_backwards)
490 channel = incoming_ch;
492 src = peers_requested - 1;
501 GNUNET_assert (NULL != channel);
502 GNUNET_assert (NULL == *pth);
504 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
505 GNUNET_TIME_UNIT_FOREVER_REL,
506 size_payload + data_sent,
507 &tmt_rdy, (void *) src);
510 unsigned long i = (unsigned long) cls;
512 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Retransmission\n");
515 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " in 1 ms\n");
516 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
517 &data_task, (void *) 1L);
522 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
524 (unsigned long long) i);
525 data_job = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
527 &data_task, (void *) i);
534 * Transmit ready callback
536 * @param cls Closure (peer # which is sending the data).
537 * @param size Size of the buffer we have.
538 * @param buf Buffer to copy data to.
541 tmt_rdy (void *cls, size_t size, void *buf)
543 struct GNUNET_MessageHeader *msg = buf;
546 long id = (long) cls;
547 unsigned int counter;
549 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
550 "tmt_rdy on %ld, filling buffer\n",
554 else if ((peers_requested - 1) == id)
558 counter = get_expected_target () == id ? ack_sent : data_sent;
559 msg_size = size_payload + counter;
560 GNUNET_assert (msg_size > sizeof (struct GNUNET_MessageHeader));
561 if ( (size < msg_size) ||
564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
565 "size %u, buf %p, data_sent %u, ack_received %u\n",
570 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
571 GNUNET_break (ok >= ok_goal - 2);
575 msg->size = htons (msg_size);
576 msg->type = htons (GNUNET_MESSAGE_TYPE_DUMMY);
577 data = (uint32_t *) &msg[1];
578 *data = htonl (counter);
579 if (GNUNET_NO == initialized)
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
582 "sending initializer\n");
583 msg_size = size_payload + 1000;
584 msg->size = htons (msg_size);
585 if (SPEED_ACK == test)
588 else if ( (SPEED == test) ||
589 (SPEED_ACK == test) )
591 if (get_expected_target() == id)
596 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
597 " Sent message %u size %u\n",
599 (unsigned int) msg_size);
600 if ( (data_sent < TOTAL_PACKETS) &&
603 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
604 " Scheduling message %d\n",
606 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
615 * Function is called whenever a message is received.
617 * @param cls closure (set from GNUNET_CADET_connect(), peer number)
618 * @param channel connection to the other end
619 * @param channel_ctx place to store local state associated with the channel
620 * @param message the actual message
621 * @return #GNUNET_OK to keep the connection open,
622 * #GNUNET_SYSERR to close it (signal serious error)
625 data_callback (void *cls,
626 struct GNUNET_CADET_Channel *channel,
628 const struct GNUNET_MessageHeader *message)
630 struct GNUNET_CADET_TransmitHandle **pth;
631 long client = (long) cls;
632 long expected_target_client;
635 unsigned int counter;
638 counter = get_expected_target () == client ? data_received : ack_received;
640 GNUNET_CADET_receive_done (channel);
644 if (NULL != disconnect_task)
646 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
647 " reschedule timeout\n");
648 GNUNET_SCHEDULER_cancel (disconnect_task);
649 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
650 &gather_stats_and_exit,
658 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
659 GNUNET_assert (channel == ch);
664 GNUNET_assert (client == peers_requested - 1);
665 GNUNET_assert (channel == incoming_ch);
667 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Leaf client %ld got a message.\n",
671 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Client %ld not valid.\n", client);
674 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
675 data = (uint32_t *) &message[1];
676 payload = ntohl (*data);
677 if (payload == counter)
679 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload as expected: %u\n", payload);
683 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " payload %u, expected: %u\n",
686 expected_target_client = get_expected_target ();
688 if (GNUNET_NO == initialized)
690 initialized = GNUNET_YES;
691 start_time = GNUNET_TIME_absolute_get ();
694 GNUNET_assert (peers_requested - 1 == client);
695 data_job = GNUNET_SCHEDULER_add_now (&data_task, NULL);
701 if (client == expected_target_client) /* Normally 4 */
704 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
705 if (SPEED != test || (ok_goal - 2) == ok)
708 GNUNET_assert (NULL == *pth);
709 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
710 GNUNET_TIME_UNIT_FOREVER_REL,
711 size_payload + ack_sent,
712 &tmt_rdy, (void *) client);
717 if (data_received < TOTAL_PACKETS)
721 else /* Normally 0 */
723 if (SPEED_ACK == test || SPEED == test)
726 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", ack_received);
728 GNUNET_assert (NULL == *pth);
729 *pth = GNUNET_CADET_notify_transmit_ready (channel, GNUNET_NO,
730 GNUNET_TIME_UNIT_FOREVER_REL,
731 size_payload + data_sent,
732 &tmt_rdy, (void *) client);
733 if (ack_received < TOTAL_PACKETS && SPEED != test)
735 if (ok == 2 && SPEED == test)
739 if (test == P2P_SIGNAL)
741 if (NULL != incoming_th)
743 GNUNET_CADET_notify_transmit_ready_cancel (incoming_th);
746 GNUNET_CADET_channel_destroy (incoming_ch);
753 GNUNET_CADET_notify_transmit_ready_cancel (th);
756 GNUNET_CADET_channel_destroy (ch);
766 * Data handlers for every message type of CADET's payload.
767 * {callback_function, message_type, size_expected}
769 static struct GNUNET_CADET_MessageHandler handlers[] = {
771 GNUNET_MESSAGE_TYPE_DUMMY,
772 sizeof (struct GNUNET_MessageHeader)},
778 * Method called whenever another peer has added us to a channel
779 * the other peer initiated.
781 * @param cls Closure.
782 * @param channel New handle to the channel.
783 * @param initiator Peer that started the channel.
784 * @param port Port this channel is connected to.
785 * @param options channel option flags
786 * @return Initial channel context for the channel
787 * (can be NULL -- that's not an error).
790 incoming_channel (void *cls,
791 struct GNUNET_CADET_Channel *channel,
792 const struct GNUNET_PeerIdentity *initiator,
793 const struct GNUNET_HashCode *port,
794 enum GNUNET_CADET_ChannelOption options)
796 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
797 "Incoming channel from %s to peer %d:%s\n",
798 GNUNET_i2s (initiator),
799 (int) (long) cls, GNUNET_h2s (port));
801 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
802 if ((long) cls == peers_requested - 1)
804 if (NULL != incoming_ch)
806 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
807 "Duplicate incoming channel for client %lu\n",
811 incoming_ch = channel;
815 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
816 "Incoming channel for unknown client %lu\n", (long) cls);
819 if (NULL != disconnect_task)
821 GNUNET_SCHEDULER_cancel (disconnect_task);
822 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
823 &gather_stats_and_exit,
832 * Function called whenever an inbound channel is destroyed. Should clean up
833 * any associated state.
835 * @param cls closure (set from GNUNET_CADET_connect, peer number)
836 * @param channel connection to the other end (henceforth invalid)
837 * @param channel_ctx place where local state associated
838 * with the channel is stored
841 channel_cleaner (void *cls,
842 const struct GNUNET_CADET_Channel *channel,
847 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
848 "Incoming channel disconnected at peer %ld\n",
850 if (peers_running - 1 == i)
853 GNUNET_break (channel == incoming_ch);
858 if (P2P_SIGNAL == test)
862 GNUNET_break (channel == ch);
866 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
867 "Unknown peer! %d\n",
869 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
871 if (NULL != disconnect_task)
873 GNUNET_SCHEDULER_cancel (disconnect_task);
874 disconnect_task = GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
881 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
883 * Testcase continues when the root receives confirmation of connected peers,
884 * on callback function ch.
886 * @param cls Closure (unused).
891 enum GNUNET_CADET_ChannelOption flags;
894 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
896 if (NULL != disconnect_task)
898 GNUNET_SCHEDULER_cancel (disconnect_task);
899 disconnect_task = NULL;
902 flags = GNUNET_CADET_OPTION_DEFAULT;
903 if (SPEED_REL == test)
906 flags |= GNUNET_CADET_OPTION_RELIABLE;
909 ch = GNUNET_CADET_channel_create (h1,
916 = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
917 &gather_stats_and_exit,
919 if (KEEPALIVE == test)
920 return; /* Don't send any data. */
922 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
923 "Sending data initializer...\n");
928 th = GNUNET_CADET_notify_transmit_ready (ch,
930 GNUNET_TIME_UNIT_FOREVER_REL,
932 &tmt_rdy, (void *) 0L);
937 * Callback to be called when the requested peer information is available
939 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
940 * @param op the operation this callback corresponds to
941 * @param pinfo the result; will be NULL if the operation has failed
942 * @param emsg error message if the operation has failed;
943 * NULL if the operation is successfull
947 struct GNUNET_TESTBED_Operation *op,
948 const struct GNUNET_TESTBED_PeerInformation *pinfo,
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
954 "id callback for %ld\n", i);
956 if ( (NULL == pinfo) ||
959 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
960 "pi_cb: %s\n", emsg);
961 abort_test (__LINE__);
964 p_id[i] = pinfo->result.id;
965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
966 " id: %s\n", GNUNET_i2s (p_id[i]));
970 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
971 "Got all IDs, starting test\n");
972 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
979 * test main: start test when all peers are connected
981 * @param cls Closure.
982 * @param ctx Argument to give to GNUNET_CADET_TEST_cleanup on test end.
983 * @param num_peers Number of peers that are running.
984 * @param peers Array of peers.
985 * @param cadetes Handle to each of the CADETs of the peers.
989 struct GNUNET_CADET_TEST_Context *ctx,
990 unsigned int num_peers,
991 struct GNUNET_TESTBED_Peer **peers,
992 struct GNUNET_CADET_Handle **cadets)
994 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
997 peers_running = num_peers;
998 GNUNET_assert (peers_running == peers_requested);
999 testbed_peers = peers;
1001 h2 = cadets[num_peers - 1];
1002 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
1003 &disconnect_cadet_peers,
1005 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
1006 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
1007 GNUNET_TESTBED_PIT_IDENTITY,
1008 &pi_cb, (void *) 0L);
1009 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
1010 GNUNET_TESTBED_PIT_IDENTITY,
1011 &pi_cb, (void *) 1L);
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
1020 main (int argc, char *argv[])
1022 initialized = GNUNET_NO;
1023 static const struct GNUNET_HashCode *ports[2];
1024 const char *config_file;
1025 char port_id[] = "test port";
1026 GNUNET_CRYPTO_hash (port_id, sizeof (port_id), &port);
1028 GNUNET_log_setup ("test", "DEBUG", NULL);
1029 config_file = "test_cadet.conf";
1031 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
1033 /* Find out requested size */
1034 if (strstr (argv[0], "_2_") != NULL)
1036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DIRECT CONNECTIONs\n");
1037 peers_requested = 2;
1039 else if (strstr (argv[0], "_5_") != NULL)
1041 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
1042 peers_requested = 5;
1046 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
1047 peers_requested = 2;
1050 /* Find out requested test */
1051 if (strstr (argv[0], "_forward") != NULL)
1053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
1055 test_name = "unicast";
1058 else if (strstr (argv[0], "_signal") != NULL)
1060 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
1062 test_name = "signal";
1065 else if (strstr (argv[0], "_speed_ack") != NULL)
1067 /* Test is supposed to generate the following callbacks:
1068 * 1 incoming channel (@dest)
1069 * TOTAL_PACKETS received data packet (@dest)
1070 * TOTAL_PACKETS received data packet (@orig)
1071 * 1 received channel destroy (@dest)
1073 ok_goal = TOTAL_PACKETS * 2 + 2;
1074 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
1076 test_name = "speed ack";
1078 else if (strstr (argv[0], "_speed") != NULL)
1080 /* Test is supposed to generate the following callbacks:
1081 * 1 incoming channel (@dest)
1082 * 1 initial packet (@dest)
1083 * TOTAL_PACKETS received data packet (@dest)
1084 * 1 received data packet (@orig)
1085 * 1 received channel destroy (@dest)
1087 ok_goal = TOTAL_PACKETS + 4;
1088 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
1089 if (strstr (argv[0], "_reliable") != NULL)
1092 test_name = "speed reliable";
1093 config_file = "test_cadet_drop.conf";
1098 test_name = "speed";
1101 else if (strstr (argv[0], "_keepalive") != NULL)
1104 /* Test is supposed to generate the following callbacks:
1105 * 1 incoming channel (@dest)
1107 * 1 received channel destroy (@dest)
1113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1118 if (strstr (argv[0], "backwards") != NULL)
1120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1121 test_backwards = GNUNET_YES;
1122 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1128 GNUNET_CADET_TEST_run ("test_cadet_small",
1132 NULL, /* tmain cls */
1140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1141 "FAILED! (%d/%d)\n", ok, ok_goal);
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1148 /* end of test_cadet.c */