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.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file transport/test_transport_testing_restart.c
20 * @brief test case for transport testing library:
21 * start the peer, get the HELLO message, restart and stop the peer
24 #include "gnunet_transport_service.h"
25 #include "transport-testing.h"
27 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
30 static struct GNUNET_SCHEDULER_Task *timeout_task;
32 static struct GNUNET_TRANSPORT_TESTING_PeerContext *p;
34 static struct GNUNET_TRANSPORT_TESTING_Handle *tth;
42 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
44 if (NULL != timeout_task)
45 GNUNET_SCHEDULER_cancel (timeout_task);
47 GNUNET_TRANSPORT_TESTING_stop_peer (p);
49 GNUNET_TRANSPORT_TESTING_done (tth);
57 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
65 restart_cb (void *cls)
67 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
68 "Peer %u (`%s') successfully restarted\n",
72 GNUNET_SCHEDULER_add_now (&end,
80 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
81 "Peer %u (`%s') restarting\n",
84 GNUNET_TRANSPORT_TESTING_restart_peer (p,
93 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
94 "Peer %u (`%s') successfully started\n",
97 GNUNET_SCHEDULER_add_now (&restart_task,
106 const struct GNUNET_CONFIGURATION_Handle *cfg)
109 tth = GNUNET_TRANSPORT_TESTING_init ();
110 GNUNET_assert (NULL != tth);
113 = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
116 p = GNUNET_TRANSPORT_TESTING_start_peer(tth,
119 NULL, /* receive cb */
120 NULL, /* connect cb */
121 NULL, /* disconnect cb */
122 NULL, /* nc/nd closure */
123 start_cb, /* startup cb */
127 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
128 "Failed to start peer\n");
139 char *const argv_1[] = { "test_transport_testing_restart",
141 "test_transport_api_data.conf",
144 struct GNUNET_GETOPT_CommandLineOption options[] = {
145 GNUNET_GETOPT_OPTION_END
148 GNUNET_log_setup ("test_transport_testing_restart",
151 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1,
153 "test_transport_testing_restart",
161 /* end of test_transport_testing_restart.c */