2 This file is part of GNUnet.
3 (C) 2009, 2010 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 transport/test_transport_api.c
22 * @brief base test case for transport implementations
24 * This test case serves as a base for tcp, udp, and udp-nat
25 * transport test cases. Based on the executable being run
26 * the correct test case will be performed. Conservation of
30 #include "gnunet_common.h"
31 #include "gnunet_hello_lib.h"
32 #include "gnunet_getopt_lib.h"
33 #include "gnunet_os_lib.h"
34 #include "gnunet_program_lib.h"
35 #include "gnunet_scheduler_lib.h"
36 #include "gnunet_transport_service.h"
37 #include "transport.h"
38 #include "transport-testing.h"
40 #define VERBOSE GNUNET_NO
42 #define VERBOSE_ARM GNUNET_NO
44 #define START_ARM GNUNET_YES
47 * How long until we give up on transmitting the message?
49 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
51 static struct PeerContext * p;
54 notify_connect (void *cls,
55 const struct GNUNET_PeerIdentity *peer,
56 const struct GNUNET_TRANSPORT_ATS_Information *ats,
59 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' connected \n",
64 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' disconnected \n",
71 notify_receive (void *cls,
72 const struct GNUNET_PeerIdentity *peer,
73 const struct GNUNET_MessageHeader *message,
74 const struct GNUNET_TRANSPORT_ATS_Information *ats,
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving\n");
84 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting peer\n");
87 p = GNUNET_TRANSPORT_TESTING_start_peer("test_quota_compliance_tcp_peer1.conf");
90 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer was successfully started\n");
92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer was not started successfully\n");
93 GNUNET_assert (p != NULL);
96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tConnecting to transport service\n");
97 GNUNET_assert (p->th == NULL);
98 p->th = GNUNET_TRANSPORT_connect(p->cfg, NULL,
103 GNUNET_assert (p->th != NULL);
105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\tDisconnecting to transport service\n");
106 GNUNET_TRANSPORT_disconnect(p->th);
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer\n");
109 GNUNET_TRANSPORT_TESTING_stop_peer(p);
115 main (int argc, char *argv[])
119 GNUNET_log_setup ("test_transport_testing",
127 char *const argv_1[] = { "test_transport_testing",
129 "test_transport_api_data.conf",
136 struct GNUNET_GETOPT_CommandLineOption options[] = {
137 GNUNET_GETOPT_OPTION_END
140 GNUNET_PROGRAM_run ((sizeof (argv_1) / sizeof (char *)) - 1,
141 argv_1, "test_transport_testing", "nohelp",
142 options, &run, &ret);
147 /* end of test_transport_api.c */