diff options
author | Ji Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96> | 2009-10-23 21:55:31 +0000 |
---|---|---|
committer | Ji Lu <jilu@140774ce-b5e7-0310-ab8b-a85725594a96> | 2009-10-23 21:55:31 +0000 |
commit | 267b8b5e0e264627f334a18ae1bf3f3a88ff2e32 (patch) | |
tree | bc5d8b0575dac520f49d957cf76bdd2b9f048a03 /src/util/test_program.c | |
parent | d5961683763d0e20330a737abb72ef4321a18b38 (diff) | |
download | gnunet-267b8b5e0e264627f334a18ae1bf3f3a88ff2e32.tar.gz gnunet-267b8b5e0e264627f334a18ae1bf3f3a88ff2e32.zip |
complete test program
Diffstat (limited to 'src/util/test_program.c')
-rw-r--r-- | src/util/test_program.c | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/src/util/test_program.c b/src/util/test_program.c index 5c58123b5..089976277 100644 --- a/src/util/test_program.c +++ b/src/util/test_program.c | |||
@@ -27,25 +27,42 @@ | |||
27 | #include "gnunet_scheduler_lib.h" | 27 | #include "gnunet_scheduler_lib.h" |
28 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
29 | 29 | ||
30 | static int setme; | 30 | static int setme1, setme2; |
31 | 31 | ||
32 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 32 | static struct GNUNET_GETOPT_CommandLineOption options1[] = { |
33 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme}, | 33 | {'n', "name", NULL, "description", 0, &GNUNET_GETOPT_set_one, &setme1}, |
34 | GNUNET_GETOPT_OPTION_END | 34 | GNUNET_GETOPT_OPTION_END |
35 | }; | 35 | }; |
36 | 36 | ||
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} | ||
40 | }; | ||
41 | |||
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} | ||
45 | |||
46 | }; | ||
47 | |||
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} | ||
51 | |||
52 | }; | ||
53 | |||
37 | /** | 54 | /** |
38 | * Main function that will be run. | 55 | * Main function that will be run. |
39 | */ | 56 | */ |
57 | |||
40 | static void | 58 | static void |
41 | runner (void *cls, | 59 | runner (void *cls, |
42 | struct GNUNET_SCHEDULER_Handle *sched, | 60 | struct GNUNET_SCHEDULER_Handle *sched, |
43 | char *const *args, | 61 | char *const *args, |
44 | const char *cfgfile, | 62 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
45 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
46 | { | 63 | { |
47 | int *ok = cls; | 64 | int *ok = cls; |
48 | GNUNET_assert (setme == 1); | 65 | GNUNET_assert (setme1 == 1); |
49 | GNUNET_assert (sched != NULL); | 66 | GNUNET_assert (sched != NULL); |
50 | GNUNET_assert (0 == strcmp (args[0], "extra")); | 67 | GNUNET_assert (0 == strcmp (args[0], "extra")); |
51 | GNUNET_assert (args[1] == NULL); | 68 | GNUNET_assert (args[1] == NULL); |
@@ -54,7 +71,6 @@ runner (void *cls, | |||
54 | *ok = 0; | 71 | *ok = 0; |
55 | } | 72 | } |
56 | 73 | ||
57 | |||
58 | /** | 74 | /** |
59 | * Main method, starts scheduler with task1, | 75 | * Main method, starts scheduler with task1, |
60 | * checks that "ok" is correct at the end. | 76 | * checks that "ok" is correct at the end. |
@@ -73,11 +89,29 @@ check () | |||
73 | "extra", | 89 | "extra", |
74 | NULL | 90 | NULL |
75 | }; | 91 | }; |
92 | |||
76 | GNUNET_assert (GNUNET_OK == | 93 | GNUNET_assert (GNUNET_OK == |
77 | GNUNET_PROGRAM_run (7, | 94 | GNUNET_PROGRAM_run (7, |
78 | argv, | 95 | argv, |
79 | "test_program", | 96 | "test_program", |
80 | "A test", options, &runner, &ok)); | 97 | "A test", options1, &runner, &ok)); |
98 | |||
99 | GNUNET_assert (GNUNET_OK == | ||
100 | GNUNET_PROGRAM_run (7, | ||
101 | argv, | ||
102 | "test_program", | ||
103 | "A test", options2, &runner, &ok)); | ||
104 | GNUNET_assert (GNUNET_OK == | ||
105 | GNUNET_PROGRAM_run (7, | ||
106 | argv, | ||
107 | "test_program", | ||
108 | "A test", options3, &runner, &ok)); | ||
109 | GNUNET_assert (GNUNET_OK == | ||
110 | GNUNET_PROGRAM_run (7, | ||
111 | argv, | ||
112 | "test_program", | ||
113 | "A test", options4, &runner, &ok)); | ||
114 | |||
81 | return ok; | 115 | return ok; |
82 | } | 116 | } |
83 | 117 | ||