diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-10-29 16:14:03 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-10-29 16:14:03 +0000 |
commit | bcbcf005b4864ac5557c31da10521126d8880849 (patch) | |
tree | 444cafefb16e1c5a4ba13ce2db07d6ec1f37675e /src/statistics | |
parent | 119193d6350bbbd8c6ecbd60ccc8301223d6f6d6 (diff) | |
download | gnunet-bcbcf005b4864ac5557c31da10521126d8880849.tar.gz gnunet-bcbcf005b4864ac5557c31da10521126d8880849.zip |
installing all service, daemon and helper binaries to lib/gnunet/libexec/; updating code to run binaries from new location, which is no longer in PATH
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/Makefile.am | 7 | ||||
-rw-r--r-- | src/statistics/test_statistics_api.c | 59 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_loop.c | 47 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_watch.c | 38 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_watch_zero_value.c | 50 |
5 files changed, 74 insertions, 127 deletions
diff --git a/src/statistics/Makefile.am b/src/statistics/Makefile.am index 5485a9c18..f4d0c3b99 100644 --- a/src/statistics/Makefile.am +++ b/src/statistics/Makefile.am | |||
@@ -11,6 +11,8 @@ endif | |||
11 | 11 | ||
12 | pkgcfgdir= $(pkgdatadir)/config.d/ | 12 | pkgcfgdir= $(pkgdatadir)/config.d/ |
13 | 13 | ||
14 | libexecdir= $(pkglibdir)/libexec/ | ||
15 | |||
14 | pkgcfg_DATA = \ | 16 | pkgcfg_DATA = \ |
15 | statistics.conf | 17 | statistics.conf |
16 | 18 | ||
@@ -25,10 +27,11 @@ libgnunetstatistics_la_LDFLAGS = \ | |||
25 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 27 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ |
26 | -version-info 1:1:1 | 28 | -version-info 1:1:1 |
27 | 29 | ||
30 | libexec_PROGRAMS = \ | ||
31 | gnunet-service-statistics | ||
28 | 32 | ||
29 | bin_PROGRAMS = \ | 33 | bin_PROGRAMS = \ |
30 | gnunet-statistics \ | 34 | gnunet-statistics |
31 | gnunet-service-statistics | ||
32 | 35 | ||
33 | gnunet_statistics_SOURCES = \ | 36 | gnunet_statistics_SOURCES = \ |
34 | gnunet-statistics.c | 37 | gnunet-statistics.c |
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index ddebfa356..5fb506ff7 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -20,17 +20,15 @@ | |||
20 | /** | 20 | /** |
21 | * @file statistics/test_statistics_api.c | 21 | * @file statistics/test_statistics_api.c |
22 | * @brief testcase for statistics_api.c | 22 | * @brief testcase for statistics_api.c |
23 | * @author Christian Grothoff | ||
23 | */ | 24 | */ |
24 | #include "platform.h" | 25 | #include "platform.h" |
25 | #include "gnunet_common.h" | 26 | #include "gnunet_util_lib.h" |
26 | #include "gnunet_getopt_lib.h" | ||
27 | #include "gnunet_os_lib.h" | ||
28 | #include "gnunet_program_lib.h" | ||
29 | #include "gnunet_scheduler_lib.h" | ||
30 | #include "gnunet_statistics_service.h" | 27 | #include "gnunet_statistics_service.h" |
31 | 28 | ||
32 | 29 | ||
33 | #define START_SERVICE GNUNET_YES | 30 | static struct GNUNET_STATISTICS_Handle *h; |
31 | |||
34 | 32 | ||
35 | static int | 33 | static int |
36 | check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | 34 | check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, |
@@ -45,6 +43,7 @@ check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
45 | return GNUNET_OK; | 43 | return GNUNET_OK; |
46 | } | 44 | } |
47 | 45 | ||
46 | |||
48 | static int | 47 | static int |
49 | check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | 48 | check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, |
50 | int is_persistent) | 49 | int is_persistent) |
@@ -58,6 +57,7 @@ check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
58 | return GNUNET_OK; | 57 | return GNUNET_OK; |
59 | } | 58 | } |
60 | 59 | ||
60 | |||
61 | static int | 61 | static int |
62 | check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, | 62 | check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, |
63 | int is_persistent) | 63 | int is_persistent) |
@@ -71,7 +71,6 @@ check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
71 | return GNUNET_OK; | 71 | return GNUNET_OK; |
72 | } | 72 | } |
73 | 73 | ||
74 | static struct GNUNET_STATISTICS_Handle *h; | ||
75 | 74 | ||
76 | static void | 75 | static void |
77 | next_fin (void *cls, int success) | 76 | next_fin (void *cls, int success) |
@@ -83,6 +82,7 @@ next_fin (void *cls, int success) | |||
83 | *ok = 0; | 82 | *ok = 0; |
84 | } | 83 | } |
85 | 84 | ||
85 | |||
86 | static void | 86 | static void |
87 | next (void *cls, int success) | 87 | next (void *cls, int success) |
88 | { | 88 | { |
@@ -94,6 +94,7 @@ next (void *cls, int success) | |||
94 | &check_2, cls)); | 94 | &check_2, cls)); |
95 | } | 95 | } |
96 | 96 | ||
97 | |||
97 | static void | 98 | static void |
98 | run (void *cls, char *const *args, const char *cfgfile, | 99 | run (void *cls, char *const *args, const char *cfgfile, |
99 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 100 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -110,6 +111,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
110 | &check_1, cls)); | 111 | &check_1, cls)); |
111 | } | 112 | } |
112 | 113 | ||
114 | |||
113 | static void | 115 | static void |
114 | run_more (void *cls, char *const *args, const char *cfgfile, | 116 | run_more (void *cls, char *const *args, const char *cfgfile, |
115 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 117 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -121,8 +123,9 @@ run_more (void *cls, char *const *args, const char *cfgfile, | |||
121 | &check_3, cls)); | 123 | &check_3, cls)); |
122 | } | 124 | } |
123 | 125 | ||
124 | static int | 126 | |
125 | check () | 127 | int |
128 | main (int argc, char *argv_ign[]) | ||
126 | { | 129 | { |
127 | int ok = 1; | 130 | int ok = 1; |
128 | 131 | ||
@@ -135,18 +138,21 @@ check () | |||
135 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 138 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
136 | GNUNET_GETOPT_OPTION_END | 139 | GNUNET_GETOPT_OPTION_END |
137 | }; | 140 | }; |
138 | #if START_SERVICE | ||
139 | struct GNUNET_OS_Process *proc; | 141 | struct GNUNET_OS_Process *proc; |
142 | char *binary; | ||
140 | 143 | ||
144 | GNUNET_log_setup ("test_statistics_api", | ||
145 | "WARNING", | ||
146 | NULL); | ||
147 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); | ||
141 | proc = | 148 | proc = |
142 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", | 149 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, |
150 | binary, | ||
143 | "gnunet-service-statistics", | 151 | "gnunet-service-statistics", |
144 | "-c", "test_statistics_api_data.conf", NULL); | 152 | "-c", "test_statistics_api_data.conf", NULL); |
145 | #endif | ||
146 | GNUNET_assert (NULL != proc); | 153 | GNUNET_assert (NULL != proc); |
147 | GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run, | 154 | GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run, |
148 | &ok); | 155 | &ok); |
149 | #if START_SERVICE | ||
150 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 156 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
151 | { | 157 | { |
152 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 158 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
@@ -155,20 +161,20 @@ check () | |||
155 | GNUNET_OS_process_wait (proc); | 161 | GNUNET_OS_process_wait (proc); |
156 | GNUNET_OS_process_destroy (proc); | 162 | GNUNET_OS_process_destroy (proc); |
157 | proc = NULL; | 163 | proc = NULL; |
158 | #endif | ||
159 | if (ok != 0) | 164 | if (ok != 0) |
165 | { | ||
166 | GNUNET_free (binary); | ||
160 | return ok; | 167 | return ok; |
168 | } | ||
161 | ok = 1; | 169 | ok = 1; |
162 | #if START_SERVICE | ||
163 | /* restart to check persistence! */ | 170 | /* restart to check persistence! */ |
164 | proc = | 171 | proc = |
165 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", | 172 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, |
173 | binary, | ||
166 | "gnunet-service-statistics", | 174 | "gnunet-service-statistics", |
167 | "-c", "test_statistics_api_data.conf", NULL); | 175 | "-c", "test_statistics_api_data.conf", NULL); |
168 | #endif | ||
169 | GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, | 176 | GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, |
170 | &run_more, &ok); | 177 | &run_more, &ok); |
171 | #if START_SERVICE | ||
172 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 178 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
173 | { | 179 | { |
174 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 180 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
@@ -177,21 +183,8 @@ check () | |||
177 | GNUNET_OS_process_wait (proc); | 183 | GNUNET_OS_process_wait (proc); |
178 | GNUNET_OS_process_destroy (proc); | 184 | GNUNET_OS_process_destroy (proc); |
179 | proc = NULL; | 185 | proc = NULL; |
180 | #endif | 186 | GNUNET_free (binary); |
181 | return ok; | 187 | return ok; |
182 | } | 188 | } |
183 | 189 | ||
184 | int | ||
185 | main (int argc, char *argv[]) | ||
186 | { | ||
187 | int ret; | ||
188 | |||
189 | GNUNET_log_setup ("test_statistics_api", | ||
190 | "WARNING", | ||
191 | NULL); | ||
192 | ret = check (); | ||
193 | |||
194 | return ret; | ||
195 | } | ||
196 | |||
197 | /* end of test_statistics_api.c */ | 190 | /* end of test_statistics_api.c */ |
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index ae798b830..f9a3a3ba6 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c | |||
@@ -22,18 +22,13 @@ | |||
22 | * @brief testcase for statistics_api.c | 22 | * @brief testcase for statistics_api.c |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_util_lib.h" |
26 | #include "gnunet_getopt_lib.h" | ||
27 | #include "gnunet_os_lib.h" | ||
28 | #include "gnunet_program_lib.h" | ||
29 | #include "gnunet_scheduler_lib.h" | ||
30 | #include "gnunet_statistics_service.h" | 26 | #include "gnunet_statistics_service.h" |
31 | 27 | ||
32 | #define VERBOSE GNUNET_NO | 28 | #define ROUNDS (1024 * 1024) |
33 | 29 | ||
34 | #define START_SERVICE GNUNET_YES | 30 | static struct GNUNET_STATISTICS_Handle *h; |
35 | 31 | ||
36 | #define ROUNDS (1024 * 1024) | ||
37 | 32 | ||
38 | static int | 33 | static int |
39 | check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | 34 | check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, |
@@ -45,7 +40,6 @@ check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
45 | return GNUNET_OK; | 40 | return GNUNET_OK; |
46 | } | 41 | } |
47 | 42 | ||
48 | static struct GNUNET_STATISTICS_Handle *h; | ||
49 | 43 | ||
50 | static void | 44 | static void |
51 | next (void *cls, int success) | 45 | next (void *cls, int success) |
@@ -57,11 +51,12 @@ next (void *cls, int success) | |||
57 | *ok = 0; | 51 | *ok = 0; |
58 | } | 52 | } |
59 | 53 | ||
54 | |||
60 | static void | 55 | static void |
61 | run (void *cls, char *const *args, const char *cfgfile, | 56 | run (void *cls, char *const *args, const char *cfgfile, |
62 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 57 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
63 | { | 58 | { |
64 | int i; | 59 | unsigned int i; |
65 | char name[128]; | 60 | char name[128]; |
66 | 61 | ||
67 | h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); | 62 | h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); |
@@ -80,8 +75,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
80 | } | 75 | } |
81 | 76 | ||
82 | 77 | ||
83 | static int | 78 | int |
84 | check () | 79 | main (int argc, char *argv_ign[]) |
85 | { | 80 | { |
86 | int ok = 1; | 81 | int ok = 1; |
87 | 82 | ||
@@ -93,21 +88,19 @@ check () | |||
93 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 88 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
94 | GNUNET_GETOPT_OPTION_END | 89 | GNUNET_GETOPT_OPTION_END |
95 | }; | 90 | }; |
96 | #if START_SERVICE | ||
97 | struct GNUNET_OS_Process *proc; | 91 | struct GNUNET_OS_Process *proc; |
92 | char *binary; | ||
98 | 93 | ||
94 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); | ||
99 | proc = | 95 | proc = |
100 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", | 96 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
101 | "gnunet-service-statistics", | 97 | NULL, NULL, |
102 | #if DEBUG_STATISTICS | 98 | binary, |
103 | "-L", "DEBUG", | 99 | "gnunet-service-statistics", |
104 | #endif | 100 | "-c", "test_statistics_api_data.conf", NULL); |
105 | "-c", "test_statistics_api_data.conf", NULL); | ||
106 | #endif | ||
107 | GNUNET_assert (NULL != proc); | 101 | GNUNET_assert (NULL != proc); |
108 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, | 102 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, |
109 | &ok); | 103 | &ok); |
110 | #if START_SERVICE | ||
111 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 104 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
112 | { | 105 | { |
113 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 106 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
@@ -116,18 +109,8 @@ check () | |||
116 | GNUNET_OS_process_wait (proc); | 109 | GNUNET_OS_process_wait (proc); |
117 | GNUNET_OS_process_destroy (proc); | 110 | GNUNET_OS_process_destroy (proc); |
118 | proc = NULL; | 111 | proc = NULL; |
119 | #endif | 112 | GNUNET_free (binary); |
120 | return ok; | 113 | return ok; |
121 | } | 114 | } |
122 | 115 | ||
123 | int | ||
124 | main (int argc, char *argv[]) | ||
125 | { | ||
126 | int ret; | ||
127 | |||
128 | ret = check (); | ||
129 | |||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | /* end of test_statistics_api_loop.c */ | 116 | /* end of test_statistics_api_loop.c */ |
diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index f3524aa7c..1e7f27b3e 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -20,6 +20,7 @@ | |||
20 | /** | 20 | /** |
21 | * @file statistics/test_statistics_api_watch.c | 21 | * @file statistics/test_statistics_api_watch.c |
22 | * @brief testcase for statistics_api.c watch functions | 22 | * @brief testcase for statistics_api.c watch functions |
23 | * @author Christian Grothoff | ||
23 | */ | 24 | */ |
24 | #include "platform.h" | 25 | #include "platform.h" |
25 | #include "gnunet_common.h" | 26 | #include "gnunet_common.h" |
@@ -29,9 +30,6 @@ | |||
29 | #include "gnunet_scheduler_lib.h" | 30 | #include "gnunet_scheduler_lib.h" |
30 | #include "gnunet_statistics_service.h" | 31 | #include "gnunet_statistics_service.h" |
31 | 32 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | #define START_SERVICE GNUNET_YES | ||
35 | 33 | ||
36 | static int ok; | 34 | static int ok; |
37 | 35 | ||
@@ -112,8 +110,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
112 | } | 110 | } |
113 | 111 | ||
114 | 112 | ||
115 | static int | 113 | int |
116 | check () | 114 | main (int argc, char *argv_ign[]) |
117 | { | 115 | { |
118 | char *const argv[] = { "test-statistics-api", | 116 | char *const argv[] = { "test-statistics-api", |
119 | "-c", | 117 | "-c", |
@@ -123,22 +121,19 @@ check () | |||
123 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 121 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
124 | GNUNET_GETOPT_OPTION_END | 122 | GNUNET_GETOPT_OPTION_END |
125 | }; | 123 | }; |
126 | #if START_SERVICE | ||
127 | struct GNUNET_OS_Process *proc; | 124 | struct GNUNET_OS_Process *proc; |
128 | 125 | char *binary; | |
126 | |||
127 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); | ||
129 | proc = | 128 | proc = |
130 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", | 129 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, |
131 | "gnunet-service-statistics", | 130 | binary, |
132 | #if VERBOSE | 131 | "gnunet-service-statistics", |
133 | "-L", "DEBUG", | 132 | "-c", "test_statistics_api_data.conf", NULL); |
134 | #endif | ||
135 | "-c", "test_statistics_api_data.conf", NULL); | ||
136 | #endif | ||
137 | GNUNET_assert (NULL != proc); | 133 | GNUNET_assert (NULL != proc); |
138 | ok = 3; | 134 | ok = 3; |
139 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, | 135 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, |
140 | NULL); | 136 | NULL); |
141 | #if START_SERVICE | ||
142 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 137 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
143 | { | 138 | { |
144 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 139 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
@@ -147,18 +142,9 @@ check () | |||
147 | GNUNET_OS_process_wait (proc); | 142 | GNUNET_OS_process_wait (proc); |
148 | GNUNET_OS_process_destroy (proc); | 143 | GNUNET_OS_process_destroy (proc); |
149 | proc = NULL; | 144 | proc = NULL; |
150 | #endif | 145 | GNUNET_free (binary); |
151 | return ok; | 146 | return ok; |
152 | } | 147 | } |
153 | 148 | ||
154 | int | ||
155 | main (int argc, char *argv[]) | ||
156 | { | ||
157 | int ret; | ||
158 | |||
159 | ret = check (); | ||
160 | |||
161 | return ret; | ||
162 | } | ||
163 | 149 | ||
164 | /* end of test_statistics_api_watch.c */ | 150 | /* end of test_statistics_api_watch.c */ |
diff --git a/src/statistics/test_statistics_api_watch_zero_value.c b/src/statistics/test_statistics_api_watch_zero_value.c index fe3974fc9..d78de9a9e 100644 --- a/src/statistics/test_statistics_api_watch_zero_value.c +++ b/src/statistics/test_statistics_api_watch_zero_value.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 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 | 6 | it under the terms of the GNU General Public License as published |
@@ -22,21 +22,15 @@ | |||
22 | * @brief testcase for statistics_api.c watch functions with initial 0 value | 22 | * @brief testcase for statistics_api.c watch functions with initial 0 value |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_util_lib.h" |
26 | #include "gnunet_getopt_lib.h" | ||
27 | #include "gnunet_os_lib.h" | ||
28 | #include "gnunet_program_lib.h" | ||
29 | #include "gnunet_scheduler_lib.h" | ||
30 | #include "gnunet_statistics_service.h" | 26 | #include "gnunet_statistics_service.h" |
31 | 27 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | #define START_SERVICE GNUNET_YES | ||
35 | |||
36 | static int ok; | 28 | static int ok; |
29 | |||
37 | static int ok2; | 30 | static int ok2; |
38 | 31 | ||
39 | static struct GNUNET_STATISTICS_Handle *h; | 32 | static struct GNUNET_STATISTICS_Handle *h; |
33 | |||
40 | static struct GNUNET_STATISTICS_Handle *h2; | 34 | static struct GNUNET_STATISTICS_Handle *h2; |
41 | 35 | ||
42 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 36 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; |
@@ -92,6 +86,7 @@ watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
92 | return GNUNET_OK; | 86 | return GNUNET_OK; |
93 | } | 87 | } |
94 | 88 | ||
89 | |||
95 | static int | 90 | static int |
96 | watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | 91 | watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, |
97 | int is_persistent) | 92 | int is_persistent) |
@@ -121,6 +116,7 @@ watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
121 | return GNUNET_OK; | 116 | return GNUNET_OK; |
122 | } | 117 | } |
123 | 118 | ||
119 | |||
124 | static void | 120 | static void |
125 | run (void *cls, char *const *args, const char *cfgfile, | 121 | run (void *cls, char *const *args, const char *cfgfile, |
126 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 122 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -145,8 +141,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
145 | } | 141 | } |
146 | 142 | ||
147 | 143 | ||
148 | static int | 144 | int |
149 | check () | 145 | main (int argc, char *argv_ign[]) |
150 | { | 146 | { |
151 | char *const argv[] = { "test-statistics-api", | 147 | char *const argv[] = { "test-statistics-api", |
152 | "-c", | 148 | "-c", |
@@ -156,23 +152,20 @@ check () | |||
156 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 152 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
157 | GNUNET_GETOPT_OPTION_END | 153 | GNUNET_GETOPT_OPTION_END |
158 | }; | 154 | }; |
159 | #if START_SERVICE | ||
160 | struct GNUNET_OS_Process *proc; | 155 | struct GNUNET_OS_Process *proc; |
156 | char *binary; | ||
161 | 157 | ||
158 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); | ||
162 | proc = | 159 | proc = |
163 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", | 160 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, |
164 | "gnunet-service-statistics", | 161 | binary, |
165 | #if VERBOSE | 162 | "gnunet-service-statistics", |
166 | "-L", "DEBUG", | 163 | "-c", "test_statistics_api_data.conf", NULL); |
167 | #endif | ||
168 | "-c", "test_statistics_api_data.conf", NULL); | ||
169 | #endif | ||
170 | GNUNET_assert (NULL != proc); | 164 | GNUNET_assert (NULL != proc); |
171 | ok = 3; | 165 | ok = 3; |
172 | ok2 = 1; | 166 | ok2 = 1; |
173 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, | 167 | GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, |
174 | NULL); | 168 | NULL); |
175 | #if START_SERVICE | ||
176 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 169 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
177 | { | 170 | { |
178 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 171 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
@@ -181,21 +174,10 @@ check () | |||
181 | GNUNET_OS_process_wait (proc); | 174 | GNUNET_OS_process_wait (proc); |
182 | GNUNET_OS_process_destroy (proc); | 175 | GNUNET_OS_process_destroy (proc); |
183 | proc = NULL; | 176 | proc = NULL; |
184 | #endif | 177 | GNUNET_free (binary); |
185 | if ((0 == ok) && (0 == ok2)) | 178 | if ((0 == ok) && (0 == ok2)) |
186 | return 0; | 179 | return 0; |
187 | else | 180 | return 1; |
188 | return 1; | ||
189 | } | ||
190 | |||
191 | int | ||
192 | main (int argc, char *argv[]) | ||
193 | { | ||
194 | int ret; | ||
195 | |||
196 | ret = check (); | ||
197 | |||
198 | return ret; | ||
199 | } | 181 | } |
200 | 182 | ||
201 | /* end of test_statistics_api_watch_zero_value.c */ | 183 | /* end of test_statistics_api_watch_zero_value.c */ |