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 2, 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_common.h"
26 #include "gnunet_program_lib.h"
27 #include "gnunet_scheduler_lib.h"
28 #include "gnunet_time_lib.h"
30 static int setme1, setme2;
32 static struct GNUNET_GETOPT_CommandLineOption options1[] = {
33 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
34 GNUNET_GETOPT_OPTION_END
37 static struct GNUNET_GETOPT_CommandLineOption options2[] = {
38 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
39 {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
42 static struct GNUNET_GETOPT_CommandLineOption options3[] = {
43 {'N', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
44 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
48 static struct GNUNET_GETOPT_CommandLineOption options4[] = {
49 {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1},
50 {'n', "number", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme2}
55 * Main function that will be run.
60 struct GNUNET_SCHEDULER_Handle *sched,
62 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
65 GNUNET_assert (setme1 == 1);
66 GNUNET_assert (sched != NULL);
67 GNUNET_assert (0 == strcmp (args[0], "extra"));
68 GNUNET_assert (args[1] == NULL);
69 GNUNET_assert (0 == strcmp (cfgfile, "test_program_data.conf"));
75 * Main method, starts scheduler with task1,
76 * checks that "ok" is correct at the end.
82 char *const argv[] = {
85 "test_program_data.conf",
93 GNUNET_assert (GNUNET_OK ==
94 GNUNET_PROGRAM_run (7,
97 "A test", options1, &runner, &ok));
99 GNUNET_assert (GNUNET_OK ==
100 GNUNET_PROGRAM_run (7,
103 "A test", options2, &runner, &ok));
104 GNUNET_assert (GNUNET_OK ==
105 GNUNET_PROGRAM_run (7,
108 "A test", options3, &runner, &ok));
109 GNUNET_assert (GNUNET_OK ==
110 GNUNET_PROGRAM_run (7,
113 "A test", options4, &runner, &ok));
119 main (int argc, char *argv[])
123 GNUNET_log_setup ("test_program", "WARNING", NULL);
129 /* end of test_program.c */