diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/datastore/test_plugin_datastore.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/datastore/test_plugin_datastore.c')
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 15cca61f1..a34c4e38a 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -118,9 +118,8 @@ put_value (struct GNUNET_DATASTORE_PluginFunctions *api, int i, int k) | |||
118 | msg = NULL; | 118 | msg = NULL; |
119 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 119 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
120 | #if VERBOSE | 120 | #if VERBOSE |
121 | fprintf (stderr, | 121 | fprintf (stderr, "putting type %u, anon %u under key %s\n", i + 1, i, |
122 | "putting type %u, anon %u under key %s\n", | 122 | GNUNET_h2s (&key)); |
123 | i + 1, i, GNUNET_h2s (&key)); | ||
124 | #endif | 123 | #endif |
125 | if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , | 124 | if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , |
126 | prio, i /* anonymity */ , | 125 | prio, i /* anonymity */ , |
@@ -149,13 +148,9 @@ static uint64_t guid; | |||
149 | 148 | ||
150 | 149 | ||
151 | static int | 150 | static int |
152 | iterate_one_shot (void *cls, | 151 | iterate_one_shot (void *cls, const GNUNET_HashCode * key, uint32_t size, |
153 | const GNUNET_HashCode * key, | 152 | const void *data, enum GNUNET_BLOCK_Type type, |
154 | uint32_t size, | 153 | uint32_t priority, uint32_t anonymity, |
155 | const void *data, | ||
156 | enum GNUNET_BLOCK_Type type, | ||
157 | uint32_t priority, | ||
158 | uint32_t anonymity, | ||
159 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 154 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
160 | { | 155 | { |
161 | struct CpsRunContext *crc = cls; | 156 | struct CpsRunContext *crc = cls; |
@@ -166,8 +161,8 @@ iterate_one_shot (void *cls, | |||
166 | #if VERBOSE | 161 | #if VERBOSE |
167 | fprintf (stderr, | 162 | fprintf (stderr, |
168 | "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", | 163 | "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", |
169 | type, priority, size, | 164 | type, priority, size, (unsigned long long) expiration.abs_value, |
170 | (unsigned long long) expiration.abs_value, GNUNET_h2s (key)); | 165 | GNUNET_h2s (key)); |
171 | #endif | 166 | #endif |
172 | GNUNET_SCHEDULER_add_now (&test, crc); | 167 | GNUNET_SCHEDULER_add_now (&test, crc); |
173 | return GNUNET_OK; | 168 | return GNUNET_OK; |
@@ -189,12 +184,12 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api, | |||
189 | char *libname; | 184 | char *libname; |
190 | 185 | ||
191 | if (GNUNET_OK != | 186 | if (GNUNET_OK != |
192 | GNUNET_CONFIGURATION_get_value_string (cfg, | 187 | GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", |
193 | "DATASTORE", "DATABASE", &name)) | 188 | &name)) |
194 | { | 189 | { |
195 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 190 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
196 | _("No `%s' specified for `%s' in configuration!\n"), | 191 | _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", |
197 | "DATABASE", "DATASTORE"); | 192 | "DATASTORE"); |
198 | return; | 193 | return; |
199 | } | 194 | } |
200 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); | 195 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); |
@@ -265,15 +260,13 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
265 | break; | 260 | break; |
266 | } | 261 | } |
267 | gen_key (5, &key); | 262 | gen_key (5, &key); |
268 | crc->api->get_key (crc->api->cls, | 263 | crc->api->get_key (crc->api->cls, crc->offset++, &key, NULL, |
269 | crc->offset++, | ||
270 | &key, NULL, | ||
271 | GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc); | 264 | GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc); |
272 | break; | 265 | break; |
273 | case RP_UPDATE: | 266 | case RP_UPDATE: |
274 | GNUNET_assert (GNUNET_OK == | 267 | GNUNET_assert (GNUNET_OK == |
275 | crc->api->update (crc->api->cls, | 268 | crc->api->update (crc->api->cls, guid, 1, |
276 | guid, 1, GNUNET_TIME_UNIT_ZERO_ABS, NULL)); | 269 | GNUNET_TIME_UNIT_ZERO_ABS, NULL)); |
277 | crc->phase++; | 270 | crc->phase++; |
278 | GNUNET_SCHEDULER_add_now (&test, crc); | 271 | GNUNET_SCHEDULER_add_now (&test, crc); |
279 | break; | 272 | break; |
@@ -314,19 +307,19 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
314 | char *libname; | 307 | char *libname; |
315 | 308 | ||
316 | if (GNUNET_OK != | 309 | if (GNUNET_OK != |
317 | GNUNET_CONFIGURATION_get_value_string (cfg, | 310 | GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", |
318 | "DATASTORE", "DATABASE", &name)) | 311 | &name)) |
319 | { | 312 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 313 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
321 | _("No `%s' specified for `%s' in configuration!\n"), | 314 | _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", |
322 | "DATABASE", "DATASTORE"); | 315 | "DATASTORE"); |
323 | return NULL; | 316 | return NULL; |
324 | } | 317 | } |
325 | env.cfg = cfg; | 318 | env.cfg = cfg; |
326 | env.duc = &disk_utilization_change_cb; | 319 | env.duc = &disk_utilization_change_cb; |
327 | env.cls = NULL; | 320 | env.cls = NULL; |
328 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 321 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), |
329 | _("Loading `%s' datastore plugin\n"), name); | 322 | name); |
330 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); | 323 | GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name); |
331 | if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) | 324 | if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env))) |
332 | { | 325 | { |
@@ -340,9 +333,8 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
340 | 333 | ||
341 | 334 | ||
342 | static void | 335 | static void |
343 | run (void *cls, | 336 | run (void *cls, char *const *args, const char *cfgfile, |
344 | char *const *args, | 337 | const struct GNUNET_CONFIGURATION_Handle *c) |
345 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
346 | { | 338 | { |
347 | struct GNUNET_DATASTORE_PluginFunctions *api; | 339 | struct GNUNET_DATASTORE_PluginFunctions *api; |
348 | struct CpsRunContext *crc; | 340 | struct CpsRunContext *crc; |
@@ -380,12 +372,10 @@ check () | |||
380 | GNUNET_GETOPT_OPTION_END | 372 | GNUNET_GETOPT_OPTION_END |
381 | }; | 373 | }; |
382 | 374 | ||
383 | GNUNET_snprintf (cfg_name, | 375 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), |
384 | sizeof (cfg_name), | ||
385 | "test_plugin_datastore_data_%s.conf", plugin_name); | 376 | "test_plugin_datastore_data_%s.conf", plugin_name); |
386 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 377 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
387 | argv, "test-plugin-datastore", "nohelp", | 378 | "test-plugin-datastore", "nohelp", options, &run, NULL); |
388 | options, &run, NULL); | ||
389 | if (ok != 0) | 379 | if (ok != 0) |
390 | fprintf (stderr, "Missed some testcases: %u\n", ok); | 380 | fprintf (stderr, "Missed some testcases: %u\n", ok); |
391 | return ok; | 381 | return ok; |
@@ -409,8 +399,7 @@ main (int argc, char *argv[]) | |||
409 | else | 399 | else |
410 | pos = (char *) plugin_name; | 400 | pos = (char *) plugin_name; |
411 | 401 | ||
412 | GNUNET_snprintf (dir_name, | 402 | GNUNET_snprintf (dir_name, sizeof (dir_name), |
413 | sizeof (dir_name), | ||
414 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); | 403 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); |
415 | GNUNET_DISK_directory_remove (dir_name); | 404 | GNUNET_DISK_directory_remove (dir_name); |
416 | GNUNET_log_setup ("test-plugin-datastore", | 405 | GNUNET_log_setup ("test-plugin-datastore", |