diff options
Diffstat (limited to 'src/datastore/perf_datastore_api.c')
-rw-r--r-- | src/datastore/perf_datastore_api.c | 497 |
1 files changed, 251 insertions, 246 deletions
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index 96ec9e924..e7eff0e6a 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /* | 20 | /* |
21 | * @file datastore/perf_datastore_api.c | 21 | * @file datastore/perf_datastore_api.c |
22 | * @brief performance measurement for the datastore implementation | 22 | * @brief performance measurement for the datastore implementation |
@@ -41,7 +41,7 @@ | |||
41 | /** | 41 | /** |
42 | * How long until we give up on transmitting the message? | 42 | * How long until we give up on transmitting the message? |
43 | */ | 43 | */ |
44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 44 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 15) |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Target datastore size (in bytes). | 47 | * Target datastore size (in bytes). |
@@ -114,8 +114,7 @@ static int ok; | |||
114 | /** | 114 | /** |
115 | * Which phase of the process are we in? | 115 | * Which phase of the process are we in? |
116 | */ | 116 | */ |
117 | enum RunPhase | 117 | enum RunPhase { |
118 | { | ||
119 | /** | 118 | /** |
120 | * We are done (shutting down normally). | 119 | * We are done (shutting down normally). |
121 | */ | 120 | */ |
@@ -154,8 +153,7 @@ enum RunPhase | |||
154 | * benchmark. Could right now be global, but this allows | 153 | * benchmark. Could right now be global, but this allows |
155 | * us to theoretically run multiple clients "in parallel". | 154 | * us to theoretically run multiple clients "in parallel". |
156 | */ | 155 | */ |
157 | struct CpsRunContext | 156 | struct CpsRunContext { |
158 | { | ||
159 | /** | 157 | /** |
160 | * Execution phase we are in. | 158 | * Execution phase we are in. |
161 | */ | 159 | */ |
@@ -188,7 +186,7 @@ struct CpsRunContext | |||
188 | * @param cls the `struct CpsRunContext` | 186 | * @param cls the `struct CpsRunContext` |
189 | */ | 187 | */ |
190 | static void | 188 | static void |
191 | run_continuation (void *cls); | 189 | run_continuation(void *cls); |
192 | 190 | ||
193 | 191 | ||
194 | /** | 192 | /** |
@@ -203,55 +201,57 @@ run_continuation (void *cls); | |||
203 | * @param msg NULL on success, otherwise an error message | 201 | * @param msg NULL on success, otherwise an error message |
204 | */ | 202 | */ |
205 | static void | 203 | static void |
206 | check_success (void *cls, | 204 | check_success(void *cls, |
207 | int success, | 205 | int success, |
208 | struct GNUNET_TIME_Absolute min_expiration, | 206 | struct GNUNET_TIME_Absolute min_expiration, |
209 | const char *msg) | 207 | const char *msg) |
210 | { | 208 | { |
211 | struct CpsRunContext *crc = cls; | 209 | struct CpsRunContext *crc = cls; |
212 | 210 | ||
213 | #if REPORT_ID | 211 | #if REPORT_ID |
214 | fprintf (stderr, "%s", (GNUNET_OK == success) ? "I" : "i"); | 212 | fprintf(stderr, "%s", (GNUNET_OK == success) ? "I" : "i"); |
215 | #endif | 213 | #endif |
216 | if (GNUNET_OK != success) | 214 | if (GNUNET_OK != success) |
217 | { | 215 | { |
218 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 216 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
219 | "Check success failed: `%s'\n", | 217 | "Check success failed: `%s'\n", |
220 | msg); | 218 | msg); |
221 | crc->phase = RP_ERROR; | 219 | crc->phase = RP_ERROR; |
222 | GNUNET_SCHEDULER_add_now (&run_continuation, | 220 | GNUNET_SCHEDULER_add_now(&run_continuation, |
223 | crc); | 221 | crc); |
224 | return; | 222 | return; |
225 | } | 223 | } |
226 | stored_bytes += crc->size; | 224 | stored_bytes += crc->size; |
227 | stored_ops++; | 225 | stored_ops++; |
228 | stored_entries++; | 226 | stored_entries++; |
229 | crc->j++; | 227 | crc->j++; |
230 | switch (crc->phase) | 228 | switch (crc->phase) |
231 | { | ||
232 | case RP_PUT: | ||
233 | if (crc->j >= PUT_10) | ||
234 | { | 229 | { |
235 | crc->j = 0; | 230 | case RP_PUT: |
236 | crc->i++; | 231 | if (crc->j >= PUT_10) |
237 | if (crc->i == ITERATIONS) | 232 | { |
238 | crc->phase = RP_PUT_QUOTA; | 233 | crc->j = 0; |
239 | else | 234 | crc->i++; |
240 | crc->phase = RP_CUT; | 235 | if (crc->i == ITERATIONS) |
236 | crc->phase = RP_PUT_QUOTA; | ||
237 | else | ||
238 | crc->phase = RP_CUT; | ||
239 | } | ||
240 | break; | ||
241 | |||
242 | case RP_PUT_QUOTA: | ||
243 | if (crc->j >= QUOTA_PUTS) | ||
244 | { | ||
245 | crc->j = 0; | ||
246 | crc->phase = RP_DONE; | ||
247 | } | ||
248 | break; | ||
249 | |||
250 | default: | ||
251 | GNUNET_assert(0); | ||
241 | } | 252 | } |
242 | break; | 253 | GNUNET_SCHEDULER_add_now(&run_continuation, |
243 | case RP_PUT_QUOTA: | 254 | crc); |
244 | if (crc->j >= QUOTA_PUTS) | ||
245 | { | ||
246 | crc->j = 0; | ||
247 | crc->phase = RP_DONE; | ||
248 | } | ||
249 | break; | ||
250 | default: | ||
251 | GNUNET_assert (0); | ||
252 | } | ||
253 | GNUNET_SCHEDULER_add_now (&run_continuation, | ||
254 | crc); | ||
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
@@ -267,29 +267,29 @@ check_success (void *cls, | |||
267 | * @param msg NULL on success, otherwise an error message | 267 | * @param msg NULL on success, otherwise an error message |
268 | */ | 268 | */ |
269 | static void | 269 | static void |
270 | remove_next (void *cls, | 270 | remove_next(void *cls, |
271 | int success, | 271 | int success, |
272 | struct GNUNET_TIME_Absolute min_expiration, | 272 | struct GNUNET_TIME_Absolute min_expiration, |
273 | const char *msg) | 273 | const char *msg) |
274 | { | 274 | { |
275 | struct CpsRunContext *crc = cls; | 275 | struct CpsRunContext *crc = cls; |
276 | 276 | ||
277 | if (GNUNET_OK != success) | 277 | if (GNUNET_OK != success) |
278 | { | 278 | { |
279 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 279 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
280 | "remove_next failed: `%s'\n", | 280 | "remove_next failed: `%s'\n", |
281 | msg); | 281 | msg); |
282 | crc->phase = RP_ERROR; | 282 | crc->phase = RP_ERROR; |
283 | GNUNET_SCHEDULER_add_now (&run_continuation, | 283 | GNUNET_SCHEDULER_add_now(&run_continuation, |
284 | crc); | 284 | crc); |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | #if REPORT_ID | 287 | #if REPORT_ID |
288 | fprintf (stderr, "%s", "D"); | 288 | fprintf(stderr, "%s", "D"); |
289 | #endif | 289 | #endif |
290 | GNUNET_assert (GNUNET_OK == success); | 290 | GNUNET_assert(GNUNET_OK == success); |
291 | GNUNET_SCHEDULER_add_now (&run_continuation, | 291 | GNUNET_SCHEDULER_add_now(&run_continuation, |
292 | crc); | 292 | crc); |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
@@ -309,32 +309,32 @@ remove_next (void *cls, | |||
309 | * maybe 0 if no unique identifier is available | 309 | * maybe 0 if no unique identifier is available |
310 | */ | 310 | */ |
311 | static void | 311 | static void |
312 | delete_value (void *cls, | 312 | delete_value(void *cls, |
313 | const struct GNUNET_HashCode *key, | 313 | const struct GNUNET_HashCode *key, |
314 | size_t size, | 314 | size_t size, |
315 | const void *data, | 315 | const void *data, |
316 | enum GNUNET_BLOCK_Type type, | 316 | enum GNUNET_BLOCK_Type type, |
317 | uint32_t priority, | 317 | uint32_t priority, |
318 | uint32_t anonymity, | 318 | uint32_t anonymity, |
319 | uint32_t replication, | 319 | uint32_t replication, |
320 | struct GNUNET_TIME_Absolute expiration, | 320 | struct GNUNET_TIME_Absolute expiration, |
321 | uint64_t uid) | 321 | uint64_t uid) |
322 | { | 322 | { |
323 | struct CpsRunContext *crc = cls; | 323 | struct CpsRunContext *crc = cls; |
324 | 324 | ||
325 | GNUNET_assert (NULL != key); | 325 | GNUNET_assert(NULL != key); |
326 | stored_ops++; | 326 | stored_ops++; |
327 | stored_bytes -= size; | 327 | stored_bytes -= size; |
328 | stored_entries--; | 328 | stored_entries--; |
329 | stored_ops++; | 329 | stored_ops++; |
330 | if (stored_bytes < MAX_SIZE) | 330 | if (stored_bytes < MAX_SIZE) |
331 | crc->phase = RP_PUT; | 331 | crc->phase = RP_PUT; |
332 | GNUNET_assert (NULL != | 332 | GNUNET_assert(NULL != |
333 | GNUNET_DATASTORE_remove (datastore, | 333 | GNUNET_DATASTORE_remove(datastore, |
334 | key, | 334 | key, |
335 | size, | 335 | size, |
336 | data, 1, 1, | 336 | data, 1, 1, |
337 | &remove_next, crc)); | 337 | &remove_next, crc)); |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
@@ -345,7 +345,7 @@ delete_value (void *cls, | |||
345 | * @param cls the `struct CpsRunContext` | 345 | * @param cls the `struct CpsRunContext` |
346 | */ | 346 | */ |
347 | static void | 347 | static void |
348 | run_continuation (void *cls) | 348 | run_continuation(void *cls) |
349 | { | 349 | { |
350 | struct CpsRunContext *crc = cls; | 350 | struct CpsRunContext *crc = cls; |
351 | size_t size; | 351 | size_t size; |
@@ -353,156 +353,161 @@ run_continuation (void *cls) | |||
353 | static char data[65536]; | 353 | static char data[65536]; |
354 | char gstr[128]; | 354 | char gstr[128]; |
355 | 355 | ||
356 | ok = (int) crc->phase; | 356 | ok = (int)crc->phase; |
357 | switch (crc->phase) | 357 | switch (crc->phase) |
358 | { | 358 | { |
359 | case RP_PUT: | 359 | case RP_PUT: |
360 | memset (&key, | 360 | memset(&key, |
361 | 256 - crc->i, | 361 | 256 - crc->i, |
362 | sizeof (struct GNUNET_HashCode)); | 362 | sizeof(struct GNUNET_HashCode)); |
363 | /* most content is 32k */ | 363 | /* most content is 32k */ |
364 | size = 32 * 1024; | 364 | size = 32 * 1024; |
365 | if (0 == | 365 | if (0 == |
366 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 366 | GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
367 | 16)) /* but some of it is less! */ | 367 | 16)) /* but some of it is less! */ |
368 | size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 368 | size = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
369 | 32 * 1024); | 369 | 32 * 1024); |
370 | crc->size = size = size - (size & 7); /* always multiple of 8 */ | 370 | crc->size = size = size - (size & 7); /* always multiple of 8 */ |
371 | GNUNET_CRYPTO_hash (&key, | 371 | GNUNET_CRYPTO_hash(&key, |
372 | sizeof (struct GNUNET_HashCode), | 372 | sizeof(struct GNUNET_HashCode), |
373 | &key); | 373 | &key); |
374 | memset (data, | 374 | memset(data, |
375 | (int) crc->j, | 375 | (int)crc->j, |
376 | size); | 376 | size); |
377 | if (crc->j > 255) | 377 | if (crc->j > 255) |
378 | memset (data, | 378 | memset(data, |
379 | (int) (crc->j - 255), | 379 | (int)(crc->j - 255), |
380 | size / 2); | 380 | size / 2); |
381 | data[0] = crc->i; | 381 | data[0] = crc->i; |
382 | GNUNET_assert (NULL != | 382 | GNUNET_assert(NULL != |
383 | GNUNET_DATASTORE_put (datastore, | 383 | GNUNET_DATASTORE_put(datastore, |
384 | 0, | 384 | 0, |
385 | &key, | 385 | &key, |
386 | size, | 386 | size, |
387 | data, | 387 | data, |
388 | crc->j + 1, | 388 | crc->j + 1, |
389 | GNUNET_CRYPTO_random_u32 | 389 | GNUNET_CRYPTO_random_u32 |
390 | (GNUNET_CRYPTO_QUALITY_WEAK, 100), | 390 | (GNUNET_CRYPTO_QUALITY_WEAK, 100), |
391 | crc->j, | 391 | crc->j, |
392 | 0, | 392 | 0, |
393 | GNUNET_TIME_relative_to_absolute | 393 | GNUNET_TIME_relative_to_absolute |
394 | (GNUNET_TIME_relative_multiply | 394 | (GNUNET_TIME_relative_multiply |
395 | (GNUNET_TIME_UNIT_SECONDS, | 395 | (GNUNET_TIME_UNIT_SECONDS, |
396 | GNUNET_CRYPTO_random_u32 | 396 | GNUNET_CRYPTO_random_u32 |
397 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), | 397 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), |
398 | 1, | 398 | 1, |
399 | 1, | 399 | 1, |
400 | &check_success, crc)); | 400 | &check_success, crc)); |
401 | break; | 401 | break; |
402 | case RP_CUT: | 402 | |
403 | /* trim down below MAX_SIZE again */ | 403 | case RP_CUT: |
404 | GNUNET_assert (NULL != | 404 | /* trim down below MAX_SIZE again */ |
405 | GNUNET_DATASTORE_get_for_replication (datastore, | 405 | GNUNET_assert(NULL != |
406 | GNUNET_DATASTORE_get_for_replication(datastore, | ||
406 | 1, 1, | 407 | 1, 1, |
407 | &delete_value, | 408 | &delete_value, |
408 | crc)); | 409 | crc)); |
409 | break; | 410 | break; |
410 | case RP_REPORT: | 411 | |
411 | printf ( | 412 | case RP_REPORT: |
413 | printf( | ||
412 | #if REPORT_ID | 414 | #if REPORT_ID |
413 | "\n" | 415 | "\n" |
414 | #endif | 416 | #endif |
415 | "Stored %llu kB / %lluk ops / %llu ops/s\n", | 417 | "Stored %llu kB / %lluk ops / %llu ops/s\n", |
416 | stored_bytes / 1024, /* used size in k */ | 418 | stored_bytes / 1024, /* used size in k */ |
417 | stored_ops / 1024, /* total operations (in k) */ | 419 | stored_ops / 1024, /* total operations (in k) */ |
418 | 1000LL * 1000LL * stored_ops / (1 + | 420 | 1000LL * 1000LL * stored_ops / (1 + |
419 | GNUNET_TIME_absolute_get_duration | 421 | GNUNET_TIME_absolute_get_duration |
420 | (start_time).rel_value_us)); | 422 | (start_time).rel_value_us)); |
421 | crc->phase = RP_PUT; | 423 | crc->phase = RP_PUT; |
422 | crc->j = 0; | 424 | crc->j = 0; |
423 | GNUNET_SCHEDULER_add_now (&run_continuation, | 425 | GNUNET_SCHEDULER_add_now(&run_continuation, |
424 | crc); | 426 | crc); |
425 | break; | 427 | break; |
426 | case RP_PUT_QUOTA: | 428 | |
427 | memset (&key, | 429 | case RP_PUT_QUOTA: |
428 | 256 - crc->i, | 430 | memset(&key, |
429 | sizeof (struct GNUNET_HashCode)); | 431 | 256 - crc->i, |
430 | /* most content is 32k */ | 432 | sizeof(struct GNUNET_HashCode)); |
431 | size = 32 * 1024; | 433 | /* most content is 32k */ |
432 | if (0 == | 434 | size = 32 * 1024; |
433 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 435 | if (0 == |
434 | 16)) /* but some of it is less! */ | 436 | GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
435 | size = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 437 | 16)) /* but some of it is less! */ |
436 | 32 * 1024); | 438 | size = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, |
437 | crc->size = size = size - (size & 7); /* always multiple of 8 */ | 439 | 32 * 1024); |
438 | GNUNET_CRYPTO_hash (&key, | 440 | crc->size = size = size - (size & 7); /* always multiple of 8 */ |
439 | sizeof (struct GNUNET_HashCode), | 441 | GNUNET_CRYPTO_hash(&key, |
440 | &key); | 442 | sizeof(struct GNUNET_HashCode), |
441 | memset (data, | 443 | &key); |
442 | (int) crc->j, | 444 | memset(data, |
443 | size); | 445 | (int)crc->j, |
444 | if (crc->j > 255) | 446 | size); |
445 | memset (data, | 447 | if (crc->j > 255) |
446 | (int) (crc->j - 255), | 448 | memset(data, |
447 | size / 2); | 449 | (int)(crc->j - 255), |
448 | data[0] = crc->i; | 450 | size / 2); |
449 | GNUNET_assert (NULL != | 451 | data[0] = crc->i; |
450 | GNUNET_DATASTORE_put (datastore, | 452 | GNUNET_assert(NULL != |
453 | GNUNET_DATASTORE_put(datastore, | ||
451 | 0, /* reservation ID */ | 454 | 0, /* reservation ID */ |
452 | &key, | 455 | &key, |
453 | size, | 456 | size, |
454 | data, | 457 | data, |
455 | crc->j + 1, /* type */ | 458 | crc->j + 1, /* type */ |
456 | GNUNET_CRYPTO_random_u32 | 459 | GNUNET_CRYPTO_random_u32 |
457 | (GNUNET_CRYPTO_QUALITY_WEAK, | 460 | (GNUNET_CRYPTO_QUALITY_WEAK, |
458 | 100), /* priority */ | 461 | 100), /* priority */ |
459 | crc->j, /* anonymity */ | 462 | crc->j, /* anonymity */ |
460 | 0, /* replication */ | 463 | 0, /* replication */ |
461 | GNUNET_TIME_relative_to_absolute | 464 | GNUNET_TIME_relative_to_absolute |
462 | (GNUNET_TIME_relative_multiply | 465 | (GNUNET_TIME_relative_multiply |
463 | (GNUNET_TIME_UNIT_SECONDS, | 466 | (GNUNET_TIME_UNIT_SECONDS, |
464 | GNUNET_CRYPTO_random_u32 | 467 | GNUNET_CRYPTO_random_u32 |
465 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), | 468 | (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), |
466 | 1, | 469 | 1, |
467 | 1, | 470 | 1, |
468 | &check_success, crc)); | 471 | &check_success, crc)); |
469 | break; | 472 | break; |
470 | 473 | ||
471 | case RP_DONE: | 474 | case RP_DONE: |
472 | GNUNET_snprintf (gstr, | 475 | GNUNET_snprintf(gstr, |
473 | sizeof (gstr), | 476 | sizeof(gstr), |
474 | "DATASTORE-%s", | 477 | "DATASTORE-%s", |
475 | plugin_name); | 478 | plugin_name); |
476 | if ((crc->i == ITERATIONS) && (stored_ops > 0)) | 479 | if ((crc->i == ITERATIONS) && (stored_ops > 0)) |
477 | { | 480 | { |
478 | GAUGER (gstr, | 481 | GAUGER(gstr, |
479 | "PUT operation duration", | 482 | "PUT operation duration", |
480 | GNUNET_TIME_absolute_get_duration (start_time).rel_value_us / 1000LL / | 483 | GNUNET_TIME_absolute_get_duration(start_time).rel_value_us / 1000LL / |
481 | stored_ops, | 484 | stored_ops, |
482 | "ms/operation"); | 485 | "ms/operation"); |
483 | fprintf (stdout, | 486 | fprintf(stdout, |
484 | "\nPUT performance: %s for %llu operations\n", | 487 | "\nPUT performance: %s for %llu operations\n", |
485 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start_time), | 488 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start_time), |
486 | GNUNET_YES), | 489 | GNUNET_YES), |
487 | stored_ops); | 490 | stored_ops); |
488 | fprintf (stdout, | 491 | fprintf(stdout, |
489 | "PUT performance: %llu ms/operation\n", | 492 | "PUT performance: %llu ms/operation\n", |
490 | GNUNET_TIME_absolute_get_duration (start_time).rel_value_us / 1000LL / | 493 | GNUNET_TIME_absolute_get_duration(start_time).rel_value_us / 1000LL / |
491 | stored_ops); | 494 | stored_ops); |
495 | } | ||
496 | GNUNET_DATASTORE_disconnect(datastore, | ||
497 | GNUNET_YES); | ||
498 | GNUNET_free(crc); | ||
499 | ok = 0; | ||
500 | break; | ||
501 | |||
502 | case RP_ERROR: | ||
503 | GNUNET_DATASTORE_disconnect(datastore, GNUNET_YES); | ||
504 | GNUNET_free(crc); | ||
505 | ok = 1; | ||
506 | break; | ||
507 | |||
508 | default: | ||
509 | GNUNET_assert(0); | ||
492 | } | 510 | } |
493 | GNUNET_DATASTORE_disconnect (datastore, | ||
494 | GNUNET_YES); | ||
495 | GNUNET_free (crc); | ||
496 | ok = 0; | ||
497 | break; | ||
498 | case RP_ERROR: | ||
499 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); | ||
500 | GNUNET_free (crc); | ||
501 | ok = 1; | ||
502 | break; | ||
503 | default: | ||
504 | GNUNET_assert (0); | ||
505 | } | ||
506 | } | 511 | } |
507 | 512 | ||
508 | 513 | ||
@@ -519,25 +524,25 @@ run_continuation (void *cls) | |||
519 | * @param msg NULL on success, otherwise an error message | 524 | * @param msg NULL on success, otherwise an error message |
520 | */ | 525 | */ |
521 | static void | 526 | static void |
522 | run_tests (void *cls, | 527 | run_tests(void *cls, |
523 | int success, | 528 | int success, |
524 | struct GNUNET_TIME_Absolute min_expiration, | 529 | struct GNUNET_TIME_Absolute min_expiration, |
525 | const char *msg) | 530 | const char *msg) |
526 | { | 531 | { |
527 | struct CpsRunContext *crc = cls; | 532 | struct CpsRunContext *crc = cls; |
528 | 533 | ||
529 | if (success != GNUNET_YES) | 534 | if (success != GNUNET_YES) |
530 | { | 535 | { |
531 | fprintf (stderr, | 536 | fprintf(stderr, |
532 | "Test 'put' operation failed with error `%s' database likely not setup, skipping test.\n", | 537 | "Test 'put' operation failed with error `%s' database likely not setup, skipping test.\n", |
533 | msg); | 538 | msg); |
534 | GNUNET_DATASTORE_disconnect (datastore, | 539 | GNUNET_DATASTORE_disconnect(datastore, |
535 | GNUNET_YES); | 540 | GNUNET_YES); |
536 | GNUNET_free (crc); | 541 | GNUNET_free(crc); |
537 | return; | 542 | return; |
538 | } | 543 | } |
539 | GNUNET_SCHEDULER_add_now (&run_continuation, | 544 | GNUNET_SCHEDULER_add_now(&run_continuation, |
540 | crc); | 545 | crc); |
541 | } | 546 | } |
542 | 547 | ||
543 | 548 | ||
@@ -551,34 +556,34 @@ run_tests (void *cls, | |||
551 | * @param peer peer handle (unused) | 556 | * @param peer peer handle (unused) |
552 | */ | 557 | */ |
553 | static void | 558 | static void |
554 | run (void *cls, | 559 | run(void *cls, |
555 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 560 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
556 | struct GNUNET_TESTING_Peer *peer) | 561 | struct GNUNET_TESTING_Peer *peer) |
557 | { | 562 | { |
558 | struct CpsRunContext *crc; | 563 | struct CpsRunContext *crc; |
559 | static struct GNUNET_HashCode zkey; | 564 | static struct GNUNET_HashCode zkey; |
560 | 565 | ||
561 | datastore = GNUNET_DATASTORE_connect (cfg); | 566 | datastore = GNUNET_DATASTORE_connect(cfg); |
562 | start_time = GNUNET_TIME_absolute_get (); | 567 | start_time = GNUNET_TIME_absolute_get(); |
563 | crc = GNUNET_new (struct CpsRunContext); | 568 | crc = GNUNET_new(struct CpsRunContext); |
564 | crc->phase = RP_PUT; | 569 | crc->phase = RP_PUT; |
565 | if (NULL == | 570 | if (NULL == |
566 | GNUNET_DATASTORE_put (datastore, | 571 | GNUNET_DATASTORE_put(datastore, |
567 | 0, | 572 | 0, |
568 | &zkey, | 573 | &zkey, |
569 | 4, "TEST", | 574 | 4, "TEST", |
570 | GNUNET_BLOCK_TYPE_TEST, | 575 | GNUNET_BLOCK_TYPE_TEST, |
571 | 0, 0, 0, | 576 | 0, 0, 0, |
572 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), | 577 | GNUNET_TIME_relative_to_absolute(GNUNET_TIME_UNIT_SECONDS), |
573 | 0, 1, | 578 | 0, 1, |
574 | &run_tests, crc)) | 579 | &run_tests, crc)) |
575 | { | 580 | { |
576 | fprintf (stderr, | 581 | fprintf(stderr, |
577 | "%s", | 582 | "%s", |
578 | "Test 'put' operation failed.\n"); | 583 | "Test 'put' operation failed.\n"); |
579 | ok = 1; | 584 | ok = 1; |
580 | GNUNET_free (crc); | 585 | GNUNET_free(crc); |
581 | } | 586 | } |
582 | } | 587 | } |
583 | 588 | ||
584 | 589 | ||
@@ -592,23 +597,23 @@ run (void *cls, | |||
592 | * @return 0 on success | 597 | * @return 0 on success |
593 | */ | 598 | */ |
594 | int | 599 | int |
595 | main (int argc, | 600 | main(int argc, |
596 | char *argv[]) | 601 | char *argv[]) |
597 | { | 602 | { |
598 | char cfg_name[PATH_MAX]; | 603 | char cfg_name[PATH_MAX]; |
599 | 604 | ||
600 | plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); | 605 | plugin_name = GNUNET_TESTING_get_testname_from_underscore(argv[0]); |
601 | GNUNET_snprintf (cfg_name, | 606 | GNUNET_snprintf(cfg_name, |
602 | sizeof (cfg_name), | 607 | sizeof(cfg_name), |
603 | "test_datastore_api_data_%s.conf", | 608 | "test_datastore_api_data_%s.conf", |
604 | plugin_name); | 609 | plugin_name); |
605 | if (0 != | 610 | if (0 != |
606 | GNUNET_TESTING_peer_run ("perf-gnunet-datastore", | 611 | GNUNET_TESTING_peer_run("perf-gnunet-datastore", |
607 | cfg_name, | 612 | cfg_name, |
608 | &run, | 613 | &run, |
609 | NULL)) | 614 | NULL)) |
610 | return 1; | 615 | return 1; |
611 | fprintf (stderr, "%s", "\n"); | 616 | fprintf(stderr, "%s", "\n"); |
612 | return ok; | 617 | return ok; |
613 | } | 618 | } |
614 | 619 | ||