2 This file is part of GNUnet.
3 Copyright (C) 2009, 2010, 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
16 * @file transport/test_transport_testing_startstop.c
17 * @brief test case for transport testing library:
18 * start the peer, get the HELLO message and stop the peer
21 #include "gnunet_transport_service.h"
22 #include "transport-testing.h"
24 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
27 static struct GNUNET_SCHEDULER_Task *timeout_task;
29 static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
31 static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
39 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
41 if (NULL != timeout_task)
42 GNUNET_SCHEDULER_cancel (timeout_task);
44 GNUNET_TRANSPORT_TESTING_stop_peer (p);
46 GNUNET_TRANSPORT_TESTING_done (tth);
54 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
64 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
65 "Peer %u (`%s') successfully started\n",
69 GNUNET_SCHEDULER_add_now (&end,
78 const struct GNUNET_CONFIGURATION_Handle *cfg)
81 tth = GNUNET_TRANSPORT_TESTING_init ();
82 GNUNET_assert (NULL != tth);
85 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
89 p = GNUNET_TRANSPORT_TESTING_start_peer (tth,
92 NULL, /* receive cb */
93 NULL, /* connect cb */
94 NULL, /* disconnect cb */
95 NULL, /* nc/nd closure */
96 &start_cb, /* startup cb */
100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to start peer\n");
101 if (timeout_task != NULL)
102 GNUNET_SCHEDULER_cancel (timeout_task);
103 timeout_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
109 main (int argc, char *argv[])
111 char *const argv_1[] = { "test_transport_testing",
113 "test_transport_api_data.conf",
116 struct GNUNET_GETOPT_CommandLineOption options[] = {
117 GNUNET_GETOPT_OPTION_END
120 GNUNET_log_setup ("test_transport_testing_startstop",
123 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1,
125 "test_transport_testing_startstop", "nohelp",
133 /* end of test_transport_testing_startstop.c */