diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-15 08:38:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-15 08:38:53 +0000 |
commit | 36ca9fcc68935edd109481d30f9e6e15a825c282 (patch) | |
tree | 5c976b741a314b5c3486124a9bff74b4ab5f5b78 /src/fs/test_fs_search_probes.c | |
parent | e825548ea9a45d1f4b25898f87b5c74f8bc4cc25 (diff) | |
download | gnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.tar.gz gnunet-36ca9fcc68935edd109481d30f9e6e15a825c282.zip |
-simplifying tests with new testing lib
Diffstat (limited to 'src/fs/test_fs_search_probes.c')
-rw-r--r-- | src/fs/test_fs_search_probes.c | 71 |
1 files changed, 6 insertions, 65 deletions
diff --git a/src/fs/test_fs_search_probes.c b/src/fs/test_fs_search_probes.c index b81659899..be710a79c 100644 --- a/src/fs/test_fs_search_probes.c +++ b/src/fs/test_fs_search_probes.c | |||
@@ -25,10 +25,9 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_arm_service.h" | 28 | #include "gnunet_testing_lib-new.h" |
29 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
30 | 30 | ||
31 | #define START_ARM GNUNET_YES | ||
32 | 31 | ||
33 | /** | 32 | /** |
34 | * File-size we use for testing. | 33 | * File-size we use for testing. |
@@ -45,16 +44,6 @@ | |||
45 | */ | 44 | */ |
46 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 45 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
47 | 46 | ||
48 | struct PeerContext | ||
49 | { | ||
50 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
51 | struct GNUNET_PeerIdentity id; | ||
52 | #if START_ARM | ||
53 | struct GNUNET_OS_Process *arm_proc; | ||
54 | #endif | ||
55 | }; | ||
56 | |||
57 | static struct PeerContext p1; | ||
58 | 47 | ||
59 | static struct GNUNET_TIME_Absolute start; | 48 | static struct GNUNET_TIME_Absolute start; |
60 | 49 | ||
@@ -166,41 +155,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
166 | 155 | ||
167 | 156 | ||
168 | static void | 157 | static void |
169 | setup_peer (struct PeerContext *p, const char *cfgname) | 158 | run (void *cls, |
170 | { | ||
171 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
172 | #if START_ARM | ||
173 | p->arm_proc = | ||
174 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
175 | "gnunet-service-arm", | ||
176 | "-c", cfgname, NULL); | ||
177 | #endif | ||
178 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
179 | } | ||
180 | |||
181 | |||
182 | static void | ||
183 | stop_arm (struct PeerContext *p) | ||
184 | { | ||
185 | #if START_ARM | ||
186 | if (NULL != p->arm_proc) | ||
187 | { | ||
188 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
189 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
190 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
191 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
193 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
194 | GNUNET_OS_process_destroy (p->arm_proc); | ||
195 | p->arm_proc = NULL; | ||
196 | } | ||
197 | #endif | ||
198 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
199 | } | ||
200 | |||
201 | |||
202 | static void | ||
203 | run (void *cls, char *const *args, const char *cfgfile, | ||
204 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 159 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
205 | { | 160 | { |
206 | const char *keywords[] = { | 161 | const char *keywords[] = { |
@@ -214,7 +169,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
214 | struct GNUNET_FS_FileInformation *fi; | 169 | struct GNUNET_FS_FileInformation *fi; |
215 | size_t i; | 170 | size_t i; |
216 | 171 | ||
217 | setup_peer (&p1, "test_fs_search_data.conf"); | ||
218 | fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, | 172 | fs = GNUNET_FS_start (cfg, "test-fs-search", &progress_cb, NULL, |
219 | GNUNET_FS_FLAGS_DO_PROBES, | 173 | GNUNET_FS_FLAGS_DO_PROBES, |
220 | GNUNET_FS_OPTIONS_END); | 174 | GNUNET_FS_OPTIONS_END); |
@@ -245,23 +199,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
245 | int | 199 | int |
246 | main (int argc, char *argv[]) | 200 | main (int argc, char *argv[]) |
247 | { | 201 | { |
248 | char *const argvx[] = { | 202 | if (0 != GNUNET_TESTING_peer_run ("test-fs-search-probes", |
249 | "test-fs-search-probes", | 203 | "test_fs_search_data.conf", |
250 | "-c", | 204 | &run, NULL)) |
251 | "test_fs_search_data.conf", | 205 | return 1; |
252 | NULL | ||
253 | }; | ||
254 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
255 | GNUNET_GETOPT_OPTION_END | ||
256 | }; | ||
257 | |||
258 | GNUNET_log_setup ("test_fs_search_probes", | ||
259 | "WARNING", | ||
260 | NULL); | ||
261 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
262 | "test-fs-search", "nohelp", options, &run, NULL); | ||
263 | stop_arm (&p1); | ||
264 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-search/"); | ||
265 | return 0; | 206 | return 0; |
266 | } | 207 | } |
267 | 208 | ||