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 | |
parent | 00abe8aad5a33c716a02e20cc8257f055edca869 (diff) | |
download | gnunet-5d2bfbd4a69f87c99083fc60954c884af69258f4.tar.gz gnunet-5d2bfbd4a69f87c99083fc60954c884af69258f4.zip |
-using testing in datastore tests
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/Makefile.am | 9 | ||||
-rw-r--r-- | src/datastore/perf_datastore_api.c | 95 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 58 | ||||
-rw-r--r-- | src/datastore/test_datastore_api.c | 101 | ||||
-rw-r--r-- | src/datastore/test_datastore_api_data_sqlite.conf | 2 | ||||
-rw-r--r-- | src/datastore/test_datastore_api_management.c | 131 | ||||
-rw-r--r-- | src/datastore/test_defaults.conf | 3 | ||||
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 71 |
8 files changed, 117 insertions, 353 deletions
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index e9774eddd..cd5b0d481 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am | |||
@@ -141,18 +141,21 @@ endif | |||
141 | test_datastore_api_sqlite_SOURCES = \ | 141 | test_datastore_api_sqlite_SOURCES = \ |
142 | test_datastore_api.c | 142 | test_datastore_api.c |
143 | test_datastore_api_sqlite_LDADD = \ | 143 | test_datastore_api_sqlite_LDADD = \ |
144 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
144 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 145 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
145 | $(top_builddir)/src/util/libgnunetutil.la | 146 | $(top_builddir)/src/util/libgnunetutil.la |
146 | 147 | ||
147 | test_datastore_api_management_sqlite_SOURCES = \ | 148 | test_datastore_api_management_sqlite_SOURCES = \ |
148 | test_datastore_api_management.c | 149 | test_datastore_api_management.c |
149 | test_datastore_api_management_sqlite_LDADD = \ | 150 | test_datastore_api_management_sqlite_LDADD = \ |
151 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
150 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 152 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
151 | $(top_builddir)/src/util/libgnunetutil.la | 153 | $(top_builddir)/src/util/libgnunetutil.la |
152 | 154 | ||
153 | perf_datastore_api_sqlite_SOURCES = \ | 155 | perf_datastore_api_sqlite_SOURCES = \ |
154 | perf_datastore_api.c | 156 | perf_datastore_api.c |
155 | perf_datastore_api_sqlite_LDADD = \ | 157 | perf_datastore_api_sqlite_LDADD = \ |
158 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
156 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 159 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
157 | $(top_builddir)/src/util/libgnunetutil.la | 160 | $(top_builddir)/src/util/libgnunetutil.la |
158 | 161 | ||
@@ -170,18 +173,21 @@ test_plugin_datastore_sqlite_LDADD = \ | |||
170 | test_datastore_api_mysql_SOURCES = \ | 173 | test_datastore_api_mysql_SOURCES = \ |
171 | test_datastore_api.c | 174 | test_datastore_api.c |
172 | test_datastore_api_mysql_LDADD = \ | 175 | test_datastore_api_mysql_LDADD = \ |
176 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
173 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 177 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
174 | $(top_builddir)/src/util/libgnunetutil.la | 178 | $(top_builddir)/src/util/libgnunetutil.la |
175 | 179 | ||
176 | test_datastore_api_management_mysql_SOURCES = \ | 180 | test_datastore_api_management_mysql_SOURCES = \ |
177 | test_datastore_api_management.c | 181 | test_datastore_api_management.c |
178 | test_datastore_api_management_mysql_LDADD = \ | 182 | test_datastore_api_management_mysql_LDADD = \ |
183 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
179 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 184 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
180 | $(top_builddir)/src/util/libgnunetutil.la | 185 | $(top_builddir)/src/util/libgnunetutil.la |
181 | 186 | ||
182 | perf_datastore_api_mysql_SOURCES = \ | 187 | perf_datastore_api_mysql_SOURCES = \ |
183 | perf_datastore_api.c | 188 | perf_datastore_api.c |
184 | perf_datastore_api_mysql_LDADD = \ | 189 | perf_datastore_api_mysql_LDADD = \ |
190 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
185 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 191 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
186 | $(top_builddir)/src/util/libgnunetutil.la | 192 | $(top_builddir)/src/util/libgnunetutil.la |
187 | 193 | ||
@@ -199,18 +205,21 @@ perf_plugin_datastore_mysql_LDADD = \ | |||
199 | test_datastore_api_postgres_SOURCES = \ | 205 | test_datastore_api_postgres_SOURCES = \ |
200 | test_datastore_api.c | 206 | test_datastore_api.c |
201 | test_datastore_api_postgres_LDADD = \ | 207 | test_datastore_api_postgres_LDADD = \ |
208 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
202 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 209 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
203 | $(top_builddir)/src/util/libgnunetutil.la | 210 | $(top_builddir)/src/util/libgnunetutil.la |
204 | 211 | ||
205 | test_datastore_api_management_postgres_SOURCES = \ | 212 | test_datastore_api_management_postgres_SOURCES = \ |
206 | test_datastore_api_management.c | 213 | test_datastore_api_management.c |
207 | test_datastore_api_management_postgres_LDADD = \ | 214 | test_datastore_api_management_postgres_LDADD = \ |
215 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
208 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 216 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
209 | $(top_builddir)/src/util/libgnunetutil.la | 217 | $(top_builddir)/src/util/libgnunetutil.la |
210 | 218 | ||
211 | perf_datastore_api_postgres_SOURCES = \ | 219 | perf_datastore_api_postgres_SOURCES = \ |
212 | perf_datastore_api.c | 220 | perf_datastore_api.c |
213 | perf_datastore_api_postgres_LDADD = \ | 221 | perf_datastore_api_postgres_LDADD = \ |
222 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
214 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | 223 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ |
215 | $(top_builddir)/src/util/libgnunetutil.la | 224 | $(top_builddir)/src/util/libgnunetutil.la |
216 | 225 | ||
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index cdbd6ae9c..e236b6235 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c | |||
@@ -36,19 +36,14 @@ | |||
36 | #include "gnunet_util_lib.h" | 36 | #include "gnunet_util_lib.h" |
37 | #include "gnunet_protocols.h" | 37 | #include "gnunet_protocols.h" |
38 | #include "gnunet_datastore_service.h" | 38 | #include "gnunet_datastore_service.h" |
39 | #include "gnunet_testing_lib-new.h" | ||
39 | #include <gauger.h> | 40 | #include <gauger.h> |
40 | 41 | ||
41 | #define VERBOSE GNUNET_NO | ||
42 | |||
43 | /** | 42 | /** |
44 | * How long until we give up on transmitting the message? | 43 | * How long until we give up on transmitting the message? |
45 | */ | 44 | */ |
46 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 45 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
47 | 46 | ||
48 | static const char *plugin_name; | ||
49 | |||
50 | static struct GNUNET_DATASTORE_Handle *datastore; | ||
51 | |||
52 | /** | 47 | /** |
53 | * Target datastore size (in bytes). | 48 | * Target datastore size (in bytes). |
54 | */ | 49 | */ |
@@ -81,8 +76,13 @@ static unsigned long long stored_ops; | |||
81 | 76 | ||
82 | static struct GNUNET_TIME_Absolute start_time; | 77 | static struct GNUNET_TIME_Absolute start_time; |
83 | 78 | ||
79 | static const char *plugin_name; | ||
80 | |||
81 | static struct GNUNET_DATASTORE_Handle *datastore; | ||
82 | |||
84 | static int ok; | 83 | static int ok; |
85 | 84 | ||
85 | |||
86 | enum RunPhase | 86 | enum RunPhase |
87 | { | 87 | { |
88 | RP_DONE = 0, | 88 | RP_DONE = 0, |
@@ -103,13 +103,10 @@ struct CpsRunContext | |||
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | |||
107 | static void | 106 | static void |
108 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 107 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
109 | 108 | ||
110 | 109 | ||
111 | |||
112 | |||
113 | static void | 110 | static void |
114 | check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) | 111 | check_success (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
115 | { | 112 | { |
@@ -297,7 +294,7 @@ run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, c | |||
297 | 294 | ||
298 | 295 | ||
299 | static void | 296 | static void |
300 | run (void *cls, char *const *args, const char *cfgfile, | 297 | run (void *cls, |
301 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 298 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
302 | { | 299 | { |
303 | struct CpsRunContext *crc; | 300 | struct CpsRunContext *crc; |
@@ -322,85 +319,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
322 | } | 319 | } |
323 | 320 | ||
324 | 321 | ||
325 | static int | ||
326 | check () | ||
327 | { | ||
328 | struct GNUNET_OS_Process *proc; | ||
329 | char cfg_name[128]; | ||
330 | |||
331 | char *const argv[] = { | ||
332 | "perf-datastore-api", | ||
333 | "-c", | ||
334 | cfg_name, | ||
335 | #if VERBOSE | ||
336 | "-L", "DEBUG", | ||
337 | #endif | ||
338 | NULL | ||
339 | }; | ||
340 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
341 | GNUNET_GETOPT_OPTION_END | ||
342 | }; | ||
343 | |||
344 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
345 | "test_datastore_api_data_%s.conf", plugin_name); | ||
346 | proc = | ||
347 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
348 | "gnunet-service-arm", | ||
349 | #if VERBOSE | ||
350 | "-L", "DEBUG", | ||
351 | #endif | ||
352 | "-c", cfg_name, NULL); | ||
353 | GNUNET_assert (NULL != proc); | ||
354 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
355 | "perf-datastore-api", "nohelp", options, &run, NULL); | ||
356 | sleep (1); /* give datastore chance to process 'DROP' */ | ||
357 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | ||
358 | { | ||
359 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
360 | ok = 1; | ||
361 | } | ||
362 | GNUNET_OS_process_wait (proc); | ||
363 | GNUNET_OS_process_destroy (proc); | ||
364 | proc = NULL; | ||
365 | return ok; | ||
366 | } | ||
367 | |||
368 | |||
369 | int | 322 | int |
370 | main (int argc, char *argv[]) | 323 | main (int argc, char *argv[]) |
371 | { | 324 | { |
372 | int ret; | ||
373 | char *pos; | 325 | char *pos; |
374 | char dir_name[128]; | 326 | char cfg_name[128]; |
375 | 327 | ||
376 | sleep (1); | ||
377 | /* determine name of plugin to use */ | 328 | /* determine name of plugin to use */ |
378 | plugin_name = argv[0]; | 329 | plugin_name = argv[0]; |
379 | while (NULL != (pos = strstr (plugin_name, "_"))) | 330 | while (NULL != (pos = strstr (plugin_name, "_"))) |
380 | plugin_name = pos + 1; | 331 | plugin_name = pos + 1; |
381 | if (NULL != (pos = strstr (plugin_name, "."))) | 332 | if (NULL != (pos = strstr (plugin_name, "."))) |
382 | pos[0] = 0; | 333 | pos[0] = '\0'; |
383 | else | 334 | else |
384 | pos = (char *) plugin_name; | 335 | pos = (char *) plugin_name; |
385 | 336 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | |
386 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", | 337 | "test_datastore_api_data_%s.conf", plugin_name); |
387 | plugin_name); | 338 | if (0 != |
388 | GNUNET_DISK_directory_remove (dir_name); | 339 | GNUNET_TESTING_peer_run ("perf-gnunet-datastore", |
389 | GNUNET_log_setup ("perf-datastore-api", | 340 | cfg_name, |
390 | #if VERBOSE | 341 | &run, |
391 | "DEBUG", | 342 | NULL)) |
392 | #else | 343 | return 1; |
393 | "WARNING", | 344 | return ok; |
394 | #endif | ||
395 | NULL); | ||
396 | ret = check (); | ||
397 | if (pos != plugin_name) | ||
398 | pos[0] = '.'; | ||
399 | #if REPORT_ID | ||
400 | FPRINTF (stderr, "%s", "\n"); | ||
401 | #endif | ||
402 | GNUNET_DISK_directory_remove (dir_name); | ||
403 | return ret; | ||
404 | } | 345 | } |
405 | 346 | ||
406 | /* end of perf_datastore_api.c */ | 347 | /* end of perf_datastore_api.c */ |
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 */ |
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 4c0736619..cfeac86db 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -30,10 +30,8 @@ | |||
30 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
31 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
32 | #include "gnunet_datastore_service.h" | 32 | #include "gnunet_datastore_service.h" |
33 | #include "gnunet_testing_lib-new.h" | ||
33 | 34 | ||
34 | #define VERBOSE GNUNET_NO | ||
35 | |||
36 | #define START_DATASTORE GNUNET_YES | ||
37 | 35 | ||
38 | /** | 36 | /** |
39 | * How long until we give up on transmitting the message? | 37 | * How long until we give up on transmitting the message? |
@@ -314,16 +312,12 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
314 | struct CpsRunContext *crc = cls; | 312 | struct CpsRunContext *crc = cls; |
315 | 313 | ||
316 | ok = (int) crc->phase; | 314 | ok = (int) crc->phase; |
317 | #if VERBOSE | ||
318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test in phase %u\n", crc->phase); | 315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test in phase %u\n", crc->phase); |
319 | #endif | ||
320 | switch (crc->phase) | 316 | switch (crc->phase) |
321 | { | 317 | { |
322 | case RP_PUT: | 318 | case RP_PUT: |
323 | #if VERBOSE | ||
324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", | 319 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", |
325 | crc->i); | 320 | crc->i); |
326 | #endif | ||
327 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 321 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
328 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), | 322 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), |
329 | get_data (crc->i), get_type (crc->i), | 323 | get_data (crc->i), get_type (crc->i), |
@@ -336,10 +330,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
336 | break; | 330 | break; |
337 | case RP_GET: | 331 | case RP_GET: |
338 | crc->i--; | 332 | crc->i--; |
339 | #if VERBOSE | ||
340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", | 333 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", |
341 | crc->i); | 334 | crc->i); |
342 | #endif | ||
343 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 335 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
344 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, | 336 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
345 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, | 337 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, |
@@ -347,10 +339,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
347 | break; | 339 | break; |
348 | case RP_DEL: | 340 | case RP_DEL: |
349 | crc->i--; | 341 | crc->i--; |
350 | #if VERBOSE | ||
351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL", | 342 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL", |
352 | crc->i); | 343 | crc->i); |
353 | #endif | ||
354 | crc->data = NULL; | 344 | crc->data = NULL; |
355 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 345 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
356 | GNUNET_assert (NULL != | 346 | GNUNET_assert (NULL != |
@@ -359,10 +349,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
359 | &delete_value, crc)); | 349 | &delete_value, crc)); |
360 | break; | 350 | break; |
361 | case RP_DO_DEL: | 351 | case RP_DO_DEL: |
362 | #if VERBOSE | ||
363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DO_DEL", | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DO_DEL", |
364 | crc->i); | 353 | crc->i); |
365 | #endif | ||
366 | if (crc->i == 0) | 354 | if (crc->i == 0) |
367 | { | 355 | { |
368 | crc->i = ITERATIONS; | 356 | crc->i = ITERATIONS; |
@@ -379,10 +367,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
379 | break; | 367 | break; |
380 | case RP_DELVALIDATE: | 368 | case RP_DELVALIDATE: |
381 | crc->i--; | 369 | crc->i--; |
382 | #if VERBOSE | ||
383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", | 370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", |
384 | "DEL-VALIDATE", crc->i); | 371 | "DEL-VALIDATE", crc->i); |
385 | #endif | ||
386 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 372 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
387 | GNUNET_assert (NULL != | 373 | GNUNET_assert (NULL != |
388 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, | 374 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
@@ -433,9 +419,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
433 | &check_update, crc)); | 419 | &check_update, crc)); |
434 | break; | 420 | break; |
435 | case RP_DONE: | 421 | case RP_DONE: |
436 | #if VERBOSE | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); | 422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); |
438 | #endif | ||
439 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); | 423 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); |
440 | GNUNET_free (crc); | 424 | GNUNET_free (crc); |
441 | ok = 0; | 425 | ok = 0; |
@@ -479,7 +463,7 @@ run_tests (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiratio | |||
479 | 463 | ||
480 | 464 | ||
481 | static void | 465 | static void |
482 | run (void *cls, char *const *args, const char *cfgfile, | 466 | run (void *cls, |
483 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 467 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
484 | { | 468 | { |
485 | struct CpsRunContext *crc; | 469 | struct CpsRunContext *crc; |
@@ -504,88 +488,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
504 | } | 488 | } |
505 | 489 | ||
506 | 490 | ||
507 | static int | ||
508 | check () | ||
509 | { | ||
510 | char cfg_name[128]; | ||
511 | |||
512 | #if START_DATASTORE | ||
513 | struct GNUNET_OS_Process *proc; | ||
514 | #endif | ||
515 | char *const argv[] = { | ||
516 | "test-datastore-api", | ||
517 | "-c", | ||
518 | cfg_name, | ||
519 | #if VERBOSE | ||
520 | "-L", "DEBUG", | ||
521 | #endif | ||
522 | NULL | ||
523 | }; | ||
524 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
525 | GNUNET_GETOPT_OPTION_END | ||
526 | }; | ||
527 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
528 | "test_datastore_api_data_%s.conf", plugin_name); | ||
529 | #if START_DATASTORE | ||
530 | proc = | ||
531 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
532 | "gnunet-service-arm", | ||
533 | #if VERBOSE | ||
534 | "-L", "DEBUG", | ||
535 | #endif | ||
536 | "-c", cfg_name, NULL); | ||
537 | #endif | ||
538 | GNUNET_assert (NULL != proc); | ||
539 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
540 | "test-datastore-api", "nohelp", options, &run, NULL); | ||
541 | #if START_DATASTORE | ||
542 | sleep (1); /* give datastore chance to receive 'DROP' request */ | ||
543 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | ||
544 | { | ||
545 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
546 | ok = 1; | ||
547 | } | ||
548 | GNUNET_OS_process_wait (proc); | ||
549 | GNUNET_OS_process_destroy (proc); | ||
550 | proc = NULL; | ||
551 | #endif | ||
552 | if (ok != 0) | ||
553 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
554 | return ok; | ||
555 | } | ||
556 | |||
557 | int | 491 | int |
558 | main (int argc, char *argv[]) | 492 | main (int argc, char *argv[]) |
559 | { | 493 | { |
560 | int ret; | ||
561 | char *pos; | 494 | char *pos; |
562 | char dir_name[128]; | 495 | char cfg_name[128]; |
563 | 496 | ||
564 | sleep (1); | ||
565 | /* determine name of plugin to use */ | 497 | /* determine name of plugin to use */ |
566 | plugin_name = argv[0]; | 498 | plugin_name = argv[0]; |
567 | while (NULL != (pos = strstr (plugin_name, "_"))) | 499 | while (NULL != (pos = strstr (plugin_name, "_"))) |
568 | plugin_name = pos + 1; | 500 | plugin_name = pos + 1; |
569 | if (NULL != (pos = strstr (plugin_name, "."))) | 501 | if (NULL != (pos = strstr (plugin_name, "."))) |
570 | pos[0] = 0; | 502 | pos[0] = '\0'; |
571 | else | 503 | else |
572 | pos = (char *) plugin_name; | 504 | pos = (char *) plugin_name; |
573 | 505 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | |
574 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", | 506 | "test_datastore_api_data_%s.conf", plugin_name); |
575 | plugin_name); | 507 | if (0 != |
576 | GNUNET_DISK_directory_remove (dir_name); | 508 | GNUNET_TESTING_peer_run ("test-gnunet-datastore", |
577 | GNUNET_log_setup ("test-datastore-api", | 509 | cfg_name, |
578 | #if VERBOSE | 510 | &run, |
579 | "DEBUG", | 511 | NULL)) |
580 | #else | 512 | return 1; |
581 | "WARNING", | 513 | return ok; |
582 | #endif | ||
583 | NULL); | ||
584 | ret = check (); | ||
585 | if (pos != plugin_name) | ||
586 | pos[0] = '.'; | ||
587 | GNUNET_DISK_directory_remove (dir_name); | ||
588 | return ret; | ||
589 | } | 514 | } |
590 | 515 | ||
591 | /* end of test_datastore_api.c */ | 516 | /* end of test_datastore_api.c */ |
diff --git a/src/datastore/test_datastore_api_data_sqlite.conf b/src/datastore/test_datastore_api_data_sqlite.conf index 098f9d2b6..a743b8008 100644 --- a/src/datastore/test_datastore_api_data_sqlite.conf +++ b/src/datastore/test_datastore_api_data_sqlite.conf | |||
@@ -19,6 +19,4 @@ PORT = 42464 | |||
19 | [datastore] | 19 | [datastore] |
20 | QUOTA = 10 MB | 20 | QUOTA = 10 MB |
21 | 21 | ||
22 | [fs] | ||
23 | AUTOSTART = NO | ||
24 | 22 | ||
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index bb3898e08..9b5fb4e6f 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c | |||
@@ -22,13 +22,12 @@ | |||
22 | * @brief Test for the space management functions of the datastore implementation. | 22 | * @brief Test for the space management functions of the datastore implementation. |
23 | * @author Christian Grothoff | 23 | * @author Christian Grothoff |
24 | */ | 24 | */ |
25 | |||
26 | #include "platform.h" | 25 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_protocols.h" | 27 | #include "gnunet_protocols.h" |
29 | #include "gnunet_datastore_service.h" | 28 | #include "gnunet_datastore_service.h" |
29 | #include "gnunet_testing_lib-new.h" | ||
30 | 30 | ||
31 | #define VERBOSE GNUNET_NO | ||
32 | 31 | ||
33 | /** | 32 | /** |
34 | * How long until we give up on transmitting the message? | 33 | * How long until we give up on transmitting the message? |
@@ -41,6 +40,27 @@ | |||
41 | */ | 40 | */ |
42 | #define ITERATIONS 5000 | 41 | #define ITERATIONS 5000 |
43 | 42 | ||
43 | enum RunPhase | ||
44 | { | ||
45 | RP_PUT, | ||
46 | RP_GET, | ||
47 | RP_DONE, | ||
48 | RP_GET_FAIL | ||
49 | }; | ||
50 | |||
51 | |||
52 | struct CpsRunContext | ||
53 | { | ||
54 | GNUNET_HashCode key; | ||
55 | int i; | ||
56 | int found; | ||
57 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
58 | void *data; | ||
59 | enum RunPhase phase; | ||
60 | uint64_t offset; | ||
61 | }; | ||
62 | |||
63 | |||
44 | static struct GNUNET_DATASTORE_Handle *datastore; | 64 | static struct GNUNET_DATASTORE_Handle *datastore; |
45 | 65 | ||
46 | static struct GNUNET_TIME_Absolute now; | 66 | static struct GNUNET_TIME_Absolute now; |
@@ -49,6 +69,7 @@ static int ok; | |||
49 | 69 | ||
50 | static const char *plugin_name; | 70 | static const char *plugin_name; |
51 | 71 | ||
72 | |||
52 | static size_t | 73 | static size_t |
53 | get_size (int i) | 74 | get_size (int i) |
54 | { | 75 | { |
@@ -96,26 +117,6 @@ get_expiration (int i) | |||
96 | return av; | 117 | return av; |
97 | } | 118 | } |
98 | 119 | ||
99 | enum RunPhase | ||
100 | { | ||
101 | RP_PUT, | ||
102 | RP_GET, | ||
103 | RP_DONE, | ||
104 | RP_GET_FAIL | ||
105 | }; | ||
106 | |||
107 | |||
108 | struct CpsRunContext | ||
109 | { | ||
110 | GNUNET_HashCode key; | ||
111 | int i; | ||
112 | int found; | ||
113 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
114 | void *data; | ||
115 | enum RunPhase phase; | ||
116 | uint64_t offset; | ||
117 | }; | ||
118 | |||
119 | 120 | ||
120 | static void | 121 | static void |
121 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 122 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
@@ -193,10 +194,8 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
193 | switch (crc->phase) | 194 | switch (crc->phase) |
194 | { | 195 | { |
195 | case RP_PUT: | 196 | case RP_PUT: |
196 | #if VERBOSE | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", | 197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", |
198 | crc->i); | 198 | crc->i); |
199 | #endif | ||
200 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 199 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
201 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), | 200 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), |
202 | get_data (crc->i), get_type (crc->i), | 201 | get_data (crc->i), get_type (crc->i), |
@@ -214,20 +213,16 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
214 | } | 213 | } |
215 | break; | 214 | break; |
216 | case RP_GET: | 215 | case RP_GET: |
217 | #if VERBOSE | ||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", | 216 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", |
219 | crc->i); | 217 | crc->i); |
220 | #endif | ||
221 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 218 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
222 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, | 219 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, |
223 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, | 220 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, |
224 | crc); | 221 | crc); |
225 | break; | 222 | break; |
226 | case RP_GET_FAIL: | 223 | case RP_GET_FAIL: |
227 | #if VERBOSE | ||
228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", | 224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", |
229 | crc->i); | 225 | crc->i); |
230 | #endif | ||
231 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 226 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
232 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, | 227 | GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, |
233 | get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, | 228 | get_type (crc->i), 1, 1, TIMEOUT, &check_nothing, |
@@ -235,9 +230,7 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
235 | break; | 230 | break; |
236 | case RP_DONE: | 231 | case RP_DONE: |
237 | GNUNET_assert (0 == crc->i); | 232 | GNUNET_assert (0 == crc->i); |
238 | #if VERBOSE | ||
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); | 233 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished, disconnecting\n"); |
240 | #endif | ||
241 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); | 234 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_YES); |
242 | GNUNET_free (crc); | 235 | GNUNET_free (crc); |
243 | ok = 0; | 236 | ok = 0; |
@@ -265,7 +258,7 @@ run_tests (void *cls, int success, struct GNUNET_TIME_Absolute min_expiration, c | |||
265 | 258 | ||
266 | 259 | ||
267 | static void | 260 | static void |
268 | run (void *cls, char *const *args, const char *cfgfile, | 261 | run (void *cls, |
269 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 262 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
270 | { | 263 | { |
271 | struct CpsRunContext *crc; | 264 | struct CpsRunContext *crc; |
@@ -290,61 +283,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
290 | } | 283 | } |
291 | 284 | ||
292 | 285 | ||
293 | |||
294 | static int | ||
295 | check () | ||
296 | { | ||
297 | struct GNUNET_OS_Process *proc; | ||
298 | char cfg_name[128]; | ||
299 | |||
300 | char *const argv[] = { | ||
301 | "test-datastore-api-management", | ||
302 | "-c", | ||
303 | cfg_name, | ||
304 | #if VERBOSE | ||
305 | "-L", "DEBUG", | ||
306 | #endif | ||
307 | NULL | ||
308 | }; | ||
309 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
310 | GNUNET_GETOPT_OPTION_END | ||
311 | }; | ||
312 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
313 | "test_datastore_api_data_%s.conf", plugin_name); | ||
314 | proc = | ||
315 | GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
316 | "gnunet-service-arm", | ||
317 | #if VERBOSE | ||
318 | "-L", "DEBUG", | ||
319 | #endif | ||
320 | "-c", cfg_name, NULL); | ||
321 | GNUNET_assert (NULL != proc); | ||
322 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
323 | "test-datastore-api-management", "nohelp", options, &run, | ||
324 | NULL); | ||
325 | sleep (1); /* give datastore chance to process 'DROP' request */ | ||
326 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | ||
327 | { | ||
328 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
329 | ok = 1; | ||
330 | } | ||
331 | GNUNET_OS_process_wait (proc); | ||
332 | GNUNET_OS_process_destroy (proc); | ||
333 | proc = NULL; | ||
334 | if (ok != 0) | ||
335 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
336 | return ok; | ||
337 | } | ||
338 | |||
339 | int | 286 | int |
340 | main (int argc, char *argv[]) | 287 | main (int argc, char *argv[]) |
341 | { | 288 | { |
342 | int ret; | ||
343 | |||
344 | char *pos; | 289 | char *pos; |
345 | char dir_name[128]; | 290 | char cfg_name[128]; |
346 | 291 | ||
347 | sleep (1); | ||
348 | /* determine name of plugin to use */ | 292 | /* determine name of plugin to use */ |
349 | plugin_name = argv[0]; | 293 | plugin_name = argv[0]; |
350 | while (NULL != (pos = strstr (plugin_name, "_"))) | 294 | while (NULL != (pos = strstr (plugin_name, "_"))) |
@@ -353,22 +297,15 @@ main (int argc, char *argv[]) | |||
353 | pos[0] = 0; | 297 | pos[0] = 0; |
354 | else | 298 | else |
355 | pos = (char *) plugin_name; | 299 | pos = (char *) plugin_name; |
356 | 300 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | |
357 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", | 301 | "test_datastore_api_data_%s.conf", plugin_name); |
358 | plugin_name); | 302 | if (0 != |
359 | GNUNET_DISK_directory_remove (dir_name); | 303 | GNUNET_TESTING_peer_run ("test-gnunet-datastore-management", |
360 | GNUNET_log_setup ("test-datastore-api-management", | 304 | cfg_name, |
361 | #if VERBOSE | 305 | &run, |
362 | "DEBUG", | 306 | NULL)) |
363 | #else | 307 | return 1; |
364 | "WARNING", | 308 | return ok; |
365 | #endif | ||
366 | NULL); | ||
367 | ret = check (); | ||
368 | if (pos != plugin_name) | ||
369 | pos[0] = '.'; | ||
370 | GNUNET_DISK_directory_remove (dir_name); | ||
371 | return ret; | ||
372 | } | 309 | } |
373 | 310 | ||
374 | /* end of test_datastore_api_management.c */ | 311 | /* end of test_datastore_api_management.c */ |
diff --git a/src/datastore/test_defaults.conf b/src/datastore/test_defaults.conf index ce27c018a..73e4a267d 100644 --- a/src/datastore/test_defaults.conf +++ b/src/datastore/test_defaults.conf | |||
@@ -31,3 +31,6 @@ AUTOSTART = NO | |||
31 | 31 | ||
32 | [namestore] | 32 | [namestore] |
33 | AUTOSTART = NO | 33 | AUTOSTART = NO |
34 | |||
35 | [fs] | ||
36 | AUTOSTART = NO | ||
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 16fe40ceb..de9e7c2ab 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_protocols.h" |
29 | #include "gnunet_datastore_plugin.h" | 29 | #include "gnunet_datastore_plugin.h" |
30 | 30 | ||
31 | #define VERBOSE GNUNET_NO | ||
32 | |||
33 | /** | 31 | /** |
34 | * Number of put operations to perform. | 32 | * Number of put operations to perform. |
35 | */ | 33 | */ |
@@ -117,10 +115,9 @@ put_value (struct GNUNET_DATASTORE_PluginFunctions *api, int i, int k) | |||
117 | value[0] = k; | 115 | value[0] = k; |
118 | msg = NULL; | 116 | msg = NULL; |
119 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 117 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
120 | #if VERBOSE | 118 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
121 | FPRINTF (stderr, "putting type %u, anon %u under key %s\n", i + 1, i, | 119 | "putting type %u, anon %u under key %s\n", i + 1, i, |
122 | GNUNET_h2s (&key)); | 120 | GNUNET_h2s (&key)); |
123 | #endif | ||
124 | if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , | 121 | if (GNUNET_OK != api->put (api->cls, &key, size, value, i + 1 /* type */ , |
125 | prio, i /* anonymity */ , | 122 | prio, i /* anonymity */ , |
126 | 0 /* replication */ , | 123 | 0 /* replication */ , |
@@ -159,12 +156,10 @@ iterate_one_shot (void *cls, const GNUNET_HashCode * key, uint32_t size, | |||
159 | GNUNET_assert (key != NULL); | 156 | GNUNET_assert (key != NULL); |
160 | guid = uid; | 157 | guid = uid; |
161 | crc->phase++; | 158 | crc->phase++; |
162 | #if VERBOSE | 159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
163 | FPRINTF (stderr, | 160 | "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", |
164 | "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", | 161 | type, priority, size, (unsigned long long) expiration.abs_value, |
165 | type, priority, size, (unsigned long long) expiration.abs_value, | 162 | GNUNET_h2s (key)); |
166 | GNUNET_h2s (key)); | ||
167 | #endif | ||
168 | GNUNET_SCHEDULER_add_now (&test, crc); | 163 | GNUNET_SCHEDULER_add_now (&test, crc); |
169 | return GNUNET_OK; | 164 | return GNUNET_OK; |
170 | } | 165 | } |
@@ -229,9 +224,8 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
229 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n"); | 224 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test aborted.\n"); |
230 | crc->phase = RP_ERROR; | 225 | crc->phase = RP_ERROR; |
231 | } | 226 | } |
232 | #if VERBOSE | 227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
233 | FPRINTF (stderr, "In phase %d, iteration %u\n", crc->phase, crc->cnt); | 228 | "In phase %d, iteration %u\n", crc->phase, crc->cnt); |
234 | #endif | ||
235 | switch (crc->phase) | 229 | switch (crc->phase) |
236 | { | 230 | { |
237 | case RP_ERROR: | 231 | case RP_ERROR: |
@@ -355,42 +349,23 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
355 | } | 349 | } |
356 | 350 | ||
357 | 351 | ||
358 | static int | 352 | |
359 | check () | 353 | int |
354 | main (int argc, char *argv[]) | ||
360 | { | 355 | { |
356 | char *pos; | ||
357 | char dir_name[128]; | ||
361 | char cfg_name[128]; | 358 | char cfg_name[128]; |
362 | 359 | char *const xargv[] = { | |
363 | char *const argv[] = { | ||
364 | "test-plugin-datastore", | 360 | "test-plugin-datastore", |
365 | "-c", | 361 | "-c", |
366 | cfg_name, | 362 | cfg_name, |
367 | #if VERBOSE | ||
368 | "-L", "DEBUG", | ||
369 | #endif | ||
370 | NULL | 363 | NULL |
371 | }; | 364 | }; |
372 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 365 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
373 | GNUNET_GETOPT_OPTION_END | 366 | GNUNET_GETOPT_OPTION_END |
374 | }; | 367 | }; |
375 | 368 | ||
376 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), | ||
377 | "test_plugin_datastore_data_%s.conf", plugin_name); | ||
378 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, | ||
379 | "test-plugin-datastore", "nohelp", options, &run, NULL); | ||
380 | if (ok != 0) | ||
381 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
382 | return ok; | ||
383 | } | ||
384 | |||
385 | |||
386 | int | ||
387 | main (int argc, char *argv[]) | ||
388 | { | ||
389 | int ret; | ||
390 | char *pos; | ||
391 | char dir_name[128]; | ||
392 | |||
393 | sleep (1); | ||
394 | /* determine name of plugin to use */ | 369 | /* determine name of plugin to use */ |
395 | plugin_name = argv[0]; | 370 | plugin_name = argv[0]; |
396 | while (NULL != (pos = strstr (plugin_name, "_"))) | 371 | while (NULL != (pos = strstr (plugin_name, "_"))) |
@@ -404,18 +379,18 @@ main (int argc, char *argv[]) | |||
404 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); | 379 | "/tmp/test-gnunet-datastore-plugin-%s", plugin_name); |
405 | GNUNET_DISK_directory_remove (dir_name); | 380 | GNUNET_DISK_directory_remove (dir_name); |
406 | GNUNET_log_setup ("test-plugin-datastore", | 381 | GNUNET_log_setup ("test-plugin-datastore", |
407 | #if VERBOSE | ||
408 | "DEBUG", | ||
409 | #else | ||
410 | "WARNING", | 382 | "WARNING", |
411 | #endif | ||
412 | NULL); | 383 | NULL); |
413 | ret = check (); | 384 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), |
385 | "test_plugin_datastore_data_%s.conf", plugin_name); | ||
386 | GNUNET_PROGRAM_run ((sizeof (xargv) / sizeof (char *)) - 1, xargv, | ||
387 | "test-plugin-datastore", "nohelp", options, &run, NULL); | ||
388 | if (ok != 0) | ||
389 | FPRINTF (stderr, "Missed some testcases: %u\n", ok); | ||
414 | if (pos != plugin_name) | 390 | if (pos != plugin_name) |
415 | pos[0] = '.'; | 391 | pos[0] = '.'; |
416 | GNUNET_DISK_directory_remove (dir_name); | 392 | GNUNET_DISK_directory_remove (dir_name); |
417 | 393 | return ok; | |
418 | return ret; | ||
419 | } | 394 | } |
420 | 395 | ||
421 | /* end of test_plugin_datastore.c */ | 396 | /* end of test_plugin_datastore.c */ |