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_start_stop.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_start_stop.c')
-rw-r--r-- | src/fs/test_fs_start_stop.c | 85 |
1 files changed, 6 insertions, 79 deletions
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c index 6bd698a43..f3dff69f6 100644 --- a/src/fs/test_fs_start_stop.c +++ b/src/fs/test_fs_start_stop.c | |||
@@ -17,7 +17,6 @@ | |||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | |||
21 | /** | 20 | /** |
22 | * @file fs/test_fs_start_stop.c | 21 | * @file fs/test_fs_start_stop.c |
23 | * @brief testcase for fs.c (start-stop only) | 22 | * @brief testcase for fs.c (start-stop only) |
@@ -26,23 +25,9 @@ | |||
26 | 25 | ||
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" | 28 | #include "gnunet_testing_lib-new.h" |
30 | #include "gnunet_fs_service.h" | 29 | #include "gnunet_fs_service.h" |
31 | 30 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | #define START_ARM GNUNET_YES | ||
35 | |||
36 | static struct PeerContext p1; | ||
37 | |||
38 | struct PeerContext | ||
39 | { | ||
40 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
41 | #if START_ARM | ||
42 | struct GNUNET_OS_Process *arm_proc; | ||
43 | #endif | ||
44 | }; | ||
45 | |||
46 | 31 | ||
47 | static void * | 32 | static void * |
48 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | 33 | progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) |
@@ -52,49 +37,11 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *event) | |||
52 | 37 | ||
53 | 38 | ||
54 | static void | 39 | static void |
55 | setup_peer (struct PeerContext *p, const char *cfgname) | 40 | run (void *cls, |
56 | { | ||
57 | p->cfg = GNUNET_CONFIGURATION_create (); | ||
58 | #if START_ARM | ||
59 | p->arm_proc = | ||
60 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
61 | "gnunet-service-arm", | ||
62 | #if VERBOSE | ||
63 | "-L", "DEBUG", | ||
64 | #endif | ||
65 | "-c", cfgname, NULL); | ||
66 | #endif | ||
67 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | ||
68 | } | ||
69 | |||
70 | |||
71 | static void | ||
72 | stop_arm (struct PeerContext *p) | ||
73 | { | ||
74 | #if START_ARM | ||
75 | if (NULL != p->arm_proc) | ||
76 | { | ||
77 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | ||
78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
79 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | ||
80 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
81 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ARM process %u stopped\n", | ||
82 | GNUNET_OS_process_get_pid (p->arm_proc)); | ||
83 | GNUNET_OS_process_destroy (p->arm_proc); | ||
84 | p->arm_proc = NULL; | ||
85 | } | ||
86 | #endif | ||
87 | GNUNET_CONFIGURATION_destroy (p->cfg); | ||
88 | } | ||
89 | |||
90 | |||
91 | static void | ||
92 | run (void *cls, char *const *args, const char *cfgfile, | ||
93 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 41 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
94 | { | 42 | { |
95 | struct GNUNET_FS_Handle *fs; | 43 | struct GNUNET_FS_Handle *fs; |
96 | 44 | ||
97 | setup_peer (&p1, "test_fs_data.conf"); | ||
98 | fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL, | 45 | fs = GNUNET_FS_start (cfg, "test-fs-start-stop", &progress_cb, NULL, |
99 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); | 46 | GNUNET_FS_FLAGS_NONE, GNUNET_FS_OPTIONS_END); |
100 | GNUNET_assert (NULL != fs); | 47 | GNUNET_assert (NULL != fs); |
@@ -105,30 +52,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
105 | int | 52 | int |
106 | main (int argc, char *argv[]) | 53 | main (int argc, char *argv[]) |
107 | { | 54 | { |
108 | char *const argvx[] = { | 55 | if (0 != GNUNET_TESTING_peer_run ("test-fs-start-stop", |
109 | "test-fs-start-stop", | 56 | "test_fs_data.conf", |
110 | "-c", | 57 | &run, NULL)) |
111 | "test_fs_data.conf", | 58 | return 1; |
112 | #if VERBOSE | ||
113 | "-L", "DEBUG", | ||
114 | #endif | ||
115 | NULL | ||
116 | }; | ||
117 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
118 | GNUNET_GETOPT_OPTION_END | ||
119 | }; | ||
120 | |||
121 | GNUNET_log_setup ("test_fs_start_stop", | ||
122 | #if VERBOSE | ||
123 | "DEBUG", | ||
124 | #else | ||
125 | "WARNING", | ||
126 | #endif | ||
127 | NULL); | ||
128 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, | ||
129 | "test-fs-start-stop", "nohelp", options, &run, NULL); | ||
130 | stop_arm (&p1); | ||
131 | GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs/"); | ||
132 | return 0; | 59 | return 0; |
133 | } | 60 | } |
134 | 61 | ||