aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_start_only.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-23 21:24:12 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-23 21:24:12 +0000
commit9f77bf9ff14edd69e58ff17e16f51663ae945c46 (patch)
tree622dd28051c1d8d4fd50ed32bc60d066749181a7 /src/core/test_core_api_start_only.c
parentda5597cf69b9bb505c0171490a6fefe358583f63 (diff)
downloadgnunet-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.c24
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
42struct PeerContext 38struct 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
52static struct PeerContext p1; 46static 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
120static void 112static void
121init_notify (void *cls, struct GNUNET_CORE_Handle *server, 113init_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
146setup_peer (struct PeerContext *p, const char *cfgname) 138setup_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
181static void 167static void
182run (void *cls, char *const *args, const char *cfgfile, 168run (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
201stop_arm (struct PeerContext *p) 187stop_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
244int 226int
245main (int argc, char *argv[]) 227main (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");