2 This file is part of GNUnet.
3 (C) 2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file mesh/test_mesh_small.c
23 * @brief Test for the mesh service: retransmission of traffic.
27 #include "mesh_test_lib.h"
28 #include "gnunet_mesh_service.h"
29 #include "gnunet_statistics_service.h"
34 * How namy messages to send
36 #define TOTAL_PACKETS 1000
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, 60)
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 explicitly (app level) acknowledged
125 * Total number of currently running peers.
127 static unsigned long long peers_running;
130 * Test context (to shut down).
132 struct GNUNET_MESH_TEST_Context *test_ctx;
135 * Task called to disconnect peers.
137 static GNUNET_SCHEDULER_TaskIdentifier disconnect_task;
140 * Task To perform tests
142 static GNUNET_SCHEDULER_TaskIdentifier test_task;
145 * Task called to shutdown test.
147 static GNUNET_SCHEDULER_TaskIdentifier shutdown_handle;
150 * Mesh handle for the root peer
152 static struct GNUNET_MESH_Handle *h1;
155 * Mesh handle for the first leaf peer
157 static struct GNUNET_MESH_Handle *h2;
160 * Channel handle for the root peer
162 static struct GNUNET_MESH_Channel *ch;
165 * Channel handle for the dest peer
167 static struct GNUNET_MESH_Channel *incoming_ch;
170 * Time we started the data transmission (after channel has been established
173 static struct GNUNET_TIME_Absolute start_time;
175 static struct GNUNET_TESTBED_Peer **testbed_peers;
176 static struct GNUNET_STATISTICS_Handle *stats;
177 static struct GNUNET_STATISTICS_GetHandle *stats_get;
178 static struct GNUNET_TESTBED_Operation *stats_op;
179 static unsigned int stats_peer;
180 static unsigned int ka_sent;
181 static unsigned int ka_received;
185 * Show the results of the test (banwidth acheived) and log them to GAUGER
190 static struct GNUNET_TIME_Absolute end_time;
191 static struct GNUNET_TIME_Relative total_time;
193 end_time = GNUNET_TIME_absolute_get();
194 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
195 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
196 FPRINTF (stderr, "Test time %s\n",
197 GNUNET_STRINGS_relative_time_to_string (total_time,
199 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
200 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
201 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
202 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
203 GAUGER ("MESH", test_name,
204 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
210 * Shut down peergroup, clean up.
212 * @param cls Closure (unused).
213 * @param tc Task Context.
216 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
219 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
224 * Disconnect from mesh services af all peers, call shutdown.
226 * @param cls Closure (unused).
227 * @param tc Task Context.
230 disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
232 long line = (long) cls;
235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
236 "disconnecting mesh service of peers, called from line %ld\n",
238 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
239 for (i = 0; i < 2; i++)
241 GNUNET_TESTBED_operation_done (t_op[i]);
245 GNUNET_MESH_channel_destroy (ch);
248 if (NULL != incoming_ch)
250 GNUNET_MESH_channel_destroy (incoming_ch);
253 GNUNET_MESH_TEST_cleanup (test_ctx);
254 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
256 GNUNET_SCHEDULER_cancel (shutdown_handle);
258 if (NULL != stats_get)
259 GNUNET_STATISTICS_get_cancel (stats_get);
260 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
265 * Abort test: schedule disconnect and shutdown immediately
267 * @param line Line in the code the abort is requested from (__LINE__).
270 abort_test (long line)
272 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
274 GNUNET_SCHEDULER_cancel (disconnect_task);
275 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
281 * Transmit ready callback.
283 * @param cls Closure (message type).
284 * @param size Size of the tranmist buffer.
285 * @param buf Pointer to the beginning of the buffer.
287 * @return Number of bytes written to buf.
290 tmt_rdy (void *cls, size_t size, void *buf);
294 * Task to schedule a new data transmission.
296 * @param cls Closure (peer #).
297 * @param tc Task Context.
300 data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
302 struct GNUNET_MESH_TransmitHandle *th;
303 struct GNUNET_MESH_Channel *channel;
305 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
308 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
309 if (GNUNET_YES == test_backwards)
311 channel = incoming_ch;
317 th = GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
318 GNUNET_TIME_UNIT_FOREVER_REL,
319 size_payload, &tmt_rdy, (void *) 1L);
322 unsigned long i = (unsigned long) cls;
324 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retransmission\n");
327 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " in 1 ms\n");
328 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
329 &data_task, (void *)1UL);
334 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "in %u ms\n", i);
335 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
336 GNUNET_TIME_UNIT_MILLISECONDS,
338 &data_task, (void *)i);
345 * Transmit ready callback
347 * @param cls Closure (message type).
348 * @param size Size of the buffer we have.
349 * @param buf Buffer to copy data to.
352 tmt_rdy (void *cls, size_t size, void *buf)
354 struct GNUNET_MessageHeader *msg = buf;
357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
358 "tmt_rdy called, filling buffer\n");
359 if (size < size_payload || NULL == buf)
361 GNUNET_break (ok >= ok_goal - 2);
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "size %u, buf %p, data_sent %u, data_received %u\n",
364 size, buf, data_sent, data_received);
365 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
369 msg->size = htons (size);
370 msg->type = htons ((long) cls);
371 data = (uint32_t *) &msg[1];
372 *data = htonl (data_sent);
373 if (GNUNET_NO == initialized)
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
376 "sending initializer\n");
378 else if (SPEED == test)
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 " Sent packet %d\n", data_sent);
383 if (data_sent < TOTAL_PACKETS)
385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
386 " Scheduling packet %d\n", data_sent + 1);
387 GNUNET_SCHEDULER_add_now (&data_task, NULL);
396 * Function is called whenever a message is received.
398 * @param cls closure (set from GNUNET_MESH_connect)
399 * @param channel connection to the other end
400 * @param channel_ctx place to store local state associated with the channel
401 * @param message the actual message
402 * @return GNUNET_OK to keep the connection open,
403 * GNUNET_SYSERR to close it (signal serious error)
406 data_callback (void *cls, struct GNUNET_MESH_Channel *channel,
408 const struct GNUNET_MessageHeader *message)
410 long client = (long) cls;
411 long expected_target_client;
416 GNUNET_MESH_receive_done (channel);
420 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
422 GNUNET_SCHEDULER_cancel (disconnect_task);
423 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
424 &disconnect_mesh_peers,
432 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
435 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
436 "Leaf client %li got a message.\n",
443 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
444 data = (uint32_t *) &message[1];
445 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: (%u)\n", ntohl (*data));
446 if (SPEED == test && GNUNET_YES == test_backwards)
448 expected_target_client = 0L;
452 expected_target_client = 4L;
455 if (GNUNET_NO == initialized)
457 initialized = GNUNET_YES;
458 start_time = GNUNET_TIME_absolute_get ();
461 GNUNET_assert (4L == client);
462 GNUNET_SCHEDULER_add_now (&data_task, NULL);
467 if (client == expected_target_client) // Normally 4
470 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
471 if (SPEED != test || (ok_goal - 2) == ok)
473 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
474 GNUNET_TIME_UNIT_FOREVER_REL,
475 size_payload, &tmt_rdy, (void *) 1L);
480 if (data_received < TOTAL_PACKETS)
486 if (test == SPEED_ACK || test == SPEED)
489 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", data_ack);
490 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
491 GNUNET_TIME_UNIT_FOREVER_REL,
492 size_payload, &tmt_rdy, (void *) 1L);
493 if (data_ack < TOTAL_PACKETS && SPEED != test)
495 if (ok == 2 && SPEED == test)
499 if (test == P2P_SIGNAL)
501 GNUNET_MESH_channel_destroy (incoming_ch);
506 GNUNET_MESH_channel_destroy (ch);
511 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
513 GNUNET_SCHEDULER_cancel (disconnect_task);
514 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
515 &disconnect_mesh_peers,
524 * Adapter function called to establish a connection to the statistics service.
527 * @param cfg configuration of the peer to connect to; will be available until
528 * GNUNET_TESTBED_operation_done() is called on the operation returned
529 * from GNUNET_TESTBED_service_connect()
530 * @return service handle to return in 'op_result', NULL on error
533 stats_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
535 return GNUNET_STATISTICS_create ("<test_mesh>", cfg);
540 * Adapter function called to destroy a connection to
541 * statistics service.
543 * @param cls Closure (unused).
544 * @param op_result service handle returned from the connect adapter
547 stats_da (void *cls, void *op_result)
549 GNUNET_assert (op_result == stats);
550 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
556 * Function called by testbed once we are connected to stats
557 * service. Get the statistics of interest.
559 * @param cls Closure (unused).
560 * @param op connect operation handle
561 * @param ca_result handle to stats service
562 * @param emsg error message on failure
565 stats_connect_cb (void *cls,
566 struct GNUNET_TESTBED_Operation *op,
571 * Stats callback. Finish the stats testbed operation and when all stats have
572 * been iterated, shutdown the test.
575 * @param success GNUNET_OK if statistics were
576 * successfully obtained, GNUNET_SYSERR if not.
579 stats_cont (void *cls, int success)
581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stats_cont for peer %u\n", cls);
582 GNUNET_TESTBED_operation_done (stats_op);
586 stats_op = GNUNET_TESTBED_service_connect (NULL,
597 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
598 GNUNET_SCHEDULER_cancel (disconnect_task);
599 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
606 * Process statistic values.
609 * @param subsystem name of subsystem that created the statistic
610 * @param name the name of the datum
611 * @param value the current value
612 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
613 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
616 stats_iterator (void *cls, const char *subsystem, const char *name,
617 uint64_t value, int is_persistent)
619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u - %s [%s]: %llu\n",
620 cls, subsystem, name, value);
621 if (0 == strncmp("# keepalives sent", name,
622 strlen("# keepalives sent"))
626 if (0 == strncmp("# keepalives received", name,
627 strlen ("# keepalives received"))
631 if (ka_sent < 2 || ka_sent > ka_received + 1)
640 * Function called by testbed once we are connected to stats
641 * service. Get the statistics of interest.
643 * @param cls Closure (unused).
644 * @param op connect operation handle
645 * @param ca_result handle to stats service
646 * @param emsg error message on failure
649 stats_connect_cb (void *cls,
650 struct GNUNET_TESTBED_Operation *op,
654 if (NULL == ca_result || NULL != emsg)
656 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
657 "Failed to connect to statistics service: %s\n", emsg);
661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stats for peer %u\n", cls);
664 stats_get = GNUNET_STATISTICS_get (stats, "mesh", NULL,
665 GNUNET_TIME_UNIT_FOREVER_REL,
666 &stats_cont, &stats_iterator, cls);
667 if (NULL == stats_get)
669 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
670 "Could not get statistics of peer %u!\n", cls);
676 * Task check that keepalives were sent and received.
678 * @param cls Closure (NULL).
679 * @param tc Task Context.
682 check_keepalives (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
684 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
687 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
688 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "check keepalives\n");
689 GNUNET_MESH_channel_destroy (ch);
690 stats_op = GNUNET_TESTBED_service_connect (NULL,
702 * Handlers, for diverse services
704 static struct GNUNET_MESH_MessageHandler handlers[] = {
705 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
711 * Method called whenever another peer has added us to a channel
712 * the other peer initiated.
714 * @param cls Closure.
715 * @param channel New handle to the channel.
716 * @param initiator Peer that started the channel.
717 * @param port Port this channel is connected to.
718 * @param options channel option flags
719 * @return Initial channel context for the channel
720 * (can be NULL -- that's not an error).
723 incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
724 const struct GNUNET_PeerIdentity *initiator,
725 uint32_t port, enum GNUNET_MESH_ChannelOption options)
727 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
728 "Incoming channel from %s to peer %d\n",
729 GNUNET_i2s (initiator), (long) cls);
731 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
732 if ((long) cls == 4L)
733 incoming_ch = channel;
736 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
737 "Incoming channel for unknown client %lu\n", (long) cls);
740 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
742 GNUNET_SCHEDULER_cancel (disconnect_task);
743 if (KEEPALIVE == test)
745 struct GNUNET_TIME_Relative delay;
746 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS , 5);
748 GNUNET_SCHEDULER_add_delayed (delay, &check_keepalives, NULL);
751 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
752 &disconnect_mesh_peers,
760 * Function called whenever an inbound channel is destroyed. Should clean up
761 * any associated state.
763 * @param cls closure (set from GNUNET_MESH_connect)
764 * @param channel connection to the other end (henceforth invalid)
765 * @param channel_ctx place where local state associated
766 * with the channel is stored
769 channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel,
774 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
775 "Incoming channel disconnected at peer %d\n",
780 GNUNET_break (channel == incoming_ch);
785 if (P2P_SIGNAL == test)
789 GNUNET_break (channel == ch);
793 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
794 "Unknown peer! %d\n", i);
795 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
797 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
799 GNUNET_SCHEDULER_cancel (disconnect_task);
800 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
809 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
811 * Testcase continues when the root receives confirmation of connected peers,
812 * on callback funtion ch.
814 * @param cls Closure (unsued).
815 * @param tc Task Context.
818 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
820 enum GNUNET_MESH_ChannelOption flags;
822 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
825 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
827 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
829 GNUNET_SCHEDULER_cancel (disconnect_task);
832 flags = GNUNET_MESH_OPTION_DEFAULT;
833 if (SPEED_REL == test)
836 flags |= GNUNET_MESH_OPTION_RELIABLE;
838 ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, flags);
840 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
841 &disconnect_mesh_peers,
843 if (KEEPALIVE == test)
844 return; /* Don't send any data. */
846 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
847 "Sending data initializer...\n");
851 GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO,
852 GNUNET_TIME_UNIT_FOREVER_REL,
853 size_payload, &tmt_rdy, (void *) 1L);
857 * Callback to be called when the requested peer information is available
859 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
860 * @param op the operation this callback corresponds to
861 * @param pinfo the result; will be NULL if the operation has failed
862 * @param emsg error message if the operation has failed;
863 * NULL if the operation is successfull
867 struct GNUNET_TESTBED_Operation *op,
868 const struct GNUNET_TESTBED_PeerInformation *pinfo,
873 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
875 if (NULL == pinfo || NULL != emsg)
877 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
878 abort_test (__LINE__);
881 p_id[i] = pinfo->result.id;
882 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
886 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
887 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
892 * test main: start test when all peers are connected
894 * @param cls Closure.
895 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
896 * @param num_peers Number of peers that are running.
897 * @param peers Array of peers.
898 * @param meshes Handle to each of the MESHs of the peers.
902 struct GNUNET_MESH_TEST_Context *ctx,
903 unsigned int num_peers,
904 struct GNUNET_TESTBED_Peer **peers,
905 struct GNUNET_MESH_Handle **meshes)
907 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
910 peers_running = num_peers;
911 testbed_peers = peers;
913 h2 = meshes[num_peers - 1];
914 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
915 &disconnect_mesh_peers,
917 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
918 &shutdown_task, NULL);
919 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
920 GNUNET_TESTBED_PIT_IDENTITY,
921 &pi_cb, (void *) 0L);
922 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
923 GNUNET_TESTBED_PIT_IDENTITY,
924 &pi_cb, (void *) 1L);
925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
933 main (int argc, char *argv[])
935 initialized = GNUNET_NO;
937 const char *config_file;
939 GNUNET_log_setup ("test", "DEBUG", NULL);
940 config_file = "test_mesh.conf";
942 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
943 if (strstr (argv[0], "_small_forward") != NULL)
945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
947 test_name = "unicast";
950 else if (strstr (argv[0], "_small_signal") != NULL)
952 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
954 test_name = "signal";
957 else if (strstr (argv[0], "_small_speed_ack") != NULL)
959 /* Test is supposed to generate the following callbacks:
960 * 1 incoming channel (@dest)
961 * TOTAL_PACKETS received data packet (@dest)
962 * TOTAL_PACKETS received data packet (@orig)
963 * 1 received channel destroy (@dest)
965 ok_goal = TOTAL_PACKETS * 2 + 2;
966 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
968 test_name = "speed ack";
970 else if (strstr (argv[0], "_small_speed") != NULL)
972 /* Test is supposed to generate the following callbacks:
973 * 1 incoming channel (@dest)
974 * 1 initial packet (@dest)
975 * TOTAL_PACKETS received data packet (@dest)
976 * 1 received data packet (@orig)
977 * 1 received channel destroy (@dest)
979 ok_goal = TOTAL_PACKETS + 4;
980 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
981 if (strstr (argv[0], "_reliable") != NULL)
984 test_name = "speed reliable";
985 config_file = "test_mesh_drop.conf";
993 else if (strstr (argv[0], "_keepalive") != NULL)
996 /* Test is supposed to generate the following callbacks:
997 * 1 incoming channel (@dest)
999 * 1 received channel destroy (@dest)
1005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1010 if (strstr (argv[0], "backwards") != NULL)
1012 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1013 test_backwards = GNUNET_YES;
1014 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1020 GNUNET_MESH_TEST_run ("test_mesh_small",
1024 NULL, /* tmain cls */
1032 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1033 "FAILED! (%d/%d)\n", ok, ok_goal);
1036 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1040 /* end of test_mesh_small.c */