diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-10 11:18:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-10 11:18:59 +0000 |
commit | 5d2bfbd4a69f87c99083fc60954c884af69258f4 (patch) | |
tree | 9fb3f83ca4e8f5bc2d8d770086882ff1ab27a56c /src/datastore/perf_plugin_datastore.c | |
parent | 00abe8aad5a33c716a02e20cc8257f055edca869 (diff) | |
download | gnunet-5d2bfbd4a69f87c99083fc60954c884af69258f4.tar.gz gnunet-5d2bfbd4a69f87c99083fc60954c884af69258f4.zip |
-using testing in datastore tests
Diffstat (limited to 'src/datastore/perf_plugin_datastore.c')
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 58 |
1 files changed, 17 insertions, 41 deletions
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 186037429..daea8d796 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include "gnunet_datastore_plugin.h" | 29 | #include "gnunet_datastore_plugin.h" |
30 | #include <gauger.h> | 30 | #include <gauger.h> |
31 | 31 | ||
32 | #define VERBOSE GNUNET_NO | ||
33 | |||
34 | /** | 32 | /** |
35 | * Target datastore size (in bytes). Realistic sizes are | 33 | * Target datastore size (in bytes). Realistic sizes are |
36 | * more like 16 GB (not the default of 16 MB); however, | 34 | * more like 16 GB (not the default of 16 MB); however, |
@@ -164,10 +162,9 @@ iterate_zeros (void *cls, const GNUNET_HashCode * key, uint32_t size, | |||
164 | memcpy (&i, &cdata[4], sizeof (i)); | 162 | memcpy (&i, &cdata[4], sizeof (i)); |
165 | hits[i / 8] |= (1 << (i % 8)); | 163 | hits[i / 8] |= (1 << (i % 8)); |
166 | 164 | ||
167 | #if VERBOSE | 165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
168 | FPRINTF (stderr, "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | 166 | "Found result type=%u, priority=%u, size=%u, expire=%llu\n", |
169 | type, priority, size, (unsigned long long) expiration.abs_value); | 167 | type, priority, size, (unsigned long long) expiration.abs_value); |
170 | #endif | ||
171 | crc->cnt++; | 168 | crc->cnt++; |
172 | if (crc->cnt == PUT_10 / 4 - 1) | 169 | if (crc->cnt == PUT_10 / 4 - 1) |
173 | { | 170 | { |
@@ -343,9 +340,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
343 | GNUNET_break (0); | 340 | GNUNET_break (0); |
344 | crc->phase = RP_ERROR; | 341 | crc->phase = RP_ERROR; |
345 | } | 342 | } |
346 | #if VERBOSE | 343 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
347 | FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt); | 344 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); |
348 | #endif | ||
349 | switch (crc->phase) | 345 | switch (crc->phase) |
350 | { | 346 | { |
351 | case RP_ERROR: | 347 | case RP_ERROR: |
@@ -454,43 +450,22 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
454 | } | 450 | } |
455 | 451 | ||
456 | 452 | ||
457 | static int | 453 | int |
458 | check () | 454 | main (int argc, char *argv[]) |
459 | { | 455 | { |
456 | char *pos; | ||
457 | char dir_name[128]; | ||
460 | char cfg_name[128]; | 458 | char cfg_name[128]; |
461 | |||
462 | char *const argv[] = { | 459 | char *const argv[] = { |
463 | "perf-plugin-datastore", | 460 | "perf-plugin-datastore", |
464 | "-c", | 461 | "-c", |
465 | cfg_name, | 462 | cfg_name, |
466 | #if VERBOSE | ||
467 | "-L", "DEBUG", | ||
468 | #endif | ||
469 | NULL | 463 | NULL |
470 | }; | 464 | }; |
471 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 465 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
472 | GNUNET_GETOPT_OPTION_END | 466 | GNUNET_GETOPT_OPTION_END |
473 | }; | 467 | }; |
474 | 468 | ||
475 | GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); | ||
476 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
477 | "perf_plugin_datastore_data_%s.conf", plugin_name); | ||
478 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
479 | "perf-plugin-datastore", "nohelp", options, &run, NULL); | ||
480 | if (ok != 0) | ||
481 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
482 | return ok; | ||
483 | } | ||
484 | |||
485 | |||
486 | int | ||
487 | main (int argc, char *argv[]) | ||
488 | { | ||
489 | int ret; | ||
490 | char *pos; | ||
491 | char dir_name[128]; | ||
492 | |||
493 | sleep (1); | ||
494 | /* determine name of plugin to use */ | 469 | /* determine name of plugin to use */ |
495 | plugin_name = argv[0]; | 470 | plugin_name = argv[0]; |
496 | while (NULL != (pos = strstr (plugin_name, "_"))) | 471 | while (NULL != (pos = strstr (plugin_name, "_"))) |
@@ -499,23 +474,24 @@ main (int argc, char *argv[]) | |||
499 | pos[0] = 0; | 474 | pos[0] = 0; |
500 | else | 475 | else |
501 | pos = (char *) plugin_name; | 476 | pos = (char *) plugin_name; |
502 | |||
503 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s", | 477 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/perf-gnunet-datastore-%s", |
504 | plugin_name); | 478 | plugin_name); |
505 | GNUNET_DISK_directory_remove (dir_name); | 479 | GNUNET_DISK_directory_remove (dir_name); |
506 | GNUNET_log_setup ("perf-plugin-datastore", | 480 | GNUNET_log_setup ("perf-plugin-datastore", |
507 | #if VERBOSE | ||
508 | "DEBUG", | ||
509 | #else | ||
510 | "WARNING", | 481 | "WARNING", |
511 | #endif | ||
512 | NULL); | 482 | NULL); |
513 | ret = check (); | 483 | GNUNET_snprintf (category, sizeof (category), "DATASTORE-%s", plugin_name); |
484 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
485 | "perf_plugin_datastore_data_%s.conf", plugin_name); | ||
486 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
487 | "perf-plugin-datastore", "nohelp", options, &run, NULL); | ||
488 | if (ok != 0) | ||
489 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
514 | if (pos != plugin_name) | 490 | if (pos != plugin_name) |
515 | pos[0] = '.'; | 491 | pos[0] = '.'; |
516 | GNUNET_DISK_directory_remove (dir_name); | 492 | GNUNET_DISK_directory_remove (dir_name); |
517 | 493 | ||
518 | return ret; | 494 | return ok; |
519 | } | 495 | } |
520 | 496 | ||
521 | /* end of perf_plugin_datastore.c */ | 497 | /* end of perf_plugin_datastore.c */ |