2 This file is part of GNUnet
3 Copyright (C) 2008, 2009, 2012 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/>.
20 * @file testing/test_testing_new_portreservation.c
21 * @brief test case for testing port reservation routines from the new testing
23 * @author Sree Harsha Totakura
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testing_lib.h"
30 #define LOG(kind,...) \
31 GNUNET_log (kind, __VA_ARGS__)
34 * The status of the test
39 * Main point of test execution
42 run (void *cls, char *const *args, const char *cfgfile,
43 const struct GNUNET_CONFIGURATION_Handle *cfg)
45 struct GNUNET_TESTING_System *system;
50 system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new",
51 "localhost", NULL, NULL);
52 GNUNET_assert (NULL != system);
53 new_port1 = GNUNET_TESTING_reserve_port (system);
54 LOG (GNUNET_ERROR_TYPE_DEBUG,
55 "Reserved TCP port %u\n", new_port1);
58 new_port2 = GNUNET_TESTING_reserve_port (system);
59 LOG (GNUNET_ERROR_TYPE_DEBUG,
60 "Reserved TCP port %u\n", new_port2);
63 GNUNET_assert (new_port1 != new_port2);
64 GNUNET_TESTING_release_port (system, new_port1);
65 old_port1 = new_port1;
67 new_port1 = GNUNET_TESTING_reserve_port (system);
68 LOG (GNUNET_ERROR_TYPE_DEBUG,
69 "Reserved TCP port %u\n", new_port1);
70 GNUNET_assert (0 != new_port1);
71 GNUNET_assert (old_port1 == new_port1);
72 GNUNET_TESTING_release_port (system, new_port1);
73 GNUNET_TESTING_release_port (system, new_port2);
77 GNUNET_TESTING_system_destroy (system, GNUNET_YES);
81 int main (int argc, char *argv[])
83 struct GNUNET_GETOPT_CommandLineOption options[] = {
84 GNUNET_GETOPT_OPTION_END
87 status = GNUNET_SYSERR;
89 GNUNET_PROGRAM_run (argc,
91 "test_testing_new_portreservation",
92 "test case for testing port reservation routines"
93 " from the new testing library API",
98 return (GNUNET_OK == status) ? 0 : 1;
101 /* end of test_testing_portreservation.c */