diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-15 08:10:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-15 08:10:52 +0000 |
commit | e825548ea9a45d1f4b25898f87b5c74f8bc4cc25 (patch) | |
tree | 0a0236af09b77d8e32693c1e9fb7db4affd9ce8a /src | |
parent | 9f4e1f6e097b3c97abe0971b68b2ab686a61f036 (diff) | |
download | gnunet-e825548ea9a45d1f4b25898f87b5c74f8bc4cc25.tar.gz gnunet-e825548ea9a45d1f4b25898f87b5c74f8bc4cc25.zip |
-simplifying tests with new testing lib
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/Makefile.am | 20 | ||||
-rw-r--r-- | src/fs/test_fs_download.c | 1 | ||||
-rw-r--r-- | src/fs/test_fs_download_indexed.c | 1 | ||||
-rw-r--r-- | src/fs/test_fs_download_persistence.c | 2 | ||||
-rw-r--r-- | src/fs/test_fs_file_information.c | 12 | ||||
-rw-r--r-- | src/fs/test_fs_getopt.c | 7 | ||||
-rw-r--r-- | src/fs/test_fs_list_indexed.c | 112 | ||||
-rw-r--r-- | src/fs/test_fs_namespace.c | 79 | ||||
-rw-r--r-- | src/fs/test_fs_namespace_list_updateable.c | 86 | ||||
-rw-r--r-- | src/fs/test_fs_unindex.c | 118 | ||||
-rw-r--r-- | src/fs/test_fs_unindex_persistence.c | 119 |
11 files changed, 85 insertions, 472 deletions
diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 2c5c545c2..224c0fd0c 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am | |||
@@ -262,8 +262,6 @@ TESTS = \ | |||
262 | endif | 262 | endif |
263 | 263 | ||
264 | 264 | ||
265 | |||
266 | |||
267 | test_fs_directory_SOURCES = \ | 265 | test_fs_directory_SOURCES = \ |
268 | test_fs_directory.c | 266 | test_fs_directory.c |
269 | test_fs_directory_LDADD = \ | 267 | test_fs_directory_LDADD = \ |
@@ -308,18 +306,21 @@ test_fs_getopt_LDADD = \ | |||
308 | test_fs_list_indexed_SOURCES = \ | 306 | test_fs_list_indexed_SOURCES = \ |
309 | test_fs_list_indexed.c | 307 | test_fs_list_indexed.c |
310 | test_fs_list_indexed_LDADD = \ | 308 | test_fs_list_indexed_LDADD = \ |
309 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
311 | $(top_builddir)/src/fs/libgnunetfs.la \ | 310 | $(top_builddir)/src/fs/libgnunetfs.la \ |
312 | $(top_builddir)/src/util/libgnunetutil.la | 311 | $(top_builddir)/src/util/libgnunetutil.la |
313 | 312 | ||
314 | test_fs_namespace_SOURCES = \ | 313 | test_fs_namespace_SOURCES = \ |
315 | test_fs_namespace.c | 314 | test_fs_namespace.c |
316 | test_fs_namespace_LDADD = \ | 315 | test_fs_namespace_LDADD = \ |
316 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
317 | $(top_builddir)/src/fs/libgnunetfs.la \ | 317 | $(top_builddir)/src/fs/libgnunetfs.la \ |
318 | $(top_builddir)/src/util/libgnunetutil.la | 318 | $(top_builddir)/src/util/libgnunetutil.la |
319 | 319 | ||
320 | test_fs_namespace_list_updateable_SOURCES = \ | 320 | test_fs_namespace_list_updateable_SOURCES = \ |
321 | test_fs_namespace_list_updateable.c | 321 | test_fs_namespace_list_updateable.c |
322 | test_fs_namespace_list_updateable_LDADD = \ | 322 | test_fs_namespace_list_updateable_LDADD = \ |
323 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
323 | $(top_builddir)/src/fs/libgnunetfs.la \ | 324 | $(top_builddir)/src/fs/libgnunetfs.la \ |
324 | $(top_builddir)/src/util/libgnunetutil.la | 325 | $(top_builddir)/src/util/libgnunetutil.la |
325 | 326 | ||
@@ -337,17 +338,20 @@ test_fs_publish_persistence_LDADD = \ | |||
337 | 338 | ||
338 | test_fs_search_SOURCES = \ | 339 | test_fs_search_SOURCES = \ |
339 | test_fs_search.c | 340 | test_fs_search.c |
340 | test_fs_search_LDADD = $(top_builddir)/src/fs/libgnunetfs.la \ | 341 | test_fs_search_LDADD = \ |
342 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
341 | $(top_builddir)/src/util/libgnunetutil.la | 343 | $(top_builddir)/src/util/libgnunetutil.la |
342 | 344 | ||
343 | test_fs_search_probes_SOURCES = \ | 345 | test_fs_search_probes_SOURCES = \ |
344 | test_fs_search_probes.c | 346 | test_fs_search_probes.c |
345 | test_fs_search_probes_LDADD = $(top_builddir)/src/fs/libgnunetfs.la \ | 347 | test_fs_search_probes_LDADD = \ |
348 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
346 | $(top_builddir)/src/util/libgnunetutil.la | 349 | $(top_builddir)/src/util/libgnunetutil.la |
347 | 350 | ||
348 | test_fs_search_persistence_SOURCES = \ | 351 | test_fs_search_persistence_SOURCES = \ |
349 | test_fs_search_persistence.c | 352 | test_fs_search_persistence.c |
350 | test_fs_search_persistence_LDADD = $(top_builddir)/src/fs/libgnunetfs.la \ | 353 | test_fs_search_persistence_LDADD = \ |
354 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
351 | $(top_builddir)/src/util/libgnunetutil.la | 355 | $(top_builddir)/src/util/libgnunetutil.la |
352 | 356 | ||
353 | test_fs_start_stop_SOURCES = \ | 357 | test_fs_start_stop_SOURCES = \ |
@@ -359,13 +363,15 @@ test_fs_start_stop_LDADD = \ | |||
359 | test_fs_unindex_SOURCES = \ | 363 | test_fs_unindex_SOURCES = \ |
360 | test_fs_unindex.c | 364 | test_fs_unindex.c |
361 | test_fs_unindex_LDADD = \ | 365 | test_fs_unindex_LDADD = \ |
362 | $(top_builddir)/src/fs/libgnunetfs.la \ | 366 | $(top_builddir)/src/testing/libgnunettesting.la \ |
367 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
363 | $(top_builddir)/src/util/libgnunetutil.la | 368 | $(top_builddir)/src/util/libgnunetutil.la |
364 | 369 | ||
365 | test_fs_unindex_persistence_SOURCES = \ | 370 | test_fs_unindex_persistence_SOURCES = \ |
366 | test_fs_unindex_persistence.c | 371 | test_fs_unindex_persistence.c |
367 | test_fs_unindex_persistence_LDADD = \ | 372 | test_fs_unindex_persistence_LDADD = \ |
368 | $(top_builddir)/src/fs/libgnunetfs.la \ | 373 | $(top_builddir)/src/testing/libgnunettesting.la \ |
374 | $(top_builddir)/src/fs/libgnunetfs.la \ | ||
369 | $(top_builddir)/src/util/libgnunetutil.la | 375 | $(top_builddir)/src/util/libgnunetutil.la |
370 | 376 | ||
371 | test_fs_uri_SOURCES = \ | 377 | test_fs_uri_SOURCES = \ |
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 31be61903..51c7a4000 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_arm_service.h" | ||
30 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
31 | #include "gnunet_testing_lib-new.h" | 30 | #include "gnunet_testing_lib-new.h" |
32 | #include <gauger.h> | 31 | #include <gauger.h> |
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c index eac683ab9..2d4091d7a 100644 --- a/src/fs/test_fs_download_indexed.c +++ b/src/fs/test_fs_download_indexed.c | |||
@@ -25,7 +25,6 @@ | |||
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" | ||
29 | #include "gnunet_fs_service.h" | 28 | #include "gnunet_fs_service.h" |
30 | #include "gnunet_testing_lib-new.h" | 29 | #include "gnunet_testing_lib-new.h" |
31 | #include <gauger.h> | 30 | #include <gauger.h> |
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index bb3bc84c9..98a32af5f 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c | |||
@@ -23,10 +23,8 @@ | |||
23 | * @brief simple testcase for persistence of simple download operation | 23 | * @brief simple testcase for persistence of simple download operation |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | |||
27 | #include "platform.h" | 26 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_arm_service.h" | ||
30 | #include "gnunet_testing_lib-new.h" | 28 | #include "gnunet_testing_lib-new.h" |
31 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
32 | 30 | ||
diff --git a/src/fs/test_fs_file_information.c b/src/fs/test_fs_file_information.c index fb7de7d9a..cc79c8020 100644 --- a/src/fs/test_fs_file_information.c +++ b/src/fs/test_fs_file_information.c | |||
@@ -31,12 +31,10 @@ | |||
31 | * - other API functions may not yet be tested (such as | 31 | * - other API functions may not yet be tested (such as |
32 | * filedata-from-callback) | 32 | * filedata-from-callback) |
33 | */ | 33 | */ |
34 | |||
35 | #include "platform.h" | 34 | #include "platform.h" |
36 | #include "gnunet_util_lib.h" | 35 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_fs_service.h" | 36 | #include "gnunet_fs_service.h" |
38 | 37 | ||
39 | #define VERBOSE GNUNET_NO | ||
40 | 38 | ||
41 | /** | 39 | /** |
42 | * File-size we use for testing. | 40 | * File-size we use for testing. |
@@ -137,9 +135,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
137 | } | 135 | } |
138 | 136 | ||
139 | 137 | ||
140 | |||
141 | |||
142 | |||
143 | int | 138 | int |
144 | main (int argc, char *argv[]) | 139 | main (int argc, char *argv[]) |
145 | { | 140 | { |
@@ -147,9 +142,6 @@ main (int argc, char *argv[]) | |||
147 | "test-fs-file_information", | 142 | "test-fs-file_information", |
148 | "-c", | 143 | "-c", |
149 | "test_fs_file_information_data.conf", | 144 | "test_fs_file_information_data.conf", |
150 | #if VERBOSE | ||
151 | "-L", "DEBUG", | ||
152 | #endif | ||
153 | NULL | 145 | NULL |
154 | }; | 146 | }; |
155 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 147 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -157,11 +149,7 @@ main (int argc, char *argv[]) | |||
157 | }; | 149 | }; |
158 | 150 | ||
159 | GNUNET_log_setup ("test_fs_file_information", | 151 | GNUNET_log_setup ("test_fs_file_information", |
160 | #if VERBOSE | ||
161 | "DEBUG", | ||
162 | #else | ||
163 | "WARNING", | 152 | "WARNING", |
164 | #endif | ||
165 | NULL); | 153 | NULL); |
166 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | 154 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, |
167 | "test-fs-file_information", "nohelp", options, &run, | 155 | "test-fs-file_information", "nohelp", options, &run, |
diff --git a/src/fs/test_fs_getopt.c b/src/fs/test_fs_getopt.c index 571346f2c..75512025c 100644 --- a/src/fs/test_fs_getopt.c +++ b/src/fs/test_fs_getopt.c | |||
@@ -25,15 +25,12 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_fs_service.h" | 26 | #include "gnunet_fs_service.h" |
27 | 27 | ||
28 | |||
28 | int | 29 | int |
29 | main (int argc, char *argv[]) | 30 | main (int argc, char *argv[]) |
30 | { | 31 | { |
31 | GNUNET_log_setup ("test_fs_directory", | 32 | GNUNET_log_setup ("test_fs_getopt", |
32 | #if VERBOSE | ||
33 | "DEBUG", | ||
34 | #else | ||
35 | "WARNING", | 33 | "WARNING", |
36 | #endif | ||
37 | NULL); | 34 | NULL); |
38 | FPRINTF (stderr, "%s", "WARNING: testcase not yet written.\n"); | 35 | FPRINTF (stderr, "%s", "WARNING: testcase not yet written.\n"); |
39 | return 0; /* testcase passed */ | 36 | return 0; /* testcase passed */ |
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c index d046a20c6..2b53bc5a4 100644 --- a/src/fs/test_fs_list_indexed.c +++ b/src/fs/test_fs_list_indexed.c | |||
@@ -27,16 +27,11 @@ | |||
27 | * TODO: | 27 | * TODO: |
28 | * - actually call list_indexed API! | 28 | * - actually call list_indexed API! |
29 | */ | 29 | */ |
30 | |||
31 | #include "platform.h" | 30 | #include "platform.h" |
32 | #include "gnunet_util_lib.h" | 31 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_arm_service.h" | 32 | #include "gnunet_testing_lib-new.h" |
34 | #include "gnunet_fs_service.h" | 33 | #include "gnunet_fs_service.h" |
35 | 34 | ||
36 | #define VERBOSE GNUNET_NO | ||
37 | |||
38 | #define START_ARM GNUNET_YES | ||
39 | |||
40 | /** | 35 | /** |
41 | * File-size we use for testing. | 36 | * File-size we use for testing. |
42 | */ | 37 | */ |
@@ -52,15 +47,6 @@ | |||
52 | */ | 47 | */ |
53 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 48 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
54 | 49 | ||
55 | struct PeerContext | ||
56 | { | ||
57 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
58 | #if START_ARM | ||
59 | struct GNUNET_OS_Process *arm_proc; | ||
60 | #endif | ||
61 | }; | ||
62 | |||
63 | static struct PeerContext p1; | ||
64 | 50 | ||
65 | static struct GNUNET_TIME_Absolute start; | 51 | static struct GNUNET_TIME_Absolute start; |
66 | 52 | ||
@@ -74,6 +60,7 @@ static char *fn2; | |||
74 | 60 | ||
75 | static int err; | 61 | static int err; |
76 | 62 | ||
63 | |||
77 | static void | 64 | static void |
78 | abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 65 | abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
79 | { | 66 | { |
@@ -120,14 +107,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
120 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 107 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
121 | ret = event->value.publish.cctx; | 108 | ret = event->value.publish.cctx; |
122 | GNUNET_assert (publish == event->value.publish.pc); | 109 | GNUNET_assert (publish == event->value.publish.pc); |
123 | #if VERBOSE | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
124 | printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", | 111 | "Publish is progressing (%llu/%llu at level %u off %llu)...\n", |
125 | (unsigned long long) event->value.publish.completed, | 112 | (unsigned long long) event->value.publish.completed, |
126 | (unsigned long long) event->value.publish.size, | 113 | (unsigned long long) event->value.publish.size, |
127 | event->value.publish.specifics.progress.depth, | 114 | event->value.publish.specifics.progress.depth, |
128 | (unsigned long long) event->value.publish.specifics. | 115 | (unsigned long long) event->value.publish.specifics. |
129 | progress.offset); | 116 | progress.offset); |
130 | #endif | ||
131 | break; | 117 | break; |
132 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 118 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
133 | ret = event->value.publish.cctx; | 119 | ret = event->value.publish.cctx; |
@@ -183,44 +169,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
183 | 169 | ||
184 | 170 | ||
185 | static void | 171 | static void |
186 | setup_peer (struct PeerContext *p, const char *cfgname) | 172 | run (void *cls, |
187 | { | ||
188 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
189 | #if START_ARM | ||
190 | p->arm_proc = | ||
191 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
192 | "gnunet-service-arm", | ||
193 | #if VERBOSE | ||
194 | "-L", "DEBUG", | ||
195 | #endif | ||
196 | "-c", cfgname, NULL); | ||
197 | #endif | ||
198 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
199 | } | ||
200 | |||
201 | |||
202 | static void | ||
203 | stop_arm (struct PeerContext *p) | ||
204 | { | ||
205 | #if START_ARM | ||
206 | if (NULL != p->arm_proc) | ||
207 | { | ||
208 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
209 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
210 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
211 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
213 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
214 | GNUNET_OS_process_destroy (p->arm_proc); | ||
215 | p->arm_proc = NULL; | ||
216 | } | ||
217 | #endif | ||
218 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
219 | } | ||
220 | |||
221 | |||
222 | static void | ||
223 | run (void *cls, char *const *args, const char *cfgfile, | ||
224 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 173 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
225 | { | 174 | { |
226 | const char *keywords[] = { | 175 | const char *keywords[] = { |
@@ -236,7 +185,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
236 | size_t i; | 185 | size_t i; |
237 | struct GNUNET_FS_BlockOptions bo; | 186 | struct GNUNET_FS_BlockOptions bo; |
238 | 187 | ||
239 | setup_peer (&p1, "test_fs_list_indexed_data.conf"); | ||
240 | fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL, | 188 | fs = GNUNET_FS_start (cfg, "test-fs-list_indexed", &progress_cb, NULL, |
241 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 189 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
242 | GNUNET_assert (NULL != fs); | 190 | GNUNET_assert (NULL != fs); |
@@ -298,41 +246,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
298 | int | 246 | int |
299 | main (int argc, char *argv[]) | 247 | main (int argc, char *argv[]) |
300 | { | 248 | { |
301 | char *const argvx[] = { | 249 | if (0 != GNUNET_TESTING_peer_run ("test-fs-list-indexed", |
302 | "test-fs-list_indexed", | 250 | "test_fs_list_indexed_data.conf", |
303 | "-c", | 251 | &run, NULL)) |
304 | "test_fs_list_indexed_data.conf", | 252 | return 1; |
305 | #if VERBOSE | 253 | return 0; |
306 | "-L", "DEBUG", | ||
307 | #endif | ||
308 | NULL | ||
309 | }; | ||
310 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
311 | GNUNET_GETOPT_OPTION_END | ||
312 | }; | ||
313 | |||
314 | GNUNET_log_setup ("test_fs_list_indexed", | ||
315 | #if VERBOSE | ||
316 | "DEBUG", | ||
317 | #else | ||
318 | "WARNING", | ||
319 | #endif | ||
320 | NULL); | ||
321 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
322 | "test-fs-list_indexed", "nohelp", options, &run, NULL); | ||
323 | stop_arm (&p1); | ||
324 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-list-indexed/"); | ||
325 | if (fn1 != NULL) | ||
326 | { | ||
327 | GNUNET_DISK_directory_remove (fn1); | ||
328 | GNUNET_free (fn1); | ||
329 | } | ||
330 | if (fn2 != NULL) | ||
331 | { | ||
332 | GNUNET_DISK_directory_remove (fn2); | ||
333 | GNUNET_free (fn2); | ||
334 | } | ||
335 | return err; | ||
336 | } | 254 | } |
337 | 255 | ||
338 | /* end of test_fs_list_indexed.c */ | 256 | /* end of test_fs_list_indexed.c */ |
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c index e837b630f..7f0a53344 100644 --- a/src/fs/test_fs_namespace.c +++ b/src/fs/test_fs_namespace.c | |||
@@ -25,14 +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 VERBOSE GNUNET_NO | ||
32 | |||
33 | #define START_ARM GNUNET_YES | ||
34 | |||
35 | static struct PeerContext p1; | ||
36 | 31 | ||
37 | static struct GNUNET_HashCode nsid; | 32 | static struct GNUNET_HashCode nsid; |
38 | 33 | ||
@@ -52,48 +47,6 @@ static int update_started; | |||
52 | 47 | ||
53 | static int err; | 48 | static int err; |
54 | 49 | ||
55 | struct PeerContext | ||
56 | { | ||
57 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
58 | #if START_ARM | ||
59 | struct GNUNET_OS_Process *arm_proc; | ||
60 | #endif | ||
61 | }; | ||
62 | |||
63 | |||
64 | static void | ||
65 | setup_peer (struct PeerContext *p, const char *cfgname) | ||
66 | { | ||
67 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
68 | #if START_ARM | ||
69 | p->arm_proc = | ||
70 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
71 | "gnunet-service-arm", | ||
72 | "-c", cfgname, NULL); | ||
73 | #endif | ||
74 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
75 | } | ||
76 | |||
77 | |||
78 | static void | ||
79 | stop_arm (struct PeerContext *p) | ||
80 | { | ||
81 | #if START_ARM | ||
82 | if (NULL != p->arm_proc) | ||
83 | { | ||
84 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
85 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
86 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
87 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
88 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
89 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
90 | GNUNET_OS_process_destroy (p->arm_proc); | ||
91 | p->arm_proc = NULL; | ||
92 | } | ||
93 | #endif | ||
94 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
95 | } | ||
96 | |||
97 | 50 | ||
98 | static void | 51 | static void |
99 | abort_ksk_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 52 | abort_ksk_search_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -143,7 +96,6 @@ do_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
143 | } | 96 | } |
144 | 97 | ||
145 | 98 | ||
146 | |||
147 | static void * | 99 | static void * |
148 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | 100 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) |
149 | { | 101 | { |
@@ -365,10 +317,9 @@ testNamespace () | |||
365 | 317 | ||
366 | 318 | ||
367 | static void | 319 | static void |
368 | run (void *cls, char *const *args, const char *cfgfile, | 320 | run (void *cls, |
369 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 321 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
370 | { | 322 | { |
371 | setup_peer (&p1, "test_fs_namespace_data.conf"); | ||
372 | fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, | 323 | fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, |
373 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 324 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
374 | testNamespace (); | 325 | testNamespace (); |
@@ -378,28 +329,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
378 | int | 329 | int |
379 | main (int argc, char *argv[]) | 330 | main (int argc, char *argv[]) |
380 | { | 331 | { |
381 | char *const argvx[] = { | 332 | if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace", |
382 | "test-fs-namespace", | 333 | "test_fs_namespace_data.conf", |
383 | "-c", | 334 | &run, NULL)) |
384 | "test_fs_namespace_data.conf", | 335 | return 1; |
385 | NULL | ||
386 | }; | ||
387 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
388 | GNUNET_GETOPT_OPTION_END | ||
389 | }; | ||
390 | |||
391 | GNUNET_log_setup ("test_fs_namespace", | ||
392 | "WARNING", | ||
393 | NULL); | ||
394 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
395 | "test-fs-namespace", "nohelp", options, &run, NULL); | ||
396 | stop_arm (&p1); | ||
397 | if (GNUNET_YES != update_started) | ||
398 | { | ||
399 | FPRINTF (stderr, "%s", "Update search never started!\n"); | ||
400 | err = 1; | ||
401 | } | ||
402 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); | ||
403 | return err; | 336 | return err; |
404 | } | 337 | } |
405 | 338 | ||
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c index 2cec67ddc..50668cac3 100644 --- a/src/fs/test_fs_namespace_list_updateable.c +++ b/src/fs/test_fs_namespace_list_updateable.c | |||
@@ -25,14 +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 VERBOSE GNUNET_NO | ||
32 | |||
33 | #define START_ARM GNUNET_YES | ||
34 | |||
35 | static struct PeerContext p1; | ||
36 | 31 | ||
37 | static struct GNUNET_FS_Handle *fs; | 32 | static struct GNUNET_FS_Handle *fs; |
38 | 33 | ||
@@ -49,15 +44,6 @@ static struct GNUNET_FS_Uri *uri_next; | |||
49 | static struct GNUNET_FS_BlockOptions bo; | 44 | static struct GNUNET_FS_BlockOptions bo; |
50 | 45 | ||
51 | 46 | ||
52 | struct PeerContext | ||
53 | { | ||
54 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
55 | #if START_ARM | ||
56 | struct GNUNET_OS_Process *arm_proc; | ||
57 | #endif | ||
58 | }; | ||
59 | |||
60 | |||
61 | static void * | 47 | static void * |
62 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | 48 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) |
63 | { | 49 | { |
@@ -66,38 +52,8 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
66 | 52 | ||
67 | 53 | ||
68 | static void | 54 | static void |
69 | setup_peer (struct PeerContext *p, const char *cfgname) | 55 | do_shutdown () |
70 | { | 56 | { |
71 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
72 | #if START_ARM | ||
73 | p->arm_proc = | ||
74 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
75 | "gnunet-service-arm", | ||
76 | #if VERBOSE | ||
77 | "-L", "DEBUG", | ||
78 | #endif | ||
79 | "-c", cfgname, NULL); | ||
80 | #endif | ||
81 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
82 | } | ||
83 | |||
84 | |||
85 | static void | ||
86 | stop_arm (struct PeerContext *p) | ||
87 | { | ||
88 | #if START_ARM | ||
89 | if (NULL != p->arm_proc) | ||
90 | { | ||
91 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
92 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
93 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
94 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
96 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
97 | GNUNET_OS_process_destroy (p->arm_proc); | ||
98 | p->arm_proc = NULL; | ||
99 | } | ||
100 | #endif | ||
101 | if (uri_this != NULL) | 57 | if (uri_this != NULL) |
102 | GNUNET_FS_uri_destroy (uri_this); | 58 | GNUNET_FS_uri_destroy (uri_this); |
103 | if (uri_next != NULL) | 59 | if (uri_next != NULL) |
@@ -106,11 +62,9 @@ stop_arm (struct PeerContext *p) | |||
106 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); | 62 | GNUNET_FS_namespace_delete (ns, GNUNET_NO); |
107 | if (meta != NULL) | 63 | if (meta != NULL) |
108 | GNUNET_CONTAINER_meta_data_destroy (meta); | 64 | GNUNET_CONTAINER_meta_data_destroy (meta); |
109 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
110 | } | 65 | } |
111 | 66 | ||
112 | 67 | ||
113 | |||
114 | static void | 68 | static void |
115 | check_next (void *cls, const char *last_id, | 69 | check_next (void *cls, const char *last_id, |
116 | const struct GNUNET_FS_Uri *last_uri, | 70 | const struct GNUNET_FS_Uri *last_uri, |
@@ -143,7 +97,6 @@ sks_cont_next (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) | |||
143 | GNUNET_assert (NULL == emsg); | 97 | GNUNET_assert (NULL == emsg); |
144 | err += 2; | 98 | err += 2; |
145 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this_next, NULL); | 99 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this_next, NULL); |
146 | |||
147 | } | 100 | } |
148 | 101 | ||
149 | 102 | ||
@@ -162,7 +115,6 @@ check_this (void *cls, const char *last_id, | |||
162 | static void | 115 | static void |
163 | sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) | 116 | sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) |
164 | { | 117 | { |
165 | |||
166 | GNUNET_assert (NULL == emsg); | 118 | GNUNET_assert (NULL == emsg); |
167 | err = 1; | 119 | err = 1; |
168 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL); | 120 | GNUNET_FS_namespace_list_updateable (ns, NULL, &check_this, NULL); |
@@ -172,11 +124,9 @@ sks_cont_this (void *cls, const struct GNUNET_FS_Uri *uri, const char *emsg) | |||
172 | } | 124 | } |
173 | 125 | ||
174 | 126 | ||
175 | |||
176 | static void | 127 | static void |
177 | testNamespace () | 128 | testNamespace () |
178 | { | 129 | { |
179 | |||
180 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); | 130 | ns = GNUNET_FS_namespace_create (fs, "testNamespace"); |
181 | GNUNET_assert (NULL != ns); | 131 | GNUNET_assert (NULL != ns); |
182 | bo.content_priority = 1; | 132 | bo.content_priority = 1; |
@@ -200,10 +150,9 @@ testNamespace () | |||
200 | 150 | ||
201 | 151 | ||
202 | static void | 152 | static void |
203 | run (void *cls, char *const *args, const char *cfgfile, | 153 | run (void *cls, |
204 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 154 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
205 | { | 155 | { |
206 | setup_peer (&p1, "test_fs_namespace_data.conf"); | ||
207 | fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, | 156 | fs = GNUNET_FS_start (cfg, "test-fs-namespace", &progress_cb, NULL, |
208 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 157 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
209 | testNamespace (); | 158 | testNamespace (); |
@@ -213,30 +162,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
213 | int | 162 | int |
214 | main (int argc, char *argv[]) | 163 | main (int argc, char *argv[]) |
215 | { | 164 | { |
216 | char *const argvx[] = { | 165 | if (0 != GNUNET_TESTING_peer_run ("test-fs-namespace-list-updateable", |
217 | "test-fs-namespace", | 166 | "test_fs_namespace_data.conf", |
218 | "-c", | 167 | &run, NULL)) |
219 | "test_fs_namespace_data.conf", | 168 | return 1; |
220 | #if VERBOSE | 169 | do_shutdown (); |
221 | "-L", "DEBUG", | ||
222 | #endif | ||
223 | NULL | ||
224 | }; | ||
225 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
226 | GNUNET_GETOPT_OPTION_END | ||
227 | }; | ||
228 | |||
229 | GNUNET_log_setup ("test_fs_namespace_list_updateable", | ||
230 | #if VERBOSE | ||
231 | "DEBUG", | ||
232 | #else | ||
233 | "WARNING", | ||
234 | #endif | ||
235 | NULL); | ||
236 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
237 | "test-fs-namespace", "nohelp", options, &run, NULL); | ||
238 | stop_arm (&p1); | ||
239 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-namespace/"); | ||
240 | return err; | 170 | return err; |
241 | } | 171 | } |
242 | 172 | ||
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c index ee76bf9f3..52e1845a7 100644 --- a/src/fs/test_fs_unindex.c +++ b/src/fs/test_fs_unindex.c | |||
@@ -23,15 +23,11 @@ | |||
23 | * @brief simple testcase for simple publish + unindex operation | 23 | * @brief simple testcase for simple publish + unindex operation |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | |||
27 | #include "platform.h" | 26 | #include "platform.h" |
28 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_arm_service.h" | ||
30 | #include "gnunet_fs_service.h" | 28 | #include "gnunet_fs_service.h" |
29 | #include "gnunet_testing_lib-new.h" | ||
31 | 30 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | #define START_ARM GNUNET_YES | ||
35 | 31 | ||
36 | /** | 32 | /** |
37 | * File-size we use for testing. | 33 | * File-size we use for testing. |
@@ -48,15 +44,6 @@ | |||
48 | */ | 44 | */ |
49 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 45 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
50 | 46 | ||
51 | struct PeerContext | ||
52 | { | ||
53 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
54 | #if START_ARM | ||
55 | struct GNUNET_OS_Process *arm_proc; | ||
56 | #endif | ||
57 | }; | ||
58 | |||
59 | static struct PeerContext p1; | ||
60 | 47 | ||
61 | static struct GNUNET_TIME_Absolute start; | 48 | static struct GNUNET_TIME_Absolute start; |
62 | 49 | ||
@@ -95,14 +82,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
95 | switch (event->status) | 82 | switch (event->status) |
96 | { | 83 | { |
97 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 84 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
98 | #if VERBOSE | 85 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
99 | printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", | 86 | "Publish is progressing (%llu/%llu at level %u off %llu)...\n", |
100 | (unsigned long long) event->value.publish.completed, | 87 | (unsigned long long) event->value.publish.completed, |
101 | (unsigned long long) event->value.publish.size, | 88 | (unsigned long long) event->value.publish.size, |
102 | event->value.publish.specifics.progress.depth, | 89 | event->value.publish.specifics.progress.depth, |
103 | (unsigned long long) event->value.publish.specifics. | 90 | (unsigned long long) event->value.publish.specifics. |
104 | progress.offset); | 91 | progress.offset); |
105 | #endif | ||
106 | break; | 92 | break; |
107 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 93 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
108 | printf ("Publishing complete, %llu kbps.\n", | 94 | printf ("Publishing complete, %llu kbps.\n", |
@@ -125,14 +111,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
125 | break; | 111 | break; |
126 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | 112 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: |
127 | GNUNET_assert (unindex == event->value.unindex.uc); | 113 | GNUNET_assert (unindex == event->value.unindex.uc); |
128 | #if VERBOSE | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
129 | printf ("Unindex is progressing (%llu/%llu at level %u off %llu)...\n", | 115 | "Unindex is progressing (%llu/%llu at level %u off %llu)...\n", |
130 | (unsigned long long) event->value.unindex.completed, | 116 | (unsigned long long) event->value.unindex.completed, |
131 | (unsigned long long) event->value.unindex.size, | 117 | (unsigned long long) event->value.unindex.size, |
132 | event->value.unindex.specifics.progress.depth, | 118 | event->value.unindex.specifics.progress.depth, |
133 | (unsigned long long) event->value.unindex.specifics. | 119 | (unsigned long long) event->value.unindex.specifics. |
134 | progress.offset); | 120 | progress.offset); |
135 | #endif | ||
136 | break; | 121 | break; |
137 | case GNUNET_FS_STATUS_PUBLISH_ERROR: | 122 | case GNUNET_FS_STATUS_PUBLISH_ERROR: |
138 | FPRINTF (stderr, "Error publishing file: %s\n", | 123 | FPRINTF (stderr, "Error publishing file: %s\n", |
@@ -182,44 +167,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
182 | 167 | ||
183 | 168 | ||
184 | static void | 169 | static void |
185 | setup_peer (struct PeerContext *p, const char *cfgname) | 170 | run (void *cls, |
186 | { | ||
187 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
188 | #if START_ARM | ||
189 | p->arm_proc = | ||
190 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
191 | "gnunet-service-arm", | ||
192 | #if VERBOSE | ||
193 | "-L", "DEBUG", | ||
194 | #endif | ||
195 | "-c", cfgname, NULL); | ||
196 | #endif | ||
197 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
198 | } | ||
199 | |||
200 | |||
201 | static void | ||
202 | stop_arm (struct PeerContext *p) | ||
203 | { | ||
204 | #if START_ARM | ||
205 | if (NULL != p->arm_proc) | ||
206 | { | ||
207 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
208 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
209 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
210 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
211 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
212 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
213 | GNUNET_OS_process_destroy (p->arm_proc); | ||
214 | p->arm_proc = NULL; | ||
215 | } | ||
216 | #endif | ||
217 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
218 | } | ||
219 | |||
220 | |||
221 | static void | ||
222 | run (void *cls, char *const *args, const char *cfgfile, | ||
223 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 171 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
224 | { | 172 | { |
225 | const char *keywords[] = { | 173 | const char *keywords[] = { |
@@ -233,7 +181,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
233 | size_t i; | 181 | size_t i; |
234 | struct GNUNET_FS_BlockOptions bo; | 182 | struct GNUNET_FS_BlockOptions bo; |
235 | 183 | ||
236 | setup_peer (&p1, "test_fs_unindex_data.conf"); | ||
237 | fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); | 184 | fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); |
238 | fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL, | 185 | fs = GNUNET_FS_start (cfg, "test-fs-unindex", &progress_cb, NULL, |
239 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 186 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
@@ -269,35 +216,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
269 | int | 216 | int |
270 | main (int argc, char *argv[]) | 217 | main (int argc, char *argv[]) |
271 | { | 218 | { |
272 | char *const argvx[] = { | 219 | if (0 != GNUNET_TESTING_peer_run ("test-fs-unindex", |
273 | "test-fs-unindex", | 220 | "test_fs_unindex_data.conf", |
274 | "-c", | 221 | &run, NULL)) |
275 | "test_fs_unindex_data.conf", | 222 | return 1; |
276 | #if VERBOSE | ||
277 | "-L", "DEBUG", | ||
278 | #endif | ||
279 | NULL | ||
280 | }; | ||
281 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
282 | GNUNET_GETOPT_OPTION_END | ||
283 | }; | ||
284 | |||
285 | GNUNET_log_setup ("test_fs_unindex", | ||
286 | #if VERBOSE | ||
287 | "DEBUG", | ||
288 | #else | ||
289 | "WARNING", | ||
290 | #endif | ||
291 | NULL); | ||
292 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
293 | "test-fs-unindex", "nohelp", options, &run, NULL); | ||
294 | stop_arm (&p1); | ||
295 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); | ||
296 | if (NULL != fn) | ||
297 | { | ||
298 | GNUNET_DISK_directory_remove (fn); | ||
299 | GNUNET_free (fn); | ||
300 | } | ||
301 | return 0; | 223 | return 0; |
302 | } | 224 | } |
303 | 225 | ||
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c index c6b1062e1..8f4364c28 100644 --- a/src/fs/test_fs_unindex_persistence.c +++ b/src/fs/test_fs_unindex_persistence.c | |||
@@ -25,13 +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 VERBOSE GNUNET_NO | ||
32 | |||
33 | #define START_ARM GNUNET_YES | ||
34 | |||
35 | /** | 31 | /** |
36 | * File-size we use for testing. | 32 | * File-size we use for testing. |
37 | */ | 33 | */ |
@@ -47,15 +43,6 @@ | |||
47 | */ | 43 | */ |
48 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 44 | #define LIFETIME GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
49 | 45 | ||
50 | struct PeerContext | ||
51 | { | ||
52 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
53 | #if START_ARM | ||
54 | struct GNUNET_OS_Process *arm_proc; | ||
55 | #endif | ||
56 | }; | ||
57 | |||
58 | static struct PeerContext p1; | ||
59 | 46 | ||
60 | static struct GNUNET_TIME_Absolute start; | 47 | static struct GNUNET_TIME_Absolute start; |
61 | 48 | ||
@@ -69,6 +56,7 @@ static char *fn; | |||
69 | 56 | ||
70 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 57 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
71 | 58 | ||
59 | |||
72 | static void | 60 | static void |
73 | abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 61 | abort_publish_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
74 | { | 62 | { |
@@ -136,14 +124,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
136 | switch (event->status) | 124 | switch (event->status) |
137 | { | 125 | { |
138 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 126 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
139 | #if VERBOSE | 127 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
140 | printf ("Publish is progressing (%llu/%llu at level %u off %llu)...\n", | 128 | "Publish is progressing (%llu/%llu at level %u off %llu)...\n", |
141 | (unsigned long long) event->value.publish.completed, | 129 | (unsigned long long) event->value.publish.completed, |
142 | (unsigned long long) event->value.publish.size, | 130 | (unsigned long long) event->value.publish.size, |
143 | event->value.publish.specifics.progress.depth, | 131 | event->value.publish.specifics.progress.depth, |
144 | (unsigned long long) event->value.publish.specifics. | 132 | (unsigned long long) event->value.publish.specifics. |
145 | progress.offset); | 133 | progress.offset); |
146 | #endif | ||
147 | break; | 134 | break; |
148 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: | 135 | case GNUNET_FS_STATUS_PUBLISH_COMPLETED: |
149 | printf ("Publishing complete, %llu kbps.\n", | 136 | printf ("Publishing complete, %llu kbps.\n", |
@@ -167,14 +154,13 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
167 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: | 154 | case GNUNET_FS_STATUS_UNINDEX_PROGRESS: |
168 | consider_restart (event->status); | 155 | consider_restart (event->status); |
169 | GNUNET_assert (unindex == event->value.unindex.uc); | 156 | GNUNET_assert (unindex == event->value.unindex.uc); |
170 | #if VERBOSE | 157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
171 | printf ("Unindex is progressing (%llu/%llu at level %u off %llu)...\n", | 158 | "Unindex is progressing (%llu/%llu at level %u off %llu)...\n", |
172 | (unsigned long long) event->value.unindex.completed, | 159 | (unsigned long long) event->value.unindex.completed, |
173 | (unsigned long long) event->value.unindex.size, | 160 | (unsigned long long) event->value.unindex.size, |
174 | event->value.unindex.specifics.progress.depth, | 161 | event->value.unindex.specifics.progress.depth, |
175 | (unsigned long long) event->value.unindex.specifics. | 162 | (unsigned long long) event->value.unindex.specifics. |
176 | progress.offset); | 163 | progress.offset); |
177 | #endif | ||
178 | break; | 164 | break; |
179 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | 165 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: |
180 | if (event->value.publish.pc == publish) | 166 | if (event->value.publish.pc == publish) |
@@ -244,44 +230,7 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
244 | 230 | ||
245 | 231 | ||
246 | static void | 232 | static void |
247 | setup_peer (struct PeerContext *p, const char *cfgname) | 233 | run (void *cls, |
248 | { | ||
249 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
250 | #if START_ARM | ||
251 | p->arm_proc = | ||
252 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
253 | "gnunet-service-arm", | ||
254 | #if VERBOSE | ||
255 | "-L", "DEBUG", | ||
256 | #endif | ||
257 | "-c", cfgname, NULL); | ||
258 | #endif | ||
259 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
260 | } | ||
261 | |||
262 | |||
263 | static void | ||
264 | stop_arm (struct PeerContext *p) | ||
265 | { | ||
266 | #if START_ARM | ||
267 | if (NULL != p->arm_proc) | ||
268 | { | ||
269 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
270 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
271 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
272 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
274 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
275 | GNUNET_OS_process_destroy (p->arm_proc); | ||
276 | p->arm_proc = NULL; | ||
277 | } | ||
278 | #endif | ||
279 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
280 | } | ||
281 | |||
282 | |||
283 | static void | ||
284 | run (void *cls, char *const *args, const char *cfgfile, | ||
285 | const struct GNUNET_CONFIGURATION_Handle *c) | 234 | const struct GNUNET_CONFIGURATION_Handle *c) |
286 | { | 235 | { |
287 | const char *keywords[] = { | 236 | const char *keywords[] = { |
@@ -296,7 +245,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
296 | struct GNUNET_FS_BlockOptions bo; | 245 | struct GNUNET_FS_BlockOptions bo; |
297 | 246 | ||
298 | cfg = c; | 247 | cfg = c; |
299 | setup_peer (&p1, "test_fs_unindex_data.conf"); | ||
300 | fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); | 248 | fn = GNUNET_DISK_mktemp ("gnunet-unindex-test-dst"); |
301 | fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, | 249 | fs = GNUNET_FS_start (cfg, "test-fs-unindex-persistence", &progress_cb, NULL, |
302 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); | 250 | GNUNET_FS_FLAGS_PERSISTENCE, GNUNET_FS_OPTIONS_END); |
@@ -332,35 +280,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
332 | int | 280 | int |
333 | main (int argc, char *argv[]) | 281 | main (int argc, char *argv[]) |
334 | { | 282 | { |
335 | char *const argvx[] = { | 283 | if (0 != GNUNET_TESTING_peer_run ("test-fs-unindex-persistence", |
336 | "test-fs-unindex", | 284 | "test_fs_unindex_data.conf", |
337 | "-c", | 285 | &run, NULL)) |
338 | "test_fs_unindex_data.conf", | 286 | return 1; |
339 | #if VERBOSE | ||
340 | "-L", "DEBUG", | ||
341 | #endif | ||
342 | NULL | ||
343 | }; | ||
344 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
345 | GNUNET_GETOPT_OPTION_END | ||
346 | }; | ||
347 | |||
348 | GNUNET_log_setup ("test_fs_unindex_persistence", | ||
349 | #if VERBOSE | ||
350 | "DEBUG", | ||
351 | #else | ||
352 | "WARNING", | ||
353 | #endif | ||
354 | NULL); | ||
355 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
356 | "test-fs-unindex", "nohelp", options, &run, NULL); | ||
357 | stop_arm (&p1); | ||
358 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-unindex/"); | ||
359 | if (NULL != fn) | ||
360 | { | ||
361 | GNUNET_DISK_directory_remove (fn); | ||
362 | GNUNET_free (fn); | ||
363 | } | ||
364 | return 0; | 287 | return 0; |
365 | } | 288 | } |
366 | 289 | ||