2 This file is part of GNUnet.
3 (C) 2009, 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.
22 * Testcase for the NAT testing code.
24 * @file nat/test_nat_test.c
25 * @brief Testcase for NAT testing functions
26 * @author Christian Grothoff
29 #include "gnunet_common.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_nat_lib.h"
34 #define VERBOSE GNUNET_YES
38 * Time to wait before stopping NAT test, in seconds
40 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
45 static struct GNUNET_NAT_Test *tst;
47 static GNUNET_SCHEDULER_TaskIdentifier end;
51 const struct GNUNET_SCHEDULER_TaskContext *tc)
53 GNUNET_NAT_test_stop (tst);
57 report_success (void *cls,
60 GNUNET_assert (GNUNET_OK == success);
62 GNUNET_SCHEDULER_cancel (end);
63 end = GNUNET_SCHEDULER_add_now (&end_test, NULL);
67 * Main function run with scheduler.
72 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
74 tst = GNUNET_NAT_test_start (cfg, GNUNET_YES,
76 &report_success, NULL);
79 end = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
86 main (int argc, char *const argv[])
88 struct GNUNET_GETOPT_CommandLineOption options[] = {
89 GNUNET_GETOPT_OPTION_END
91 struct GNUNET_OS_Process *gns;
92 char *const argv_prog[] = {
95 "test_nat_test_data.conf",
105 GNUNET_log_setup ("test-nat-test",
112 gns = GNUNET_OS_start_process (NULL, NULL,
119 "-c", "test_nat_test_data.conf",
122 GNUNET_assert (NULL != gns);
123 GNUNET_PROGRAM_run (5, argv_prog,
124 "test-nat-test", "nohelp",
127 GNUNET_break (0 == GNUNET_OS_process_kill (gns, SIGTERM));
128 GNUNET_break (GNUNET_OK ==
129 GNUNET_OS_process_wait (gns));
130 GNUNET_OS_process_close (gns);
134 /* end of test_nat_test.c */