2 This file is part of GNUnet.
3 (C) 2009 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 util/test_program.c
22 * @brief tests for program.c
25 #include "gnunet_util_lib.h"
27 static int setme1, setme2;
29 static struct GNUNET_GETOPT_CommandLineOption options1[] = {
30 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
31 GNUNET_GETOPT_OPTION_END
34 static struct GNUNET_GETOPT_CommandLineOption options2[] = {
35 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
36 {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
37 GNUNET_GETOPT_OPTION_END
40 static struct GNUNET_GETOPT_CommandLineOption options3[] = {
41 {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
42 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
43 GNUNET_GETOPT_OPTION_END
46 static struct GNUNET_GETOPT_CommandLineOption options4[] = {
47 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
48 {'n', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2},
49 GNUNET_GETOPT_OPTION_END
53 * Main function that will be run.
57 runner (void *cls, char *const *args, const char *cfgfile,
58 const struct GNUNET_CONFIGURATION_Handle *cfg)
62 GNUNET_assert (setme1 == 1);
63 GNUNET_assert (0 == strcmp (args[0], "extra"));
64 GNUNET_assert (args[1] == NULL);
65 GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf"));
71 * Main method, starts scheduler with task1,
72 * checks that "ok" is correct at the end.
79 char *const argv[] = {
82 "test_program_data.conf",
90 GNUNET_assert (GNUNET_OK ==
91 GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
92 options1, &runner, &ok));
94 GNUNET_assert (GNUNET_OK ==
95 GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
96 options2, &runner, &ok));
97 GNUNET_assert (GNUNET_OK ==
98 GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
99 options3, &runner, &ok));
100 GNUNET_assert (GNUNET_OK ==
101 GNUNET_PROGRAM_run (7, argv, "test_program", "A test",
102 options4, &runner, &ok));
108 main (int argc, char *argv[])
112 GNUNET_log_setup ("test_program", "WARNING", NULL);
118 /* end of test_program.c */