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 ka_sent;
180 static unsigned int ka_received;
184 * Show the results of the test (banwidth acheived) and log them to GAUGER
189 static struct GNUNET_TIME_Absolute end_time;
190 static struct GNUNET_TIME_Relative total_time;
192 end_time = GNUNET_TIME_absolute_get();
193 total_time = GNUNET_TIME_absolute_get_difference(start_time, end_time);
194 FPRINTF (stderr, "\nResults of test \"%s\"\n", test_name);
195 FPRINTF (stderr, "Test time %s\n",
196 GNUNET_STRINGS_relative_time_to_string (total_time,
198 FPRINTF (stderr, "Test bandwidth: %f kb/s\n",
199 4 * TOTAL_PACKETS * 1.0 / (total_time.rel_value_us / 1000)); // 4bytes * ms
200 FPRINTF (stderr, "Test throughput: %f packets/s\n\n",
201 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000)); // packets * ms
202 GAUGER ("MESH", test_name,
203 TOTAL_PACKETS * 1000.0 / (total_time.rel_value_us / 1000),
209 * Shut down peergroup, clean up.
211 * @param cls Closure (unused).
212 * @param tc Task Context.
215 shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending test.\n");
218 shutdown_handle = GNUNET_SCHEDULER_NO_TASK;
223 * Disconnect from mesh services af all peers, call shutdown.
225 * @param cls Closure (unused).
226 * @param tc Task Context.
229 disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
231 long line = (long) cls;
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
235 "disconnecting mesh service of peers, called from line %ld\n",
237 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
238 for (i = 0; i < 2; i++)
240 GNUNET_TESTBED_operation_done (t_op[i]);
244 GNUNET_MESH_channel_destroy (ch);
247 if (NULL != incoming_ch)
249 GNUNET_MESH_channel_destroy (incoming_ch);
252 GNUNET_MESH_TEST_cleanup (test_ctx);
253 if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle)
255 GNUNET_SCHEDULER_cancel (shutdown_handle);
257 if (NULL != stats_get)
258 GNUNET_STATISTICS_get_cancel (stats_get);
259 shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
264 * Abort test: schedule disconnect and shutdown immediately
266 * @param line Line in the code the abort is requested from (__LINE__).
269 abort_test (long line)
271 if (disconnect_task != GNUNET_SCHEDULER_NO_TASK)
273 GNUNET_SCHEDULER_cancel (disconnect_task);
274 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
280 * Transmit ready callback.
282 * @param cls Closure (message type).
283 * @param size Size of the tranmist buffer.
284 * @param buf Pointer to the beginning of the buffer.
286 * @return Number of bytes written to buf.
289 tmt_rdy (void *cls, size_t size, void *buf);
293 * Task to schedule a new data transmission.
295 * @param cls Closure (peer #).
296 * @param tc Task Context.
299 data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
301 struct GNUNET_MESH_TransmitHandle *th;
302 struct GNUNET_MESH_Channel *channel;
304 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n");
308 if (GNUNET_YES == test_backwards)
310 channel = incoming_ch;
316 th = GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
317 GNUNET_TIME_UNIT_FOREVER_REL,
318 size_payload, &tmt_rdy, (void *) 1L);
321 unsigned long i = (unsigned long) cls;
323 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Retransmission\n");
326 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " in 1 ms\n");
327 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
328 &data_task, (void *)1UL);
333 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "in %u ms\n", i);
334 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
335 GNUNET_TIME_UNIT_MILLISECONDS,
337 &data_task, (void *)i);
344 * Transmit ready callback
346 * @param cls Closure (message type).
347 * @param size Size of the buffer we have.
348 * @param buf Buffer to copy data to.
351 tmt_rdy (void *cls, size_t size, void *buf)
353 struct GNUNET_MessageHeader *msg = buf;
356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
357 "tmt_rdy called, filling buffer\n");
358 if (size < size_payload || NULL == buf)
360 GNUNET_break (ok >= ok_goal - 2);
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
362 "size %u, buf %p, data_sent %u, data_received %u\n",
363 size, buf, data_sent, data_received);
364 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ok %u, ok goal %u\n", ok, ok_goal);
368 msg->size = htons (size);
369 msg->type = htons ((long) cls);
370 data = (uint32_t *) &msg[1];
371 *data = htonl (data_sent);
372 if (GNUNET_NO == initialized)
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
375 "sending initializer\n");
377 else if (SPEED == test)
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
381 " Sent packet %d\n", data_sent);
382 if (data_sent < TOTAL_PACKETS)
384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
385 " Scheduling packet %d\n", data_sent + 1);
386 GNUNET_SCHEDULER_add_now (&data_task, NULL);
395 * Function is called whenever a message is received.
397 * @param cls closure (set from GNUNET_MESH_connect)
398 * @param channel connection to the other end
399 * @param channel_ctx place to store local state associated with the channel
400 * @param message the actual message
401 * @return GNUNET_OK to keep the connection open,
402 * GNUNET_SYSERR to close it (signal serious error)
405 data_callback (void *cls, struct GNUNET_MESH_Channel *channel,
407 const struct GNUNET_MessageHeader *message)
409 long client = (long) cls;
410 long expected_target_client;
415 GNUNET_MESH_receive_done (channel);
419 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
421 GNUNET_SCHEDULER_cancel (disconnect_task);
422 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
423 &disconnect_mesh_peers,
431 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Root client got a message!\n");
434 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
435 "Leaf client %li got a message.\n",
442 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: (%d/%d)\n", ok, ok_goal);
443 data = (uint32_t *) &message[1];
444 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " payload: (%u)\n", ntohl (*data));
445 if (SPEED == test && GNUNET_YES == test_backwards)
447 expected_target_client = 0L;
451 expected_target_client = 4L;
454 if (GNUNET_NO == initialized)
456 initialized = GNUNET_YES;
457 start_time = GNUNET_TIME_absolute_get ();
460 GNUNET_assert (4L == client);
461 GNUNET_SCHEDULER_add_now (&data_task, NULL);
466 if (client == expected_target_client) // Normally 4
469 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received data %u\n", data_received);
470 if (SPEED != test || (ok_goal - 2) == ok)
472 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
473 GNUNET_TIME_UNIT_FOREVER_REL,
474 size_payload, &tmt_rdy, (void *) 1L);
479 if (data_received < TOTAL_PACKETS)
485 if (test == SPEED_ACK || test == SPEED)
488 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " received ack %u\n", data_ack);
489 GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO,
490 GNUNET_TIME_UNIT_FOREVER_REL,
491 size_payload, &tmt_rdy, (void *) 1L);
492 if (data_ack < TOTAL_PACKETS && SPEED != test)
494 if (ok == 2 && SPEED == test)
498 if (test == P2P_SIGNAL)
500 GNUNET_MESH_channel_destroy (incoming_ch);
505 GNUNET_MESH_channel_destroy (ch);
510 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
512 GNUNET_SCHEDULER_cancel (disconnect_task);
513 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
514 &disconnect_mesh_peers,
523 * Adapter function called to establish a connection to the statistics service.
526 * @param cfg configuration of the peer to connect to; will be available until
527 * GNUNET_TESTBED_operation_done() is called on the operation returned
528 * from GNUNET_TESTBED_service_connect()
529 * @return service handle to return in 'op_result', NULL on error
532 stats_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
534 return GNUNET_STATISTICS_create ("<test_mesh>", cfg);
539 * Adapter function called to destroy a connection to
540 * statistics service.
542 * @param cls Closure (unused).
543 * @param op_result service handle returned from the connect adapter
546 stats_da (void *cls, void *op_result)
548 GNUNET_assert (op_result == stats);
549 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
555 * Function called by testbed once we are connected to stats
556 * service. Get the statistics of interest.
558 * @param cls Closure (unused).
559 * @param op connect operation handle
560 * @param ca_result handle to stats service
561 * @param emsg error message on failure
564 stats_connect_cb (void *cls,
565 struct GNUNET_TESTBED_Operation *op,
570 * Stats callback. Finish the stats testbed operation and when all stats have
571 * been iterated, shutdown the test.
574 * @param success GNUNET_OK if statistics were
575 * successfully obtained, GNUNET_SYSERR if not.
578 stats_cont (void *cls, int success)
580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stats_cont for peer %u\n", cls);
581 GNUNET_TESTBED_operation_done (stats_op);
585 stats_op = GNUNET_TESTBED_service_connect (NULL,
596 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
597 GNUNET_SCHEDULER_cancel (disconnect_task);
598 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
605 * Process statistic values.
608 * @param subsystem name of subsystem that created the statistic
609 * @param name the name of the datum
610 * @param value the current value
611 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
612 * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration
615 stats_iterator (void *cls, const char *subsystem, const char *name,
616 uint64_t value, int is_persistent)
618 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " %u - %s [%s]: %llu\n",
619 cls, subsystem, name, value);
620 if (0 == strncmp("# keepalives sent", name,
621 strlen("# keepalives sent"))
625 if (0 == strncmp("# keepalives received", name,
626 strlen ("# keepalives received"))
630 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " sent: %u, received: %u\n",
631 ka_sent, ka_received);
632 if (ka_sent < 2 || ka_sent > ka_received + 1)
641 * Function called by testbed once we are connected to stats
642 * service. Get the statistics of interest.
644 * @param cls Closure (unused).
645 * @param op connect operation handle
646 * @param ca_result handle to stats service
647 * @param emsg error message on failure
650 stats_connect_cb (void *cls,
651 struct GNUNET_TESTBED_Operation *op,
655 if (NULL == ca_result || NULL != emsg)
657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
658 "Failed to connect to statistics service: %s\n", emsg);
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "stats for peer %u\n", cls);
665 stats_get = GNUNET_STATISTICS_get (stats, "mesh", NULL,
666 GNUNET_TIME_UNIT_FOREVER_REL,
667 &stats_cont, &stats_iterator, cls);
668 if (NULL == stats_get)
670 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
671 "Could not get statistics of peer %u!\n", cls);
677 * Task check that keepalives were sent and received.
679 * @param cls Closure (NULL).
680 * @param tc Task Context.
683 check_keepalives (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
685 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
688 disconnect_task = GNUNET_SCHEDULER_NO_TASK;
689 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "check keepalives\n");
690 GNUNET_MESH_channel_destroy (ch);
691 stats_op = GNUNET_TESTBED_service_connect (NULL,
703 * Handlers, for diverse services
705 static struct GNUNET_MESH_MessageHandler handlers[] = {
706 {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
712 * Method called whenever another peer has added us to a channel
713 * the other peer initiated.
715 * @param cls Closure.
716 * @param channel New handle to the channel.
717 * @param initiator Peer that started the channel.
718 * @param port Port this channel is connected to.
719 * @param options channel option flags
720 * @return Initial channel context for the channel
721 * (can be NULL -- that's not an error).
724 incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel,
725 const struct GNUNET_PeerIdentity *initiator,
726 uint32_t port, enum GNUNET_MESH_ChannelOption options)
728 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
729 "Incoming channel from %s to peer %d\n",
730 GNUNET_i2s (initiator), (long) cls);
732 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
733 if ((long) cls == 4L)
734 incoming_ch = channel;
737 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
738 "Incoming channel for unknown client %lu\n", (long) cls);
741 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
743 GNUNET_SCHEDULER_cancel (disconnect_task);
744 if (KEEPALIVE == test)
746 struct GNUNET_TIME_Relative delay;
747 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS , 5);
749 GNUNET_SCHEDULER_add_delayed (delay, &check_keepalives, NULL);
752 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
753 &disconnect_mesh_peers,
761 * Function called whenever an inbound channel is destroyed. Should clean up
762 * any associated state.
764 * @param cls closure (set from GNUNET_MESH_connect)
765 * @param channel connection to the other end (henceforth invalid)
766 * @param channel_ctx place where local state associated
767 * with the channel is stored
770 channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel,
775 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
776 "Incoming channel disconnected at peer %d\n",
781 GNUNET_break (channel == incoming_ch);
786 if (P2P_SIGNAL == test)
790 GNUNET_break (channel == ch);
794 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
795 "Unknown peer! %d\n", i);
796 GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok);
798 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
800 GNUNET_SCHEDULER_cancel (disconnect_task);
801 disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_mesh_peers,
810 * START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE MESH SERVICES.
812 * Testcase continues when the root receives confirmation of connected peers,
813 * on callback funtion ch.
815 * @param cls Closure (unsued).
816 * @param tc Task Context.
819 do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
821 enum GNUNET_MESH_ChannelOption flags;
823 if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0)
826 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test_task\n");
828 if (GNUNET_SCHEDULER_NO_TASK != disconnect_task)
830 GNUNET_SCHEDULER_cancel (disconnect_task);
833 flags = GNUNET_MESH_OPTION_DEFAULT;
834 if (SPEED_REL == test)
837 flags |= GNUNET_MESH_OPTION_RELIABLE;
839 ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, flags);
841 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
842 &disconnect_mesh_peers,
844 if (KEEPALIVE == test)
845 return; /* Don't send any data. */
847 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
848 "Sending data initializer...\n");
852 GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO,
853 GNUNET_TIME_UNIT_FOREVER_REL,
854 size_payload, &tmt_rdy, (void *) 1L);
858 * Callback to be called when the requested peer information is available
860 * @param cls the closure from GNUNET_TESTBED_peer_get_information()
861 * @param op the operation this callback corresponds to
862 * @param pinfo the result; will be NULL if the operation has failed
863 * @param emsg error message if the operation has failed;
864 * NULL if the operation is successfull
868 struct GNUNET_TESTBED_Operation *op,
869 const struct GNUNET_TESTBED_PeerInformation *pinfo,
874 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "id callback for %ld\n", i);
876 if (NULL == pinfo || NULL != emsg)
878 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "pi_cb: %s\n", emsg);
879 abort_test (__LINE__);
882 p_id[i] = pinfo->result.id;
883 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " id: %s\n", GNUNET_i2s (p_id[i]));
887 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got all IDs, starting test\n");
888 test_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
893 * test main: start test when all peers are connected
895 * @param cls Closure.
896 * @param ctx Argument to give to GNUNET_MESH_TEST_cleanup on test end.
897 * @param num_peers Number of peers that are running.
898 * @param peers Array of peers.
899 * @param meshes Handle to each of the MESHs of the peers.
903 struct GNUNET_MESH_TEST_Context *ctx,
904 unsigned int num_peers,
905 struct GNUNET_TESTBED_Peer **peers,
906 struct GNUNET_MESH_Handle **meshes)
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test main\n");
911 peers_running = num_peers;
912 testbed_peers = peers;
914 h2 = meshes[num_peers - 1];
915 disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
916 &disconnect_mesh_peers,
918 shutdown_handle = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
919 &shutdown_task, NULL);
920 t_op[0] = GNUNET_TESTBED_peer_get_information (peers[0],
921 GNUNET_TESTBED_PIT_IDENTITY,
922 &pi_cb, (void *) 0L);
923 t_op[1] = GNUNET_TESTBED_peer_get_information (peers[num_peers - 1],
924 GNUNET_TESTBED_PIT_IDENTITY,
925 &pi_cb, (void *) 1L);
926 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "requested peer ids\n");
934 main (int argc, char *argv[])
936 initialized = GNUNET_NO;
938 const char *config_file;
940 GNUNET_log_setup ("test", "DEBUG", NULL);
941 config_file = "test_mesh.conf";
943 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Start\n");
944 if (strstr (argv[0], "_small_forward") != NULL)
946 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "FORWARD\n");
948 test_name = "unicast";
951 else if (strstr (argv[0], "_small_signal") != NULL)
953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SIGNAL\n");
955 test_name = "signal";
958 else if (strstr (argv[0], "_small_speed_ack") != NULL)
960 /* Test is supposed to generate the following callbacks:
961 * 1 incoming channel (@dest)
962 * TOTAL_PACKETS received data packet (@dest)
963 * TOTAL_PACKETS received data packet (@orig)
964 * 1 received channel destroy (@dest)
966 ok_goal = TOTAL_PACKETS * 2 + 2;
967 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED_ACK\n");
969 test_name = "speed ack";
971 else if (strstr (argv[0], "_small_speed") != NULL)
973 /* Test is supposed to generate the following callbacks:
974 * 1 incoming channel (@dest)
975 * 1 initial packet (@dest)
976 * TOTAL_PACKETS received data packet (@dest)
977 * 1 received data packet (@orig)
978 * 1 received channel destroy (@dest)
980 ok_goal = TOTAL_PACKETS + 4;
981 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n");
982 if (strstr (argv[0], "_reliable") != NULL)
985 test_name = "speed reliable";
986 config_file = "test_mesh_drop.conf";
994 else if (strstr (argv[0], "_keepalive") != NULL)
997 /* Test is supposed to generate the following callbacks:
998 * 1 incoming channel (@dest)
1000 * 1 received channel destroy (@dest)
1006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
1011 if (strstr (argv[0], "backwards") != NULL)
1013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "BACKWARDS (LEAF TO ROOT)\n");
1014 test_backwards = GNUNET_YES;
1015 GNUNET_asprintf (&test_name, "backwards %s", test_name);
1021 GNUNET_MESH_TEST_run ("test_mesh_small",
1025 NULL, /* tmain cls */
1033 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1034 "FAILED! (%d/%d)\n", ok, ok_goal);
1037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "success\n");
1041 /* end of test_mesh_small.c */