diff options
Diffstat (limited to 'src/ats/test_ats_api_scheduling_destroy_session.c')
-rw-r--r-- | src/ats/test_ats_api_scheduling_destroy_session.c | 69 |
1 files changed, 15 insertions, 54 deletions
diff --git a/src/ats/test_ats_api_scheduling_destroy_session.c b/src/ats/test_ats_api_scheduling_destroy_session.c index 7d223a71e..722102b32 100644 --- a/src/ats/test_ats_api_scheduling_destroy_session.c +++ b/src/ats/test_ats_api_scheduling_destroy_session.c | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_ats_service.h" | 29 | #include "gnunet_ats_service.h" |
30 | #include "gnunet_testing_lib-new.h" | ||
30 | #include "ats.h" | 31 | #include "ats.h" |
31 | 32 | ||
32 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
@@ -35,11 +36,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task; | |||
35 | 36 | ||
36 | static struct GNUNET_ATS_SchedulingHandle *ats; | 37 | static struct GNUNET_ATS_SchedulingHandle *ats; |
37 | 38 | ||
38 | struct GNUNET_OS_Process *arm_proc; | ||
39 | |||
40 | |||
41 | |||
42 | static int ret; | 39 | static int ret; |
40 | |||
43 | static int stage; | 41 | static int stage; |
44 | 42 | ||
45 | struct Address | 43 | struct Address |
@@ -63,20 +61,12 @@ struct PeerContext | |||
63 | struct Address *addr; | 61 | struct Address *addr; |
64 | }; | 62 | }; |
65 | 63 | ||
66 | struct Address test_addr; | ||
67 | struct PeerContext p; | ||
68 | struct GNUNET_ATS_Information atsi; | ||
69 | struct GNUNET_HELLO_Address hello_address; | ||
70 | 64 | ||
71 | static void | 65 | static struct Address test_addr; |
72 | stop_arm () | 66 | |
73 | { | 67 | static struct PeerContext p; |
74 | if (0 != GNUNET_OS_process_kill (arm_proc, SIGTERM)) | 68 | |
75 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 69 | static struct GNUNET_HELLO_Address hello_address; |
76 | GNUNET_OS_process_wait (arm_proc); | ||
77 | GNUNET_OS_process_destroy (arm_proc); | ||
78 | arm_proc = NULL; | ||
79 | } | ||
80 | 70 | ||
81 | 71 | ||
82 | static void | 72 | static void |
@@ -85,10 +75,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
85 | die_task = GNUNET_SCHEDULER_NO_TASK; | 75 | die_task = GNUNET_SCHEDULER_NO_TASK; |
86 | if (ats != NULL) | 76 | if (ats != NULL) |
87 | GNUNET_ATS_scheduling_done (ats); | 77 | GNUNET_ATS_scheduling_done (ats); |
88 | |||
89 | ret = GNUNET_SYSERR; | 78 | ret = GNUNET_SYSERR; |
90 | |||
91 | stop_arm (); | ||
92 | } | 79 | } |
93 | 80 | ||
94 | 81 | ||
@@ -101,9 +88,7 @@ end () | |||
101 | GNUNET_SCHEDULER_cancel (die_task); | 88 | GNUNET_SCHEDULER_cancel (die_task); |
102 | die_task = GNUNET_SCHEDULER_NO_TASK; | 89 | die_task = GNUNET_SCHEDULER_NO_TASK; |
103 | } | 90 | } |
104 | |||
105 | GNUNET_ATS_scheduling_done (ats); | 91 | GNUNET_ATS_scheduling_done (ats); |
106 | |||
107 | if (2 == stage) | 92 | if (2 == stage) |
108 | ret = 0; | 93 | ret = 0; |
109 | else | 94 | else |
@@ -111,8 +96,6 @@ end () | |||
111 | GNUNET_break (0); | 96 | GNUNET_break (0); |
112 | ret = 1; | 97 | ret = 1; |
113 | } | 98 | } |
114 | |||
115 | stop_arm (); | ||
116 | } | 99 | } |
117 | 100 | ||
118 | 101 | ||
@@ -167,26 +150,16 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
167 | stage++; | 150 | stage++; |
168 | } | 151 | } |
169 | 152 | ||
170 | void | ||
171 | start_arm (const char *cfgname) | ||
172 | { | ||
173 | arm_proc = | ||
174 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
175 | "gnunet-service-arm", | ||
176 | "-c", cfgname, NULL); | ||
177 | } | ||
178 | 153 | ||
179 | static void | 154 | static void |
180 | check (void *cls, char *const *args, const char *cfgfile, | 155 | run (void *cls, |
181 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 156 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
157 | struct GNUNET_TESTING_Peer *peer) | ||
182 | { | 158 | { |
183 | ret = GNUNET_SYSERR; | 159 | ret = GNUNET_SYSERR; |
184 | 160 | ||
185 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 161 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
186 | start_arm (cfgfile); | ||
187 | |||
188 | ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); | 162 | ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); |
189 | |||
190 | if (ats == NULL) | 163 | if (ats == NULL) |
191 | { | 164 | { |
192 | ret = GNUNET_SYSERR; | 165 | ret = GNUNET_SYSERR; |
@@ -211,29 +184,17 @@ check (void *cls, char *const *args, const char *cfgfile, | |||
211 | hello_address.address = test_addr.addr; | 184 | hello_address.address = test_addr.addr; |
212 | hello_address.address_length = test_addr.addr_len; | 185 | hello_address.address_length = test_addr.addr_len; |
213 | GNUNET_ATS_address_add (ats, &hello_address, test_addr.session, NULL, 0); | 186 | GNUNET_ATS_address_add (ats, &hello_address, test_addr.session, NULL, 0); |
214 | |||
215 | GNUNET_ATS_suggest_address (ats, &p.id); | 187 | GNUNET_ATS_suggest_address (ats, &p.id); |
216 | } | 188 | } |
217 | 189 | ||
190 | |||
218 | int | 191 | int |
219 | main (int argc, char *argv[]) | 192 | main (int argc, char *argv[]) |
220 | { | 193 | { |
221 | static char *const argv2[] = { "test_ats_api_scheduling_destroy_session", | 194 | if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_destroy_session", |
222 | "-c", | 195 | "test_ats_api.conf", |
223 | "test_ats_api.conf", | 196 | &run, NULL)) |
224 | "-L", "WARNING", | 197 | return 1; |
225 | NULL | ||
226 | }; | ||
227 | |||
228 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
229 | GNUNET_GETOPT_OPTION_END | ||
230 | }; | ||
231 | |||
232 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | ||
233 | "test_ats_api_scheduling_destroy_session", "nohelp", options, &check, | ||
234 | NULL); | ||
235 | |||
236 | |||
237 | return ret; | 198 | return ret; |
238 | } | 199 | } |
239 | 200 | ||