diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-23 21:24:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-23 21:24:12 +0000 |
commit | 9f77bf9ff14edd69e58ff17e16f51663ae945c46 (patch) | |
tree | 622dd28051c1d8d4fd50ed32bc60d066749181a7 /src/core/test_core_api_start_only.c | |
parent | da5597cf69b9bb505c0171490a6fefe358583f63 (diff) | |
download | gnunet-9f77bf9ff14edd69e58ff17e16f51663ae945c46.tar.gz gnunet-9f77bf9ff14edd69e58ff17e16f51663ae945c46.zip |
-use testing lib
Diffstat (limited to 'src/core/test_core_api_start_only.c')
-rw-r--r-- | src/core/test_core_api_start_only.c | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 308814b21..7704b4387 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c | |||
@@ -31,12 +31,8 @@ | |||
31 | #include "gnunet_program_lib.h" | 31 | #include "gnunet_program_lib.h" |
32 | #include "gnunet_scheduler_lib.h" | 32 | #include "gnunet_scheduler_lib.h" |
33 | 33 | ||
34 | #define VERBOSE GNUNET_NO | ||
35 | |||
36 | #define TIMEOUT 5 | 34 | #define TIMEOUT 5 |
37 | 35 | ||
38 | #define START_ARM GNUNET_YES | ||
39 | |||
40 | #define MTYPE 12345 | 36 | #define MTYPE 12345 |
41 | 37 | ||
42 | struct PeerContext | 38 | struct PeerContext |
@@ -44,9 +40,7 @@ struct PeerContext | |||
44 | struct GNUNET_CONFIGURATION_Handle *cfg; | 40 | struct GNUNET_CONFIGURATION_Handle *cfg; |
45 | struct GNUNET_CORE_Handle *ch; | 41 | struct GNUNET_CORE_Handle *ch; |
46 | struct GNUNET_PeerIdentity id; | 42 | struct GNUNET_PeerIdentity id; |
47 | #if START_ARM | ||
48 | struct GNUNET_OS_Process *arm_proc; | 43 | struct GNUNET_OS_Process *arm_proc; |
49 | #endif | ||
50 | }; | 44 | }; |
51 | 45 | ||
52 | static struct PeerContext p1; | 46 | static struct PeerContext p1; |
@@ -115,8 +109,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
115 | } | 109 | } |
116 | 110 | ||
117 | 111 | ||
118 | |||
119 | |||
120 | static void | 112 | static void |
121 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, | 113 | init_notify (void *cls, struct GNUNET_CORE_Handle *server, |
122 | const struct GNUNET_PeerIdentity *my_identity) | 114 | const struct GNUNET_PeerIdentity *my_identity) |
@@ -146,15 +138,10 @@ static void | |||
146 | setup_peer (struct PeerContext *p, const char *cfgname) | 138 | setup_peer (struct PeerContext *p, const char *cfgname) |
147 | { | 139 | { |
148 | p->cfg = GNUNET_CONFIGURATION_create (); | 140 | p->cfg = GNUNET_CONFIGURATION_create (); |
149 | #if START_ARM | ||
150 | p->arm_proc = | 141 | p->arm_proc = |
151 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | 142 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", |
152 | "gnunet-service-arm", | 143 | "gnunet-service-arm", |
153 | #if VERBOSE | ||
154 | "-L", "DEBUG", | ||
155 | #endif | ||
156 | "-c", cfgname, NULL); | 144 | "-c", cfgname, NULL); |
157 | #endif | ||
158 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 145 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
159 | } | 146 | } |
160 | 147 | ||
@@ -177,7 +164,6 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
177 | } | 164 | } |
178 | 165 | ||
179 | 166 | ||
180 | |||
181 | static void | 167 | static void |
182 | run (void *cls, char *const *args, const char *cfgfile, | 168 | run (void *cls, char *const *args, const char *cfgfile, |
183 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 169 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -201,7 +187,6 @@ static void | |||
201 | stop_arm (struct PeerContext *p) | 187 | stop_arm (struct PeerContext *p) |
202 | { | 188 | { |
203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer\n"); | 189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer\n"); |
204 | #if START_ARM | ||
205 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | 190 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) |
206 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 191 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
207 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | 192 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
@@ -210,7 +195,6 @@ stop_arm (struct PeerContext *p) | |||
210 | GNUNET_OS_process_get_pid (p->arm_proc)); | 195 | GNUNET_OS_process_get_pid (p->arm_proc)); |
211 | GNUNET_OS_process_destroy (p->arm_proc); | 196 | GNUNET_OS_process_destroy (p->arm_proc); |
212 | p->arm_proc = NULL; | 197 | p->arm_proc = NULL; |
213 | #endif | ||
214 | GNUNET_CONFIGURATION_destroy (p->cfg); | 198 | GNUNET_CONFIGURATION_destroy (p->cfg); |
215 | } | 199 | } |
216 | 200 | ||
@@ -221,9 +205,6 @@ check () | |||
221 | char *const argv[] = { "test-core-api-start-only", | 205 | char *const argv[] = { "test-core-api-start-only", |
222 | "-c", | 206 | "-c", |
223 | "test_core_api_data.conf", | 207 | "test_core_api_data.conf", |
224 | #if VERBOSE | ||
225 | "-L", "DEBUG", | ||
226 | #endif | ||
227 | NULL | 208 | NULL |
228 | }; | 209 | }; |
229 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 210 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -241,17 +222,14 @@ check () | |||
241 | return ok; | 222 | return ok; |
242 | } | 223 | } |
243 | 224 | ||
225 | |||
244 | int | 226 | int |
245 | main (int argc, char *argv[]) | 227 | main (int argc, char *argv[]) |
246 | { | 228 | { |
247 | int ret; | 229 | int ret; |
248 | 230 | ||
249 | GNUNET_log_setup ("test-core-api-start-only", | 231 | GNUNET_log_setup ("test-core-api-start-only", |
250 | #if VERBOSE | ||
251 | "DEBUG", | ||
252 | #else | ||
253 | "WARNING", | 232 | "WARNING", |
254 | #endif | ||
255 | NULL); | 233 | NULL); |
256 | ret = check (); | 234 | ret = check (); |
257 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 235 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); |