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/fs/test_fs_namespace.c | |
parent | 9f4e1f6e097b3c97abe0971b68b2ab686a61f036 (diff) | |
download | gnunet-e825548ea9a45d1f4b25898f87b5c74f8bc4cc25.tar.gz gnunet-e825548ea9a45d1f4b25898f87b5c74f8bc4cc25.zip |
-simplifying tests with new testing lib
Diffstat (limited to 'src/fs/test_fs_namespace.c')
-rw-r--r-- | src/fs/test_fs_namespace.c | 79 |
1 files changed, 6 insertions, 73 deletions
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 | ||