diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-05-05 15:35:43 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-05-05 15:35:43 +0000 |
commit | 7181a8fb4f75af69d82709b975ffb9c991e45ec7 (patch) | |
tree | acc2e1469e383ab4cf654c1be3ff17ab375940e5 /src/transport/test_plugin_transport_http.c | |
parent | 8f086c06169388510f0742b165a232cf7199843f (diff) | |
download | gnunet-7181a8fb4f75af69d82709b975ffb9c991e45ec7.tar.gz gnunet-7181a8fb4f75af69d82709b975ffb9c991e45ec7.zip |
Diffstat (limited to 'src/transport/test_plugin_transport_http.c')
-rw-r--r-- | src/transport/test_plugin_transport_http.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/transport/test_plugin_transport_http.c b/src/transport/test_plugin_transport_http.c index a7a2c2cb7..0412badd4 100644 --- a/src/transport/test_plugin_transport_http.c +++ b/src/transport/test_plugin_transport_http.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "gnunet_protocols.h" | 33 | #include "gnunet_protocols.h" |
34 | #include "gnunet_program_lib.h" | 34 | #include "gnunet_program_lib.h" |
35 | #include "gnunet_signatures.h" | 35 | #include "gnunet_signatures.h" |
36 | #include "gnunet_service_lib.h" | ||
36 | #include "plugin_transport.h" | 37 | #include "plugin_transport.h" |
37 | #include "gnunet_statistics_service.h" | 38 | #include "gnunet_statistics_service.h" |
38 | #include "transport.h" | 39 | #include "transport.h" |
@@ -84,12 +85,14 @@ static uint32_t max_connect_per_transport; | |||
84 | /** | 85 | /** |
85 | * Environment for this plugin. | 86 | * Environment for this plugin. |
86 | */ | 87 | */ |
87 | struct GNUNET_TRANSPORT_PluginEnvironment env; | 88 | static struct GNUNET_TRANSPORT_PluginEnvironment env; |
88 | 89 | ||
89 | /** | 90 | /** |
90 | *handle for the api provided by this plugin | 91 | *handle for the api provided by this plugin |
91 | */ | 92 | */ |
92 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 93 | static struct GNUNET_TRANSPORT_PluginFunctions *api; |
94 | |||
95 | static struct GNUNET_SERVICE_Context *service; | ||
93 | 96 | ||
94 | /** | 97 | /** |
95 | * Did the test pass or fail? | 98 | * Did the test pass or fail? |
@@ -98,6 +101,8 @@ static int fail; | |||
98 | 101 | ||
99 | static GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 102 | static GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
100 | 103 | ||
104 | pid_t pid; | ||
105 | |||
101 | /** | 106 | /** |
102 | * Initialize Environment for this plugin | 107 | * Initialize Environment for this plugin |
103 | */ | 108 | */ |
@@ -152,6 +157,12 @@ shutdown_clean () | |||
152 | { | 157 | { |
153 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) | 158 | if (timeout_task != GNUNET_SCHEDULER_NO_TASK) |
154 | GNUNET_SCHEDULER_cancel( sched, timeout_task ); | 159 | GNUNET_SCHEDULER_cancel( sched, timeout_task ); |
160 | if (NULL != service) GNUNET_SERVICE_stop (service); | ||
161 | if (0 != PLIBC_KILL (pid, SIGTERM)) | ||
162 | { | ||
163 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
164 | fail = 1; | ||
165 | } | ||
155 | unload_plugins(env.cls, env.cfg); | 166 | unload_plugins(env.cls, env.cfg); |
156 | } | 167 | } |
157 | 168 | ||
@@ -184,6 +195,20 @@ setup_plugin_environment () | |||
184 | env.max_connections = max_connect_per_transport; | 195 | env.max_connections = max_connect_per_transport; |
185 | } | 196 | } |
186 | 197 | ||
198 | static int | ||
199 | process_stat (void *cls, | ||
200 | const char *subsystem, | ||
201 | const char *name, | ||
202 | uint64_t value, | ||
203 | int is_persistent) | ||
204 | { | ||
205 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
206 | _("Value: %llums\n"), | ||
207 | (unsigned long long) value); | ||
208 | return GNUNET_OK; | ||
209 | } | ||
210 | |||
211 | |||
187 | /** | 212 | /** |
188 | * Runs the test. | 213 | * Runs the test. |
189 | * | 214 | * |
@@ -222,9 +247,32 @@ run (void *cls, | |||
222 | return; | 247 | return; |
223 | } | 248 | } |
224 | 249 | ||
250 | pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", | ||
251 | "gnunet-service-statistics", | ||
252 | "-L", "DEBUG", | ||
253 | "-c", "test_plugin_transport_data_http.conf", NULL); | ||
254 | |||
255 | |||
256 | if ( pid == -1) | ||
257 | { | ||
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
259 | _("Failed to start service for `%s' http transport plugin test.\n"), | ||
260 | "statistics"); | ||
261 | return; | ||
262 | } | ||
225 | 263 | ||
226 | // stats = GNUNET_STATISTICS_create (sched, "http-transport", cfg); | ||
227 | 264 | ||
265 | |||
266 | stats = GNUNET_STATISTICS_create (sched, "http-transport", cfg); | ||
267 | env.stats = stats; | ||
268 | |||
269 | GNUNET_STATISTICS_get (stats, | ||
270 | "http-transport", | ||
271 | gettext_noop("# PUT requests"), | ||
272 | GNUNET_TIME_UNIT_MINUTES, | ||
273 | NULL, | ||
274 | &process_stat, | ||
275 | NULL); | ||
228 | /* | 276 | /* |
229 | max_connect_per_transport = (uint32_t) tneigh; | 277 | max_connect_per_transport = (uint32_t) tneigh; |
230 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); | 278 | my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile); |