diff options
-rw-r--r-- | src/namestore/test_namestore_api.c | 22 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_create.c | 180 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_create_update.c | 331 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_lookup.c | 150 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_lookup_specific_type.c | 198 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_put.c | 19 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_remove.c | 150 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_remove_not_existing_record.c | 151 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_sign_verify.c | 38 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration.c | 151 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_specific_zone.c | 158 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_stop.c | 156 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_to_name.c | 134 | ||||
-rw-r--r-- | src/namestore/test_namestore_record_serialization.c | 4 |
14 files changed, 474 insertions, 1368 deletions
diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c index 55601390a..9e56e569d 100644 --- a/src/namestore/test_namestore_api.c +++ b/src/namestore/test_namestore_api.c | |||
@@ -27,11 +27,14 @@ | |||
27 | #include "gnunet_testing_lib-new.h" | 27 | #include "gnunet_testing_lib-new.h" |
28 | 28 | ||
29 | #define TEST_RECORD_TYPE 1234 | 29 | #define TEST_RECORD_TYPE 1234 |
30 | |||
30 | #define TEST_RECORD_DATALEN 123 | 31 | #define TEST_RECORD_DATALEN 123 |
32 | |||
31 | #define TEST_RECORD_DATA 'a' | 33 | #define TEST_RECORD_DATA 'a' |
32 | 34 | ||
33 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 35 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
34 | 36 | ||
37 | |||
35 | static struct GNUNET_NAMESTORE_Handle *nsh; | 38 | static struct GNUNET_NAMESTORE_Handle *nsh; |
36 | 39 | ||
37 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 40 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
@@ -118,24 +121,6 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
118 | 121 | ||
119 | 122 | ||
120 | static void | 123 | static void |
121 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
122 | { | ||
123 | char *afsdir; | ||
124 | |||
125 | if (GNUNET_OK == | ||
126 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
127 | "FILENAME", &afsdir)) | ||
128 | { | ||
129 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
130 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
131 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
132 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
133 | GNUNET_free (afsdir); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | |||
138 | static void | ||
139 | run (void *cls, | 124 | run (void *cls, |
140 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 125 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
141 | { | 126 | { |
@@ -144,7 +129,6 @@ run (void *cls, | |||
144 | char *hostkey_file; | 129 | char *hostkey_file; |
145 | const char * name = "dummy.dummy.gnunet"; | 130 | const char * name = "dummy.dummy.gnunet"; |
146 | 131 | ||
147 | delete_existing_db(cfg); | ||
148 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 132 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); |
149 | 133 | ||
150 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 134 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c index 131c934cb..916168738 100644 --- a/src/namestore/test_namestore_api_create.c +++ b/src/namestore/test_namestore_api_create.c | |||
@@ -24,65 +24,50 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | 31 | ||
32 | #define RECORDS 1 | 32 | #define RECORDS 1 |
33 | |||
33 | #define TEST_RECORD_TYPE 1234 | 34 | #define TEST_RECORD_TYPE 1234 |
35 | |||
34 | #define TEST_RECORD_DATALEN 123 | 36 | #define TEST_RECORD_DATALEN 123 |
37 | |||
35 | #define TEST_RECORD_DATA 'a' | 38 | #define TEST_RECORD_DATA 'a' |
36 | 39 | ||
37 | #define TEST_CREATE_RECORD_TYPE 4321 | 40 | #define TEST_CREATE_RECORD_TYPE 4321 |
41 | |||
38 | #define TEST_CREATE_RECORD_DATALEN 255 | 42 | #define TEST_CREATE_RECORD_DATALEN 255 |
43 | |||
39 | #define TEST_CREATE_RECORD_DATA 'b' | 44 | #define TEST_CREATE_RECORD_DATA 'b' |
40 | 45 | ||
41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 46 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
42 | 47 | ||
48 | |||
43 | static struct GNUNET_NAMESTORE_Handle * nsh; | 49 | static struct GNUNET_NAMESTORE_Handle * nsh; |
44 | 50 | ||
45 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 51 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
46 | static struct GNUNET_OS_Process *arm; | ||
47 | 52 | ||
48 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 53 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
54 | |||
49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 55 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 56 | |
51 | struct GNUNET_CRYPTO_RsaSignature *s_signature_updated; | 57 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; |
58 | |||
59 | static struct GNUNET_CRYPTO_RsaSignature *s_signature_updated; | ||
60 | |||
52 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 61 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
53 | struct GNUNET_NAMESTORE_RecordData *s_first_record; | ||
54 | struct GNUNET_NAMESTORE_RecordData *s_second_record; | ||
55 | static char *s_name; | ||
56 | 62 | ||
63 | static struct GNUNET_NAMESTORE_RecordData *s_first_record; | ||
57 | 64 | ||
65 | static struct GNUNET_NAMESTORE_RecordData *s_second_record; | ||
66 | |||
67 | static char *s_name; | ||
58 | 68 | ||
59 | static int res; | 69 | static int res; |
60 | 70 | ||
61 | static void | ||
62 | start_arm (const char *cfgname) | ||
63 | { | ||
64 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
65 | "gnunet-service-arm", "-c", cfgname, | ||
66 | #if VERBOSE_PEERS | ||
67 | "-L", "DEBUG", | ||
68 | #else | ||
69 | "-L", "ERROR", | ||
70 | #endif | ||
71 | NULL); | ||
72 | } | ||
73 | |||
74 | static void | ||
75 | stop_arm () | ||
76 | { | ||
77 | if (NULL != arm) | ||
78 | { | ||
79 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
80 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
81 | GNUNET_OS_process_wait (arm); | ||
82 | GNUNET_OS_process_destroy (arm); | ||
83 | arm = NULL; | ||
84 | } | ||
85 | } | ||
86 | 71 | ||
87 | /** | 72 | /** |
88 | * Re-establish the connection to the service. | 73 | * Re-establish the connection to the service. |
@@ -96,14 +81,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
96 | if (nsh != NULL) | 81 | if (nsh != NULL) |
97 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 82 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
98 | nsh = NULL; | 83 | nsh = NULL; |
99 | |||
100 | if (privkey != NULL) | 84 | if (privkey != NULL) |
101 | GNUNET_CRYPTO_rsa_key_free (privkey); | 85 | GNUNET_CRYPTO_rsa_key_free (privkey); |
102 | privkey = NULL; | 86 | privkey = NULL; |
103 | |||
104 | if (NULL != arm) | ||
105 | stop_arm(); | ||
106 | |||
107 | res = 1; | 87 | res = 1; |
108 | } | 88 | } |
109 | 89 | ||
@@ -116,30 +96,26 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
116 | GNUNET_SCHEDULER_cancel (endbadly_task); | 96 | GNUNET_SCHEDULER_cancel (endbadly_task); |
117 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 97 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
118 | } | 98 | } |
119 | |||
120 | GNUNET_free ((void *) s_first_record->data); | 99 | GNUNET_free ((void *) s_first_record->data); |
121 | GNUNET_free (s_first_record); | 100 | GNUNET_free (s_first_record); |
122 | GNUNET_free_non_null (s_second_record); | 101 | GNUNET_free_non_null (s_second_record); |
123 | |||
124 | if (privkey != NULL) | 102 | if (privkey != NULL) |
125 | GNUNET_CRYPTO_rsa_key_free (privkey); | 103 | GNUNET_CRYPTO_rsa_key_free (privkey); |
126 | privkey = NULL; | 104 | privkey = NULL; |
127 | |||
128 | if (nsh != NULL) | 105 | if (nsh != NULL) |
129 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 106 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
130 | nsh = NULL; | 107 | nsh = NULL; |
131 | |||
132 | if (NULL != arm) | ||
133 | stop_arm(); | ||
134 | } | 108 | } |
135 | 109 | ||
136 | void name_lookup_second_proc (void *cls, | 110 | |
137 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 111 | static void |
138 | struct GNUNET_TIME_Absolute expire, | 112 | name_lookup_second_proc (void *cls, |
139 | const char *n, | 113 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
140 | unsigned int rd_count, | 114 | struct GNUNET_TIME_Absolute expire, |
141 | const struct GNUNET_NAMESTORE_RecordData *rd, | 115 | const char *n, |
142 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 116 | unsigned int rd_count, |
117 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
118 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
143 | { | 119 | { |
144 | static int found = GNUNET_NO; | 120 | static int found = GNUNET_NO; |
145 | int failed = GNUNET_NO; | 121 | int failed = GNUNET_NO; |
@@ -219,10 +195,11 @@ void name_lookup_second_proc (void *cls, | |||
219 | } | 195 | } |
220 | 196 | ||
221 | 197 | ||
222 | void | 198 | static void |
223 | create_second_cont (void *cls, int32_t success, const char *emsg) | 199 | create_second_cont (void *cls, int32_t success, const char *emsg) |
224 | { | 200 | { |
225 | char *name = cls; | 201 | char *name = cls; |
202 | |||
226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create second record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create second record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
227 | if (success == GNUNET_OK) | 204 | if (success == GNUNET_OK) |
228 | { | 205 | { |
@@ -235,16 +212,17 @@ create_second_cont (void *cls, int32_t success, const char *emsg) | |||
235 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); | 212 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); |
236 | GNUNET_SCHEDULER_add_now(&end, NULL); | 213 | GNUNET_SCHEDULER_add_now(&end, NULL); |
237 | } | 214 | } |
238 | |||
239 | } | 215 | } |
240 | 216 | ||
241 | void name_lookup_initial_proc (void *cls, | 217 | |
242 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 218 | static void |
243 | struct GNUNET_TIME_Absolute expire, | 219 | name_lookup_initial_proc (void *cls, |
244 | const char *n, | 220 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
245 | unsigned int rd_count, | 221 | struct GNUNET_TIME_Absolute expire, |
246 | const struct GNUNET_NAMESTORE_RecordData *rd, | 222 | const char *n, |
247 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 223 | unsigned int rd_count, |
224 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
225 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
248 | { | 226 | { |
249 | char * name = cls; | 227 | char * name = cls; |
250 | static int found = GNUNET_NO; | 228 | static int found = GNUNET_NO; |
@@ -323,7 +301,8 @@ void name_lookup_initial_proc (void *cls, | |||
323 | } | 301 | } |
324 | } | 302 | } |
325 | 303 | ||
326 | void | 304 | |
305 | static void | ||
327 | create_first_cont (void *cls, int32_t success, const char *emsg) | 306 | create_first_cont (void *cls, int32_t success, const char *emsg) |
328 | { | 307 | { |
329 | char *name = cls; | 308 | char *name = cls; |
@@ -340,25 +319,8 @@ create_first_cont (void *cls, int32_t success, const char *emsg) | |||
340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); | 319 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); |
341 | GNUNET_SCHEDULER_add_now(&end, NULL); | 320 | GNUNET_SCHEDULER_add_now(&end, NULL); |
342 | } | 321 | } |
343 | |||
344 | } | 322 | } |
345 | 323 | ||
346 | void | ||
347 | put_cont (void *cls, int32_t success, const char *emsg) | ||
348 | { | ||
349 | char *name = cls; | ||
350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | ||
351 | if (success == GNUNET_OK) | ||
352 | { | ||
353 | |||
354 | } | ||
355 | else | ||
356 | { | ||
357 | res = 1; | ||
358 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); | ||
359 | GNUNET_SCHEDULER_add_now(&end, NULL); | ||
360 | } | ||
361 | } | ||
362 | 324 | ||
363 | static struct GNUNET_NAMESTORE_RecordData * | 325 | static struct GNUNET_NAMESTORE_RecordData * |
364 | create_record (int count) | 326 | create_record (int count) |
@@ -379,35 +341,16 @@ create_record (int count) | |||
379 | return rd; | 341 | return rd; |
380 | } | 342 | } |
381 | 343 | ||
382 | void | ||
383 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
384 | { | ||
385 | char *afsdir; | ||
386 | |||
387 | if (GNUNET_OK == | ||
388 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
389 | "FILENAME", &afsdir)) | ||
390 | { | ||
391 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
392 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
393 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
395 | GNUNET_free (afsdir); | ||
396 | } | ||
397 | |||
398 | } | ||
399 | 344 | ||
400 | static void | 345 | static void |
401 | run (void *cls, char *const *args, const char *cfgfile, | 346 | run (void *cls, |
402 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 347 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
403 | { | 348 | { |
404 | delete_existing_db(cfg); | ||
405 | |||
406 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
407 | size_t rd_ser_len; | 349 | size_t rd_ser_len; |
350 | char *hostkey_file; | ||
408 | 351 | ||
352 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,endbadly, NULL); | ||
409 | /* load privat key */ | 353 | /* load privat key */ |
410 | char *hostkey_file; | ||
411 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 354 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
412 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 355 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -430,10 +373,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
430 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 373 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
431 | 374 | ||
432 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); |
433 | |||
434 | start_arm (cfgfile); | ||
435 | GNUNET_assert (arm != NULL); | ||
436 | |||
437 | nsh = GNUNET_NAMESTORE_connect (cfg); | 376 | nsh = GNUNET_NAMESTORE_connect (cfg); |
438 | GNUNET_break (NULL != nsh); | 377 | GNUNET_break (NULL != nsh); |
439 | 378 | ||
@@ -444,35 +383,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
444 | GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name); | 383 | GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name); |
445 | } | 384 | } |
446 | 385 | ||
447 | static int | ||
448 | check () | ||
449 | { | ||
450 | static char *const argv[] = { "test-namestore-api", | ||
451 | "-c", | ||
452 | "test_namestore_api.conf", | ||
453 | #if VERBOSE | ||
454 | "-L", "DEBUG", | ||
455 | #endif | ||
456 | NULL | ||
457 | }; | ||
458 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
459 | GNUNET_GETOPT_OPTION_END | ||
460 | }; | ||
461 | |||
462 | res = 1; | ||
463 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
464 | "nohelp", options, &run, &res); | ||
465 | return res; | ||
466 | } | ||
467 | 386 | ||
468 | int | 387 | int |
469 | main (int argc, char *argv[]) | 388 | main (int argc, char *argv[]) |
470 | { | 389 | { |
471 | int ret; | 390 | res = 1; |
472 | 391 | if (0 != | |
473 | ret = check (); | 392 | GNUNET_TESTING_service_run ("test-namestore-api-create", |
393 | "namestore", | ||
394 | "test_namestore_api.conf", | ||
395 | &run, | ||
396 | NULL)) | ||
397 | return 1; | ||
474 | GNUNET_free (s_signature); | 398 | GNUNET_free (s_signature); |
475 | return ret; | 399 | return res; |
476 | } | 400 | } |
477 | 401 | ||
478 | /* end of test_namestore_api.c */ | 402 | /* end of test_namestore_api_create.c */ |
diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c index 93570e458..e898a3050 100644 --- a/src/namestore/test_namestore_api_create_update.c +++ b/src/namestore/test_namestore_api_create_update.c | |||
@@ -24,65 +24,48 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | 31 | ||
32 | #define RECORDS 1 | 32 | #define RECORDS 1 |
33 | |||
33 | #define TEST_RECORD_TYPE 1234 | 34 | #define TEST_RECORD_TYPE 1234 |
35 | |||
34 | #define TEST_RECORD_DATALEN 123 | 36 | #define TEST_RECORD_DATALEN 123 |
37 | |||
35 | #define TEST_RECORD_DATA 'a' | 38 | #define TEST_RECORD_DATA 'a' |
36 | 39 | ||
37 | #define TEST_CREATE_RECORD_TYPE 4321 | 40 | #define TEST_CREATE_RECORD_TYPE 4321 |
41 | |||
38 | #define TEST_CREATE_RECORD_DATALEN 255 | 42 | #define TEST_CREATE_RECORD_DATALEN 255 |
43 | |||
39 | #define TEST_CREATE_RECORD_DATA 'b' | 44 | #define TEST_CREATE_RECORD_DATA 'b' |
40 | 45 | ||
41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 46 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
42 | 47 | ||
48 | |||
43 | static struct GNUNET_NAMESTORE_Handle * nsh; | 49 | static struct GNUNET_NAMESTORE_Handle * nsh; |
44 | 50 | ||
45 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 51 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
46 | static struct GNUNET_OS_Process *arm; | ||
47 | 52 | ||
48 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 53 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
54 | |||
49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 55 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 56 | |
51 | struct GNUNET_CRYPTO_RsaSignature *s_signature_updated; | 57 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; |
58 | |||
52 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 59 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
53 | struct GNUNET_NAMESTORE_RecordData *s_first_record; | ||
54 | struct GNUNET_NAMESTORE_RecordData *s_second_record; | ||
55 | static char *s_name; | ||
56 | 60 | ||
61 | static struct GNUNET_NAMESTORE_RecordData *s_first_record; | ||
57 | 62 | ||
63 | static struct GNUNET_NAMESTORE_RecordData *s_second_record; | ||
58 | 64 | ||
59 | static int res; | 65 | static char *s_name; |
60 | 66 | ||
61 | static void | 67 | static int res; |
62 | start_arm (const char *cfgname) | ||
63 | { | ||
64 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
65 | "gnunet-service-arm", "-c", cfgname, | ||
66 | #if VERBOSE_PEERS | ||
67 | "-L", "DEBUG", | ||
68 | #else | ||
69 | "-L", "ERROR", | ||
70 | #endif | ||
71 | NULL); | ||
72 | } | ||
73 | 68 | ||
74 | static void | ||
75 | stop_arm () | ||
76 | { | ||
77 | if (NULL != arm) | ||
78 | { | ||
79 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
80 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
81 | GNUNET_OS_process_wait (arm); | ||
82 | GNUNET_OS_process_destroy (arm); | ||
83 | arm = NULL; | ||
84 | } | ||
85 | } | ||
86 | 69 | ||
87 | /** | 70 | /** |
88 | * Re-establish the connection to the service. | 71 | * Re-establish the connection to the service. |
@@ -96,14 +79,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
96 | if (nsh != NULL) | 79 | if (nsh != NULL) |
97 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 80 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
98 | nsh = NULL; | 81 | nsh = NULL; |
99 | |||
100 | if (privkey != NULL) | 82 | if (privkey != NULL) |
101 | GNUNET_CRYPTO_rsa_key_free (privkey); | 83 | GNUNET_CRYPTO_rsa_key_free (privkey); |
102 | privkey = NULL; | 84 | privkey = NULL; |
103 | |||
104 | if (NULL != arm) | ||
105 | stop_arm(); | ||
106 | |||
107 | res = 1; | 85 | res = 1; |
108 | } | 86 | } |
109 | 87 | ||
@@ -116,208 +94,19 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
116 | GNUNET_SCHEDULER_cancel (endbadly_task); | 94 | GNUNET_SCHEDULER_cancel (endbadly_task); |
117 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 95 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
118 | } | 96 | } |
119 | |||
120 | GNUNET_free ((void *) s_first_record->data); | 97 | GNUNET_free ((void *) s_first_record->data); |
121 | GNUNET_free (s_first_record); | 98 | GNUNET_free (s_first_record); |
122 | GNUNET_free_non_null (s_second_record); | 99 | GNUNET_free_non_null (s_second_record); |
123 | |||
124 | if (privkey != NULL) | 100 | if (privkey != NULL) |
125 | GNUNET_CRYPTO_rsa_key_free (privkey); | 101 | GNUNET_CRYPTO_rsa_key_free (privkey); |
126 | privkey = NULL; | 102 | privkey = NULL; |
127 | |||
128 | if (nsh != NULL) | 103 | if (nsh != NULL) |
129 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 104 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
130 | nsh = NULL; | 105 | nsh = NULL; |
131 | |||
132 | if (NULL != arm) | ||
133 | stop_arm(); | ||
134 | } | 106 | } |
135 | 107 | ||
136 | void name_lookup_second_proc (void *cls, | ||
137 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
138 | struct GNUNET_TIME_Absolute expire, | ||
139 | const char *n, | ||
140 | unsigned int rd_count, | ||
141 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
142 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
143 | { | ||
144 | static int found = GNUNET_NO; | ||
145 | int failed = GNUNET_NO; | ||
146 | int c; | ||
147 | |||
148 | if (n != NULL) | ||
149 | { | ||
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n"); | ||
151 | if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) | ||
152 | { | ||
153 | GNUNET_break (0); | ||
154 | failed = GNUNET_YES; | ||
155 | } | ||
156 | |||
157 | if (0 != strcmp(n, s_name)) | ||
158 | { | ||
159 | GNUNET_break (0); | ||
160 | failed = GNUNET_YES; | ||
161 | } | ||
162 | |||
163 | if (2 != rd_count) | ||
164 | { | ||
165 | GNUNET_break (0); | ||
166 | failed = GNUNET_YES; | ||
167 | } | ||
168 | |||
169 | for (c = 0; c < rd_count; c++) | ||
170 | { | ||
171 | if ((GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_first_record)) && | ||
172 | (GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], s_second_record))) | ||
173 | { | ||
174 | GNUNET_break (0); | ||
175 | failed = GNUNET_YES; | ||
176 | } | ||
177 | } | ||
178 | |||
179 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature)) | ||
180 | { | ||
181 | GNUNET_break (0); | ||
182 | failed = GNUNET_YES; | ||
183 | } | ||
184 | |||
185 | struct GNUNET_NAMESTORE_RecordData rd_new[2]; | ||
186 | rd_new[0] = *s_first_record; | ||
187 | rd_new[1] = *s_second_record; | ||
188 | s_signature_updated = GNUNET_NAMESTORE_create_signature(privkey, expire, s_name, rd_new, 2); | ||
189 | |||
190 | if (0 != memcmp (s_signature_updated, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature))) | ||
191 | { | ||
192 | GNUNET_break (0); | ||
193 | failed = GNUNET_YES; | ||
194 | } | ||
195 | |||
196 | found = GNUNET_YES; | ||
197 | if (failed == GNUNET_NO) | ||
198 | res = 0; | ||
199 | else | ||
200 | res = 1; | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | if (found != GNUNET_YES) | ||
205 | { | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name); | ||
207 | res = 1; | ||
208 | } | ||
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name); | ||
210 | } | ||
211 | GNUNET_SCHEDULER_add_now(&end, NULL); | ||
212 | } | ||
213 | |||
214 | |||
215 | void | ||
216 | create_second_cont (void *cls, int32_t success, const char *emsg) | ||
217 | { | ||
218 | char *name = cls; | ||
219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create second record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | ||
220 | if (success == GNUNET_OK) | ||
221 | { | ||
222 | res = 0; | ||
223 | GNUNET_NAMESTORE_lookup_record (nsh, &s_zone, name, 0, &name_lookup_second_proc, name); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | res = 1; | ||
228 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); | ||
229 | GNUNET_SCHEDULER_add_now(&end, NULL); | ||
230 | } | ||
231 | 108 | ||
232 | } | 109 | static void |
233 | |||
234 | void name_lookup_initial_proc (void *cls, | ||
235 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | ||
236 | struct GNUNET_TIME_Absolute expire, | ||
237 | const char *n, | ||
238 | unsigned int rd_count, | ||
239 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
240 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
241 | { | ||
242 | char * name = cls; | ||
243 | static int found = GNUNET_NO; | ||
244 | int failed = GNUNET_NO; | ||
245 | int c; | ||
246 | |||
247 | if (n != NULL) | ||
248 | { | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n"); | ||
250 | if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) | ||
251 | { | ||
252 | GNUNET_break (0); | ||
253 | failed = GNUNET_YES; | ||
254 | } | ||
255 | |||
256 | if (0 != strcmp(n, s_name)) | ||
257 | { | ||
258 | GNUNET_break (0); | ||
259 | failed = GNUNET_YES; | ||
260 | } | ||
261 | |||
262 | if (RECORDS != rd_count) | ||
263 | { | ||
264 | GNUNET_break (0); | ||
265 | failed = GNUNET_YES; | ||
266 | } | ||
267 | |||
268 | for (c = 0; c < RECORDS; c++) | ||
269 | { | ||
270 | if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp(&rd[c], &s_first_record[c])) | ||
271 | { | ||
272 | GNUNET_break (0); | ||
273 | failed = GNUNET_YES; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature(&pubkey, expire, n, rd_count, rd, signature)) | ||
278 | { | ||
279 | GNUNET_break (0); | ||
280 | failed = GNUNET_YES; | ||
281 | } | ||
282 | |||
283 | if (0 != memcmp (s_signature, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature))) | ||
284 | { | ||
285 | GNUNET_break (0); | ||
286 | failed = GNUNET_YES; | ||
287 | } | ||
288 | |||
289 | found = GNUNET_YES; | ||
290 | if (failed == GNUNET_NO) | ||
291 | res = 0; | ||
292 | else | ||
293 | res = 1; | ||
294 | |||
295 | /* create a second record */ | ||
296 | s_second_record = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_RecordData) + TEST_CREATE_RECORD_DATALEN); | ||
297 | s_second_record->expiration = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
298 | s_second_record->record_type = TEST_CREATE_RECORD_TYPE; | ||
299 | s_second_record->flags = GNUNET_NAMESTORE_RF_AUTHORITY; | ||
300 | s_second_record->data = &s_second_record[1]; | ||
301 | s_second_record->data_size = TEST_CREATE_RECORD_DATALEN; | ||
302 | memset ((char *) s_second_record->data, TEST_CREATE_RECORD_DATA, TEST_CREATE_RECORD_DATALEN); | ||
303 | |||
304 | GNUNET_NAMESTORE_record_create (nsh, privkey, name, s_second_record, &create_second_cont, name); | ||
305 | |||
306 | } | ||
307 | else | ||
308 | { | ||
309 | if (found != GNUNET_YES) | ||
310 | { | ||
311 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", s_name); | ||
312 | res = 1; | ||
313 | } | ||
314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", s_name); | ||
315 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
316 | } | ||
317 | } | ||
318 | |||
319 | |||
320 | void | ||
321 | create_updated_cont (void *cls, int32_t success, const char *emsg) | 110 | create_updated_cont (void *cls, int32_t success, const char *emsg) |
322 | { | 111 | { |
323 | char *name = cls; | 112 | char *name = cls; |
@@ -340,7 +129,8 @@ create_updated_cont (void *cls, int32_t success, const char *emsg) | |||
340 | GNUNET_SCHEDULER_add_now(&end, NULL); | 129 | GNUNET_SCHEDULER_add_now(&end, NULL); |
341 | } | 130 | } |
342 | 131 | ||
343 | void | 132 | |
133 | static void | ||
344 | create_identical_cont (void *cls, int32_t success, const char *emsg) | 134 | create_identical_cont (void *cls, int32_t success, const char *emsg) |
345 | { | 135 | { |
346 | char *name = cls; | 136 | char *name = cls; |
@@ -360,7 +150,8 @@ create_identical_cont (void *cls, int32_t success, const char *emsg) | |||
360 | 150 | ||
361 | } | 151 | } |
362 | 152 | ||
363 | void | 153 | |
154 | static void | ||
364 | create_first_cont (void *cls, int32_t success, const char *emsg) | 155 | create_first_cont (void *cls, int32_t success, const char *emsg) |
365 | { | 156 | { |
366 | char *name = cls; | 157 | char *name = cls; |
@@ -380,22 +171,6 @@ create_first_cont (void *cls, int32_t success, const char *emsg) | |||
380 | 171 | ||
381 | } | 172 | } |
382 | 173 | ||
383 | void | ||
384 | put_cont (void *cls, int32_t success, const char *emsg) | ||
385 | { | ||
386 | char *name = cls; | ||
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name store added record for `%s': %s `%s'\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL", emsg); | ||
388 | if (success == GNUNET_OK) | ||
389 | { | ||
390 | |||
391 | } | ||
392 | else | ||
393 | { | ||
394 | res = 1; | ||
395 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name); | ||
396 | GNUNET_SCHEDULER_add_now(&end, NULL); | ||
397 | } | ||
398 | } | ||
399 | 174 | ||
400 | static struct GNUNET_NAMESTORE_RecordData * | 175 | static struct GNUNET_NAMESTORE_RecordData * |
401 | create_record (int count) | 176 | create_record (int count) |
@@ -416,41 +191,22 @@ create_record (int count) | |||
416 | return rd; | 191 | return rd; |
417 | } | 192 | } |
418 | 193 | ||
419 | void | ||
420 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
421 | { | ||
422 | char *afsdir; | ||
423 | |||
424 | if (GNUNET_OK == | ||
425 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
426 | "FILENAME", &afsdir)) | ||
427 | { | ||
428 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
429 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
430 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
432 | GNUNET_free (afsdir); | ||
433 | } | ||
434 | |||
435 | } | ||
436 | 194 | ||
437 | static void | 195 | static void |
438 | run (void *cls, char *const *args, const char *cfgfile, | 196 | run (void *cls, |
439 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 197 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
440 | { | 198 | { |
441 | delete_existing_db(cfg); | 199 | size_t rd_ser_len; |
200 | char *hostkey_file; | ||
442 | 201 | ||
443 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 202 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); |
444 | size_t rd_ser_len; | ||
445 | 203 | ||
446 | /* load privat key */ | 204 | /* load privat key */ |
447 | char *hostkey_file; | ||
448 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 205 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
449 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 206 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
450 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 207 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
451 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); | 208 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file(hostkey_file); |
452 | GNUNET_free (hostkey_file); | 209 | GNUNET_free (hostkey_file); |
453 | |||
454 | GNUNET_assert (privkey != NULL); | 210 | GNUNET_assert (privkey != NULL); |
455 | /* get public key */ | 211 | /* get public key */ |
456 | GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); | 212 | GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey); |
@@ -469,10 +225,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
469 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 225 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
470 | 226 | ||
471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); | 227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); |
472 | |||
473 | start_arm (cfgfile); | ||
474 | GNUNET_assert (arm != NULL); | ||
475 | |||
476 | nsh = GNUNET_NAMESTORE_connect (cfg); | 228 | nsh = GNUNET_NAMESTORE_connect (cfg); |
477 | GNUNET_break (NULL != nsh); | 229 | GNUNET_break (NULL != nsh); |
478 | 230 | ||
@@ -483,35 +235,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
483 | GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name); | 235 | GNUNET_NAMESTORE_record_create (nsh, privkey, s_name, s_first_record, &create_first_cont, s_name); |
484 | } | 236 | } |
485 | 237 | ||
486 | static int | ||
487 | check () | ||
488 | { | ||
489 | static char *const argv[] = { "test-namestore-api", | ||
490 | "-c", | ||
491 | "test_namestore_api.conf", | ||
492 | #if VERBOSE | ||
493 | "-L", "DEBUG", | ||
494 | #endif | ||
495 | NULL | ||
496 | }; | ||
497 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
498 | GNUNET_GETOPT_OPTION_END | ||
499 | }; | ||
500 | |||
501 | res = 1; | ||
502 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
503 | "nohelp", options, &run, &res); | ||
504 | return res; | ||
505 | } | ||
506 | 238 | ||
507 | int | 239 | int |
508 | main (int argc, char *argv[]) | 240 | main (int argc, char *argv[]) |
509 | { | 241 | { |
510 | int ret; | 242 | res = 1; |
511 | 243 | if (0 != | |
512 | ret = check (); | 244 | GNUNET_TESTING_service_run ("test-namestore-api-create-update", |
513 | GNUNET_free (s_signature); | 245 | "namestore", |
514 | return ret; | 246 | "test_namestore_api.conf", |
247 | &run, | ||
248 | NULL)) | ||
249 | return 1; | ||
250 | GNUNET_free_non_null (s_signature); | ||
251 | return res; | ||
515 | } | 252 | } |
516 | 253 | ||
517 | /* end of test_namestore_api.c */ | 254 | /* end of test_namestore_api_create_update.c */ |
diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c index 818e7108d..1cf9ec864 100644 --- a/src/namestore/test_namestore_api_lookup.c +++ b/src/namestore/test_namestore_api_lookup.c | |||
@@ -24,59 +24,41 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | 31 | #define VERBOSE GNUNET_NO |
31 | 32 | ||
32 | #define RECORDS 5 | 33 | #define RECORDS 5 |
34 | |||
33 | #define TEST_RECORD_TYPE 1234 | 35 | #define TEST_RECORD_TYPE 1234 |
36 | |||
34 | #define TEST_RECORD_DATALEN 123 | 37 | #define TEST_RECORD_DATALEN 123 |
38 | |||
35 | #define TEST_RECORD_DATA 'a' | 39 | #define TEST_RECORD_DATA 'a' |
36 | 40 | ||
37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
38 | 42 | ||
43 | |||
39 | static struct GNUNET_NAMESTORE_Handle * nsh; | 44 | static struct GNUNET_NAMESTORE_Handle * nsh; |
40 | 45 | ||
41 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 46 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
42 | static struct GNUNET_OS_Process *arm; | ||
43 | 47 | ||
44 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 48 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
49 | |||
45 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 50 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
46 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 51 | |
52 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; | ||
53 | |||
47 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 54 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
48 | struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
49 | static char *s_name; | ||
50 | 55 | ||
56 | static struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
51 | 57 | ||
58 | static char *s_name; | ||
52 | 59 | ||
53 | static int res; | 60 | static int res; |
54 | 61 | ||
55 | static void | ||
56 | start_arm (const char *cfgname) | ||
57 | { | ||
58 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
59 | "gnunet-service-arm", "-c", cfgname, | ||
60 | #if VERBOSE_PEERS | ||
61 | "-L", "DEBUG", | ||
62 | #else | ||
63 | "-L", "ERROR", | ||
64 | #endif | ||
65 | NULL); | ||
66 | } | ||
67 | |||
68 | static void | ||
69 | stop_arm () | ||
70 | { | ||
71 | if (NULL != arm) | ||
72 | { | ||
73 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
74 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
75 | GNUNET_OS_process_wait (arm); | ||
76 | GNUNET_OS_process_destroy (arm); | ||
77 | arm = NULL; | ||
78 | } | ||
79 | } | ||
80 | 62 | ||
81 | /** | 63 | /** |
82 | * Re-establish the connection to the service. | 64 | * Re-establish the connection to the service. |
@@ -90,14 +72,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
90 | if (nsh != NULL) | 72 | if (nsh != NULL) |
91 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 73 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
92 | nsh = NULL; | 74 | nsh = NULL; |
93 | |||
94 | if (privkey != NULL) | 75 | if (privkey != NULL) |
95 | GNUNET_CRYPTO_rsa_key_free (privkey); | 76 | GNUNET_CRYPTO_rsa_key_free (privkey); |
96 | privkey = NULL; | 77 | privkey = NULL; |
97 | |||
98 | if (NULL != arm) | ||
99 | stop_arm(); | ||
100 | |||
101 | res = 1; | 78 | res = 1; |
102 | } | 79 | } |
103 | 80 | ||
@@ -105,36 +82,33 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
105 | static void | 82 | static void |
106 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 83 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
107 | { | 84 | { |
85 | int c; | ||
86 | |||
108 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 87 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
109 | { | 88 | { |
110 | GNUNET_SCHEDULER_cancel (endbadly_task); | 89 | GNUNET_SCHEDULER_cancel (endbadly_task); |
111 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 90 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
112 | } | 91 | } |
113 | |||
114 | int c; | ||
115 | for (c = 0; c < RECORDS; c++) | 92 | for (c = 0; c < RECORDS; c++) |
116 | GNUNET_free_non_null((void *) s_rd[c].data); | 93 | GNUNET_free_non_null((void *) s_rd[c].data); |
117 | GNUNET_free (s_rd); | 94 | GNUNET_free (s_rd); |
118 | |||
119 | if (privkey != NULL) | 95 | if (privkey != NULL) |
120 | GNUNET_CRYPTO_rsa_key_free (privkey); | 96 | GNUNET_CRYPTO_rsa_key_free (privkey); |
121 | privkey = NULL; | 97 | privkey = NULL; |
122 | |||
123 | if (nsh != NULL) | 98 | if (nsh != NULL) |
124 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 99 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
125 | nsh = NULL; | 100 | nsh = NULL; |
126 | |||
127 | if (NULL != arm) | ||
128 | stop_arm(); | ||
129 | } | 101 | } |
130 | 102 | ||
131 | void name_lookup_proc (void *cls, | 103 | |
132 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 104 | static void |
133 | struct GNUNET_TIME_Absolute expire, | 105 | name_lookup_proc (void *cls, |
134 | const char *n, | 106 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
135 | unsigned int rd_count, | 107 | struct GNUNET_TIME_Absolute expire, |
136 | const struct GNUNET_NAMESTORE_RecordData *rd, | 108 | const char *n, |
137 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 109 | unsigned int rd_count, |
110 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
111 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
138 | { | 112 | { |
139 | static int found = GNUNET_NO; | 113 | static int found = GNUNET_NO; |
140 | int c; | 114 | int c; |
@@ -146,22 +120,18 @@ void name_lookup_proc (void *cls, | |||
146 | { | 120 | { |
147 | GNUNET_break (0); | 121 | GNUNET_break (0); |
148 | } | 122 | } |
149 | |||
150 | if (0 != memcmp (signature, s_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature))) | 123 | if (0 != memcmp (signature, s_signature, sizeof (struct GNUNET_CRYPTO_RsaSignature))) |
151 | { | 124 | { |
152 | GNUNET_break (0); | 125 | GNUNET_break (0); |
153 | } | 126 | } |
154 | |||
155 | if (0 != strcmp(n, s_name)) | 127 | if (0 != strcmp(n, s_name)) |
156 | { | 128 | { |
157 | GNUNET_break (0); | 129 | GNUNET_break (0); |
158 | } | 130 | } |
159 | |||
160 | if (RECORDS != rd_count) | 131 | if (RECORDS != rd_count) |
161 | { | 132 | { |
162 | GNUNET_break (0); | 133 | GNUNET_break (0); |
163 | } | 134 | } |
164 | |||
165 | for (c = 0; c < RECORDS; c++) | 135 | for (c = 0; c < RECORDS; c++) |
166 | { | 136 | { |
167 | if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp (&rd[c], &s_rd[c])) | 137 | if (GNUNET_NO == GNUNET_NAMESTORE_records_cmp (&rd[c], &s_rd[c])) |
@@ -184,7 +154,8 @@ void name_lookup_proc (void *cls, | |||
184 | GNUNET_SCHEDULER_add_now(&end, NULL); | 154 | GNUNET_SCHEDULER_add_now(&end, NULL); |
185 | } | 155 | } |
186 | 156 | ||
187 | void | 157 | |
158 | static void | ||
188 | put_cont (void *cls, int32_t success, const char *emsg) | 159 | put_cont (void *cls, int32_t success, const char *emsg) |
189 | { | 160 | { |
190 | char * name = cls; | 161 | char * name = cls; |
@@ -203,6 +174,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
203 | } | 174 | } |
204 | } | 175 | } |
205 | 176 | ||
177 | |||
206 | static struct GNUNET_NAMESTORE_RecordData * | 178 | static struct GNUNET_NAMESTORE_RecordData * |
207 | create_record (int count) | 179 | create_record (int count) |
208 | { | 180 | { |
@@ -212,43 +184,25 @@ create_record (int count) | |||
212 | 184 | ||
213 | for (c = 0; c < RECORDS; c++) | 185 | for (c = 0; c < RECORDS; c++) |
214 | { | 186 | { |
215 | rd[c].expiration = GNUNET_TIME_absolute_get(); | 187 | rd[c].expiration = GNUNET_TIME_absolute_get(); |
216 | rd[c].record_type = TEST_RECORD_TYPE; | 188 | rd[c].record_type = TEST_RECORD_TYPE; |
217 | rd[c].data_size = TEST_RECORD_DATALEN; | 189 | rd[c].data_size = TEST_RECORD_DATALEN; |
218 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); | 190 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); |
219 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); | 191 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); |
220 | } | 192 | } |
221 | 193 | ||
222 | return rd; | 194 | return rd; |
223 | } | 195 | } |
224 | 196 | ||
225 | void | ||
226 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
227 | { | ||
228 | char *afsdir; | ||
229 | |||
230 | if (GNUNET_OK == | ||
231 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
232 | "FILENAME", &afsdir)) | ||
233 | { | ||
234 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
235 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
236 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
237 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
238 | GNUNET_free (afsdir); | ||
239 | } | ||
240 | |||
241 | } | ||
242 | 197 | ||
243 | static void | 198 | static void |
244 | run (void *cls, char *const *args, const char *cfgfile, | 199 | run (void *cls, |
245 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 200 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
246 | { | 201 | { |
247 | delete_existing_db(cfg); | ||
248 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
249 | |||
250 | size_t rd_ser_len; | 202 | size_t rd_ser_len; |
251 | 203 | ||
204 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
205 | |||
252 | /* load privat key from file not included in zonekey dir */ | 206 | /* load privat key from file not included in zonekey dir */ |
253 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file("test_hostkey"); | 207 | privkey = GNUNET_CRYPTO_rsa_key_create_from_file("test_hostkey"); |
254 | GNUNET_assert (privkey != NULL); | 208 | GNUNET_assert (privkey != NULL); |
@@ -268,9 +222,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
268 | 222 | ||
269 | /* create random zone hash */ | 223 | /* create random zone hash */ |
270 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 224 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
271 | start_arm (cfgfile); | ||
272 | GNUNET_assert (arm != NULL); | ||
273 | |||
274 | nsh = GNUNET_NAMESTORE_connect (cfg); | 225 | nsh = GNUNET_NAMESTORE_connect (cfg); |
275 | GNUNET_break (NULL != nsh); | 226 | GNUNET_break (NULL != nsh); |
276 | 227 | ||
@@ -283,35 +234,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
283 | } | 234 | } |
284 | 235 | ||
285 | 236 | ||
286 | static int | 237 | int |
287 | check () | 238 | main (int argc, char *argv[]) |
288 | { | 239 | { |
289 | static char *const argv[] = { "test-namestore-api", | ||
290 | "-c", | ||
291 | "test_namestore_api.conf", | ||
292 | #if VERBOSE | ||
293 | "-L", "DEBUG", | ||
294 | #endif | ||
295 | NULL | ||
296 | }; | ||
297 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
298 | GNUNET_GETOPT_OPTION_END | ||
299 | }; | ||
300 | |||
301 | res = 1; | 240 | res = 1; |
302 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | 241 | if (0 != |
303 | "nohelp", options, &run, &res); | 242 | GNUNET_TESTING_service_run ("test-namestore-api-lookup", |
243 | "namestore", | ||
244 | "test_namestore_api.conf", | ||
245 | &run, | ||
246 | NULL)) | ||
247 | return 1; | ||
248 | GNUNET_free_non_null (s_signature); | ||
304 | return res; | 249 | return res; |
305 | } | 250 | } |
306 | 251 | ||
307 | int | ||
308 | main (int argc, char *argv[]) | ||
309 | { | ||
310 | int ret; | ||
311 | |||
312 | ret = check (); | ||
313 | GNUNET_free (s_signature); | ||
314 | return ret; | ||
315 | } | ||
316 | 252 | ||
317 | /* end of test_namestore_api.c */ | 253 | /* end of test_namestore_api.c */ |
diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c index 981e252de..e2ac2588d 100644 --- a/src/namestore/test_namestore_api_lookup_specific_type.c +++ b/src/namestore/test_namestore_api_lookup_specific_type.c | |||
@@ -24,62 +24,44 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | 31 | ||
32 | #define RECORDS 5 | 32 | #define RECORDS 5 |
33 | |||
33 | #define TEST_RECORD_TYPE 1234 | 34 | #define TEST_RECORD_TYPE 1234 |
35 | |||
34 | #define TEST_RECORD_DATALEN 123 | 36 | #define TEST_RECORD_DATALEN 123 |
37 | |||
35 | #define TEST_RECORD_DATA 'a' | 38 | #define TEST_RECORD_DATA 'a' |
36 | 39 | ||
37 | #define TEST_RECORD_LOOKUP_TYPE_NOT_EXISTING 11111 | 40 | #define TEST_RECORD_LOOKUP_TYPE_NOT_EXISTING 11111 |
41 | |||
38 | #define TEST_RECORD_LOOKUP_TYPE_EXISTING 22222 | 42 | #define TEST_RECORD_LOOKUP_TYPE_EXISTING 22222 |
39 | 43 | ||
40 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 44 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
41 | 45 | ||
46 | |||
42 | static struct GNUNET_NAMESTORE_Handle * nsh; | 47 | static struct GNUNET_NAMESTORE_Handle * nsh; |
43 | 48 | ||
44 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 49 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
45 | static struct GNUNET_OS_Process *arm; | ||
46 | 50 | ||
47 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 51 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
52 | |||
48 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 53 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
49 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 54 | |
55 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; | ||
56 | |||
50 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 57 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
51 | struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
52 | static char *s_name; | ||
53 | 58 | ||
59 | static struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
54 | 60 | ||
61 | static char *s_name; | ||
55 | 62 | ||
56 | static int res; | 63 | static int res; |
57 | 64 | ||
58 | static void | ||
59 | start_arm (const char *cfgname) | ||
60 | { | ||
61 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
62 | "gnunet-service-arm", "-c", cfgname, | ||
63 | #if VERBOSE_PEERS | ||
64 | "-L", "DEBUG", | ||
65 | #else | ||
66 | "-L", "ERROR", | ||
67 | #endif | ||
68 | NULL); | ||
69 | } | ||
70 | |||
71 | static void | ||
72 | stop_arm () | ||
73 | { | ||
74 | if (NULL != arm) | ||
75 | { | ||
76 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
77 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
78 | GNUNET_OS_process_wait (arm); | ||
79 | GNUNET_OS_process_destroy (arm); | ||
80 | arm = NULL; | ||
81 | } | ||
82 | } | ||
83 | 65 | ||
84 | /** | 66 | /** |
85 | * Re-establish the connection to the service. | 67 | * Re-establish the connection to the service. |
@@ -93,14 +75,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
93 | if (nsh != NULL) | 75 | if (nsh != NULL) |
94 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 76 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
95 | nsh = NULL; | 77 | nsh = NULL; |
96 | |||
97 | if (privkey != NULL) | 78 | if (privkey != NULL) |
98 | GNUNET_CRYPTO_rsa_key_free (privkey); | 79 | GNUNET_CRYPTO_rsa_key_free (privkey); |
99 | privkey = NULL; | 80 | privkey = NULL; |
100 | |||
101 | if (NULL != arm) | ||
102 | stop_arm(); | ||
103 | |||
104 | res = 1; | 81 | res = 1; |
105 | } | 82 | } |
106 | 83 | ||
@@ -108,13 +85,13 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
108 | static void | 85 | static void |
109 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 86 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
110 | { | 87 | { |
88 | int c; | ||
89 | |||
111 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 90 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
112 | { | 91 | { |
113 | GNUNET_SCHEDULER_cancel (endbadly_task); | 92 | GNUNET_SCHEDULER_cancel (endbadly_task); |
114 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 93 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
115 | } | 94 | } |
116 | |||
117 | int c; | ||
118 | for (c = 0; c < RECORDS; c++) | 95 | for (c = 0; c < RECORDS; c++) |
119 | { | 96 | { |
120 | GNUNET_free_non_null((void *) s_rd[c].data); | 97 | GNUNET_free_non_null((void *) s_rd[c].data); |
@@ -124,23 +101,20 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
124 | if (privkey != NULL) | 101 | if (privkey != NULL) |
125 | GNUNET_CRYPTO_rsa_key_free (privkey); | 102 | GNUNET_CRYPTO_rsa_key_free (privkey); |
126 | privkey = NULL; | 103 | privkey = NULL; |
127 | |||
128 | if (nsh != NULL) | 104 | if (nsh != NULL) |
129 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 105 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
130 | nsh = NULL; | 106 | nsh = NULL; |
131 | |||
132 | if (NULL != arm) | ||
133 | stop_arm(); | ||
134 | } | 107 | } |
135 | 108 | ||
136 | 109 | ||
137 | void name_lookup_existing_record_type (void *cls, | 110 | static void |
138 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 111 | name_lookup_existing_record_type (void *cls, |
139 | struct GNUNET_TIME_Absolute expire, | 112 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
140 | const char *n, | 113 | struct GNUNET_TIME_Absolute expire, |
141 | unsigned int rd_count, | 114 | const char *n, |
142 | const struct GNUNET_NAMESTORE_RecordData *rd, | 115 | unsigned int rd_count, |
143 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 116 | const struct GNUNET_NAMESTORE_RecordData *rd, |
117 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
144 | { | 118 | { |
145 | int failed = GNUNET_NO; | 119 | int failed = GNUNET_NO; |
146 | 120 | ||
@@ -171,7 +145,6 @@ void name_lookup_existing_record_type (void *cls, | |||
171 | GNUNET_break(0); | 145 | GNUNET_break(0); |
172 | failed = GNUNET_YES; | 146 | failed = GNUNET_YES; |
173 | } | 147 | } |
174 | |||
175 | if (failed == GNUNET_YES) | 148 | if (failed == GNUNET_YES) |
176 | { | 149 | { |
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore returned invalid response\n"); | 150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore returned invalid response\n"); |
@@ -181,18 +154,18 @@ void name_lookup_existing_record_type (void *cls, | |||
181 | { | 154 | { |
182 | res = 0; | 155 | res = 0; |
183 | } | 156 | } |
184 | |||
185 | GNUNET_SCHEDULER_add_now(&end, NULL); | 157 | GNUNET_SCHEDULER_add_now(&end, NULL); |
186 | } | 158 | } |
187 | 159 | ||
188 | 160 | ||
189 | void name_lookup_non_existing_record_type (void *cls, | 161 | static void |
190 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 162 | name_lookup_non_existing_record_type (void *cls, |
191 | struct GNUNET_TIME_Absolute expire, | 163 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
192 | const char *n, | 164 | struct GNUNET_TIME_Absolute expire, |
193 | unsigned int rd_count, | 165 | const char *n, |
194 | const struct GNUNET_NAMESTORE_RecordData *rd, | 166 | unsigned int rd_count, |
195 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 167 | const struct GNUNET_NAMESTORE_RecordData *rd, |
168 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
196 | { | 169 | { |
197 | int failed = GNUNET_NO; | 170 | int failed = GNUNET_NO; |
198 | /* We expect zone key != NULL, name != NULL, rd_count 0, rd NULL, signature NULL */ | 171 | /* We expect zone key != NULL, name != NULL, rd_count 0, rd NULL, signature NULL */ |
@@ -250,7 +223,8 @@ void name_lookup_non_existing_record_type (void *cls, | |||
250 | } | 223 | } |
251 | } | 224 | } |
252 | 225 | ||
253 | void | 226 | |
227 | static void | ||
254 | put_cont (void *cls, int32_t success, const char *emsg) | 228 | put_cont (void *cls, int32_t success, const char *emsg) |
255 | { | 229 | { |
256 | char * name = cls; | 230 | char * name = cls; |
@@ -270,13 +244,14 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
270 | } | 244 | } |
271 | } | 245 | } |
272 | 246 | ||
247 | |||
273 | static struct GNUNET_NAMESTORE_RecordData * | 248 | static struct GNUNET_NAMESTORE_RecordData * |
274 | create_record (int count) | 249 | create_record (int count) |
275 | { | 250 | { |
276 | int c; | 251 | int c; |
277 | struct GNUNET_NAMESTORE_RecordData * rd; | 252 | struct GNUNET_NAMESTORE_RecordData * rd; |
278 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
279 | 253 | ||
254 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
280 | for (c = 0; c < RECORDS-1; c++) | 255 | for (c = 0; c < RECORDS-1; c++) |
281 | { | 256 | { |
282 | rd[c].expiration = GNUNET_TIME_UNIT_ZERO_ABS; | 257 | rd[c].expiration = GNUNET_TIME_UNIT_ZERO_ABS; |
@@ -285,46 +260,25 @@ create_record (int count) | |||
285 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); | 260 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); |
286 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); | 261 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); |
287 | } | 262 | } |
288 | |||
289 | rd[c].expiration = GNUNET_TIME_absolute_get(); | 263 | rd[c].expiration = GNUNET_TIME_absolute_get(); |
290 | rd[c].record_type = TEST_RECORD_LOOKUP_TYPE_EXISTING; | 264 | rd[c].record_type = TEST_RECORD_LOOKUP_TYPE_EXISTING; |
291 | rd[c].data_size = TEST_RECORD_DATALEN; | 265 | rd[c].data_size = TEST_RECORD_DATALEN; |
292 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); | 266 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); |
293 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); | 267 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); |
294 | 268 | ||
295 | |||
296 | return rd; | 269 | return rd; |
297 | } | 270 | } |
298 | 271 | ||
299 | void | ||
300 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
301 | { | ||
302 | char *afsdir; | ||
303 | |||
304 | if (GNUNET_OK == | ||
305 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
306 | "FILENAME", &afsdir)) | ||
307 | { | ||
308 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
309 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
310 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
311 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
312 | GNUNET_free (afsdir); | ||
313 | } | ||
314 | |||
315 | } | ||
316 | 272 | ||
317 | static void | 273 | static void |
318 | run (void *cls, char *const *args, const char *cfgfile, | 274 | run (void *cls, |
319 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 275 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
320 | { | 276 | { |
321 | delete_existing_db(cfg); | ||
322 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
323 | |||
324 | size_t rd_ser_len; | 277 | size_t rd_ser_len; |
278 | char *hostkey_file; | ||
325 | 279 | ||
280 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
326 | /* load privat key */ | 281 | /* load privat key */ |
327 | char *hostkey_file; | ||
328 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 282 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
329 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 283 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -339,61 +293,39 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
339 | s_rd = create_record (RECORDS); | 293 | s_rd = create_record (RECORDS); |
340 | 294 | ||
341 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd); | 295 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(RECORDS, s_rd); |
342 | char rd_ser[rd_ser_len]; | 296 | { |
343 | GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser); | 297 | char rd_ser[rd_ser_len]; |
344 | 298 | GNUNET_NAMESTORE_records_serialize(RECORDS, s_rd, rd_ser_len, rd_ser); | |
345 | /* sign */ | 299 | |
346 | s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[RECORDS -1].expiration, s_name, s_rd, RECORDS); | 300 | /* sign */ |
347 | 301 | s_signature = GNUNET_NAMESTORE_create_signature(privkey, s_rd[RECORDS -1].expiration, s_name, s_rd, RECORDS); | |
348 | /* create random zone hash */ | 302 | |
349 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 303 | /* create random zone hash */ |
350 | 304 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | |
351 | start_arm (cfgfile); | 305 | nsh = GNUNET_NAMESTORE_connect (cfg); |
352 | GNUNET_assert (arm != NULL); | 306 | GNUNET_break (NULL != nsh); |
353 | 307 | GNUNET_break (s_rd != NULL); | |
354 | nsh = GNUNET_NAMESTORE_connect (cfg); | 308 | GNUNET_break (s_name != NULL); |
355 | GNUNET_break (NULL != nsh); | 309 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, |
356 | 310 | GNUNET_TIME_UNIT_FOREVER_ABS, | |
357 | GNUNET_break (s_rd != NULL); | 311 | RECORDS, s_rd, s_signature, put_cont, s_name); |
358 | GNUNET_break (s_name != NULL); | 312 | } |
359 | |||
360 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, | ||
361 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
362 | RECORDS, s_rd, s_signature, put_cont, s_name); | ||
363 | |||
364 | |||
365 | |||
366 | } | 313 | } |
367 | 314 | ||
368 | static int | ||
369 | check () | ||
370 | { | ||
371 | static char *const argv[] = { "test-namestore-api", | ||
372 | "-c", | ||
373 | "test_namestore_api.conf", | ||
374 | #if VERBOSE | ||
375 | "-L", "DEBUG", | ||
376 | #endif | ||
377 | NULL | ||
378 | }; | ||
379 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
380 | GNUNET_GETOPT_OPTION_END | ||
381 | }; | ||
382 | |||
383 | res = 1; | ||
384 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
385 | "nohelp", options, &run, &res); | ||
386 | return res; | ||
387 | } | ||
388 | 315 | ||
389 | int | 316 | int |
390 | main (int argc, char *argv[]) | 317 | main (int argc, char *argv[]) |
391 | { | 318 | { |
392 | int ret; | 319 | res = 1; |
393 | 320 | if (0 != | |
394 | ret = check (); | 321 | GNUNET_TESTING_service_run ("test-namestore-api-lookup-specific-type", |
395 | GNUNET_free (s_signature); | 322 | "namestore", |
396 | return ret; | 323 | "test_namestore_api.conf", |
324 | &run, | ||
325 | NULL)) | ||
326 | return 1; | ||
327 | GNUNET_free_non_null (s_signature); | ||
328 | return res; | ||
397 | } | 329 | } |
398 | 330 | ||
399 | /* end of test_namestore_api.c */ | 331 | /* end of test_namestore_api_lookup_specific_type.c */ |
diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c index 438c49243..5ad5a87cd 100644 --- a/src/namestore/test_namestore_api_put.c +++ b/src/namestore/test_namestore_api_put.c | |||
@@ -132,24 +132,6 @@ create_record (int count) | |||
132 | 132 | ||
133 | 133 | ||
134 | static void | 134 | static void |
135 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
136 | { | ||
137 | char *afsdir; | ||
138 | |||
139 | if (GNUNET_OK == | ||
140 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
141 | "FILENAME", &afsdir)) | ||
142 | { | ||
143 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
144 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
145 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
147 | GNUNET_free (afsdir); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | |||
152 | static void | ||
153 | run (void *cls, | 135 | run (void *cls, |
154 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 136 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
155 | { | 137 | { |
@@ -158,7 +140,6 @@ run (void *cls, | |||
158 | int c; | 140 | int c; |
159 | char *hostkey_file; | 141 | char *hostkey_file; |
160 | 142 | ||
161 | delete_existing_db(cfg); | ||
162 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 143 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); |
163 | /* load privat key */ | 144 | /* load privat key */ |
164 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 145 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index 57bb4a822..1d57e70f9 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c | |||
@@ -24,63 +24,45 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define RECORDS 5 | 31 | #define RECORDS 5 |
32 | |||
33 | #define TEST_RECORD_TYPE 1234 | 33 | #define TEST_RECORD_TYPE 1234 |
34 | |||
34 | #define TEST_RECORD_DATALEN 123 | 35 | #define TEST_RECORD_DATALEN 123 |
36 | |||
35 | #define TEST_RECORD_DATA 'a' | 37 | #define TEST_RECORD_DATA 'a' |
36 | 38 | ||
37 | #define TEST_REMOVE_RECORD_TYPE 4321 | 39 | #define TEST_REMOVE_RECORD_TYPE 4321 |
40 | |||
38 | #define TEST_REMOVE_RECORD_DATALEN 255 | 41 | #define TEST_REMOVE_RECORD_DATALEN 255 |
42 | |||
39 | #define TEST_REMOVE_RECORD_DATA 'b' | 43 | #define TEST_REMOVE_RECORD_DATA 'b' |
40 | 44 | ||
41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 45 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
42 | 46 | ||
47 | |||
43 | static struct GNUNET_NAMESTORE_Handle * nsh; | 48 | static struct GNUNET_NAMESTORE_Handle * nsh; |
44 | 49 | ||
45 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 50 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
46 | static struct GNUNET_OS_Process *arm; | ||
47 | 51 | ||
48 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 52 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
53 | |||
49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 54 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 55 | |
56 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; | ||
57 | |||
51 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 58 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
52 | struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
53 | static char *s_name; | ||
54 | 59 | ||
60 | static struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
55 | 61 | ||
62 | static char *s_name; | ||
56 | 63 | ||
57 | static int res; | 64 | static int res; |
58 | 65 | ||
59 | static void | ||
60 | start_arm (const char *cfgname) | ||
61 | { | ||
62 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
63 | "gnunet-service-arm", "-c", cfgname, | ||
64 | #if VERBOSE_PEERS | ||
65 | "-L", "DEBUG", | ||
66 | #else | ||
67 | "-L", "ERROR", | ||
68 | #endif | ||
69 | NULL); | ||
70 | } | ||
71 | |||
72 | static void | ||
73 | stop_arm () | ||
74 | { | ||
75 | if (NULL != arm) | ||
76 | { | ||
77 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
79 | GNUNET_OS_process_wait (arm); | ||
80 | GNUNET_OS_process_destroy (arm); | ||
81 | arm = NULL; | ||
82 | } | ||
83 | } | ||
84 | 66 | ||
85 | /** | 67 | /** |
86 | * Re-establish the connection to the service. | 68 | * Re-establish the connection to the service. |
@@ -94,14 +76,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
94 | if (nsh != NULL) | 76 | if (nsh != NULL) |
95 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 77 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
96 | nsh = NULL; | 78 | nsh = NULL; |
97 | |||
98 | if (privkey != NULL) | 79 | if (privkey != NULL) |
99 | GNUNET_CRYPTO_rsa_key_free (privkey); | 80 | GNUNET_CRYPTO_rsa_key_free (privkey); |
100 | privkey = NULL; | 81 | privkey = NULL; |
101 | |||
102 | if (NULL != arm) | ||
103 | stop_arm(); | ||
104 | |||
105 | res = 1; | 82 | res = 1; |
106 | } | 83 | } |
107 | 84 | ||
@@ -109,36 +86,33 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
109 | static void | 86 | static void |
110 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 87 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
111 | { | 88 | { |
89 | int c; | ||
90 | |||
112 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 91 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
113 | { | 92 | { |
114 | GNUNET_SCHEDULER_cancel (endbadly_task); | 93 | GNUNET_SCHEDULER_cancel (endbadly_task); |
115 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 94 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
116 | } | 95 | } |
117 | |||
118 | int c; | ||
119 | for (c = 0; c < RECORDS; c++) | 96 | for (c = 0; c < RECORDS; c++) |
120 | GNUNET_free_non_null((void *) s_rd[c].data); | 97 | GNUNET_free_non_null((void *) s_rd[c].data); |
121 | GNUNET_free (s_rd); | 98 | GNUNET_free (s_rd); |
122 | |||
123 | if (privkey != NULL) | 99 | if (privkey != NULL) |
124 | GNUNET_CRYPTO_rsa_key_free (privkey); | 100 | GNUNET_CRYPTO_rsa_key_free (privkey); |
125 | privkey = NULL; | 101 | privkey = NULL; |
126 | |||
127 | if (nsh != NULL) | 102 | if (nsh != NULL) |
128 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 103 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
129 | nsh = NULL; | 104 | nsh = NULL; |
130 | |||
131 | if (NULL != arm) | ||
132 | stop_arm(); | ||
133 | } | 105 | } |
134 | 106 | ||
135 | void name_lookup_proc (void *cls, | 107 | |
136 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 108 | static void |
137 | struct GNUNET_TIME_Absolute expire, | 109 | name_lookup_proc (void *cls, |
138 | const char *n, | 110 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
139 | unsigned int rd_count, | 111 | struct GNUNET_TIME_Absolute expire, |
140 | const struct GNUNET_NAMESTORE_RecordData *rd, | 112 | const char *n, |
141 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 113 | unsigned int rd_count, |
114 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
115 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
142 | { | 116 | { |
143 | static int found = GNUNET_NO; | 117 | static int found = GNUNET_NO; |
144 | int failed = GNUNET_NO; | 118 | int failed = GNUNET_NO; |
@@ -197,7 +171,8 @@ void name_lookup_proc (void *cls, | |||
197 | GNUNET_SCHEDULER_add_now(&end, NULL); | 171 | GNUNET_SCHEDULER_add_now(&end, NULL); |
198 | } | 172 | } |
199 | 173 | ||
200 | void | 174 | |
175 | static void | ||
201 | remove_cont (void *cls, int32_t success, const char *emsg) | 176 | remove_cont (void *cls, int32_t success, const char *emsg) |
202 | { | 177 | { |
203 | char *name = cls; | 178 | char *name = cls; |
@@ -216,7 +191,8 @@ remove_cont (void *cls, int32_t success, const char *emsg) | |||
216 | 191 | ||
217 | } | 192 | } |
218 | 193 | ||
219 | void | 194 | |
195 | static void | ||
220 | put_cont (void *cls, int32_t success, const char *emsg) | 196 | put_cont (void *cls, int32_t success, const char *emsg) |
221 | { | 197 | { |
222 | char *name = cls; | 198 | char *name = cls; |
@@ -236,6 +212,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
236 | } | 212 | } |
237 | } | 213 | } |
238 | 214 | ||
215 | |||
239 | static struct GNUNET_NAMESTORE_RecordData * | 216 | static struct GNUNET_NAMESTORE_RecordData * |
240 | create_record (int count) | 217 | create_record (int count) |
241 | { | 218 | { |
@@ -261,34 +238,16 @@ create_record (int count) | |||
261 | return rd; | 238 | return rd; |
262 | } | 239 | } |
263 | 240 | ||
264 | void | ||
265 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
266 | { | ||
267 | char *afsdir; | ||
268 | |||
269 | if (GNUNET_OK == | ||
270 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
271 | "FILENAME", &afsdir)) | ||
272 | { | ||
273 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
274 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
275 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
276 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
277 | GNUNET_free (afsdir); | ||
278 | } | ||
279 | |||
280 | } | ||
281 | 241 | ||
282 | static void | 242 | static void |
283 | run (void *cls, char *const *args, const char *cfgfile, | 243 | run (void *cls, |
284 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 244 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
285 | { | 245 | { |
286 | delete_existing_db(cfg); | ||
287 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
288 | size_t rd_ser_len; | 246 | size_t rd_ser_len; |
247 | char *hostkey_file; | ||
289 | 248 | ||
249 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
290 | /* load privat key */ | 250 | /* load privat key */ |
291 | char *hostkey_file; | ||
292 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 251 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
293 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 252 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -313,54 +272,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
313 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 272 | GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
314 | 273 | ||
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); | 274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_short_h2s (&s_zone)); |
316 | |||
317 | |||
318 | start_arm (cfgfile); | ||
319 | GNUNET_assert (arm != NULL); | ||
320 | |||
321 | nsh = GNUNET_NAMESTORE_connect (cfg); | 275 | nsh = GNUNET_NAMESTORE_connect (cfg); |
322 | GNUNET_break (NULL != nsh); | 276 | GNUNET_break (NULL != nsh); |
323 | |||
324 | GNUNET_break (s_rd != NULL); | 277 | GNUNET_break (s_rd != NULL); |
325 | GNUNET_break (s_name != NULL); | 278 | GNUNET_break (s_name != NULL); |
326 | |||
327 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, | 279 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, |
328 | GNUNET_TIME_UNIT_FOREVER_ABS, | 280 | GNUNET_TIME_UNIT_FOREVER_ABS, |
329 | RECORDS, s_rd, s_signature, put_cont, s_name); | 281 | RECORDS, s_rd, s_signature, put_cont, s_name); |
330 | |||
331 | |||
332 | |||
333 | } | 282 | } |
334 | 283 | ||
335 | static int | ||
336 | check () | ||
337 | { | ||
338 | static char *const argv[] = { "test-namestore-api", | ||
339 | "-c", | ||
340 | "test_namestore_api.conf", | ||
341 | #if VERBOSE | ||
342 | "-L", "DEBUG", | ||
343 | #endif | ||
344 | NULL | ||
345 | }; | ||
346 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
347 | GNUNET_GETOPT_OPTION_END | ||
348 | }; | ||
349 | |||
350 | res = 1; | ||
351 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
352 | "nohelp", options, &run, &res); | ||
353 | return res; | ||
354 | } | ||
355 | 284 | ||
356 | int | 285 | int |
357 | main (int argc, char *argv[]) | 286 | main (int argc, char *argv[]) |
358 | { | 287 | { |
359 | int ret; | 288 | res = 1; |
360 | 289 | if (0 != | |
361 | ret = check (); | 290 | GNUNET_TESTING_service_run ("test-namestore-api-remove", |
362 | GNUNET_free (s_signature); | 291 | "namestore", |
363 | return ret; | 292 | "test_namestore_api.conf", |
293 | &run, | ||
294 | NULL)) | ||
295 | return 1; | ||
296 | GNUNET_free_non_null (s_signature); | ||
297 | return res; | ||
364 | } | 298 | } |
365 | 299 | ||
366 | /* end of test_namestore_api.c */ | 300 | /* end of test_namestore_api.c */ |
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c index 329602d41..5dfe8e220 100644 --- a/src/namestore/test_namestore_api_remove_not_existing_record.c +++ b/src/namestore/test_namestore_api_remove_not_existing_record.c | |||
@@ -18,69 +18,51 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api.c | 21 | * @file namestore/test_namestore_api_remove_not_existing_record.c |
22 | * @brief testcase for namestore_api.c | 22 | * @brief testcase for namestore_api.c |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define RECORDS 5 | 31 | #define RECORDS 5 |
32 | |||
33 | #define TEST_RECORD_TYPE 1234 | 33 | #define TEST_RECORD_TYPE 1234 |
34 | |||
34 | #define TEST_RECORD_DATALEN 123 | 35 | #define TEST_RECORD_DATALEN 123 |
36 | |||
35 | #define TEST_RECORD_DATA 'a' | 37 | #define TEST_RECORD_DATA 'a' |
36 | 38 | ||
37 | #define TEST_REMOVE_RECORD_TYPE 4321 | 39 | #define TEST_REMOVE_RECORD_TYPE 4321 |
40 | |||
38 | #define TEST_REMOVE_RECORD_DATALEN 255 | 41 | #define TEST_REMOVE_RECORD_DATALEN 255 |
42 | |||
39 | #define TEST_REMOVE_RECORD_DATA 'b' | 43 | #define TEST_REMOVE_RECORD_DATA 'b' |
40 | 44 | ||
41 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 45 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
42 | 46 | ||
47 | |||
43 | static struct GNUNET_NAMESTORE_Handle * nsh; | 48 | static struct GNUNET_NAMESTORE_Handle * nsh; |
44 | 49 | ||
45 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 50 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
46 | static struct GNUNET_OS_Process *arm; | ||
47 | 51 | ||
48 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 52 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
53 | |||
49 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 54 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
50 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | 55 | |
56 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; | ||
57 | |||
51 | static struct GNUNET_HashCode s_zone; | 58 | static struct GNUNET_HashCode s_zone; |
52 | struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
53 | static char *s_name; | ||
54 | 59 | ||
60 | static struct GNUNET_NAMESTORE_RecordData *s_rd; | ||
55 | 61 | ||
62 | static char *s_name; | ||
56 | 63 | ||
57 | static int res; | 64 | static int res; |
58 | 65 | ||
59 | static void | ||
60 | start_arm (const char *cfgname) | ||
61 | { | ||
62 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
63 | "gnunet-service-arm", "-c", cfgname, | ||
64 | #if VERBOSE_PEERS | ||
65 | "-L", "DEBUG", | ||
66 | #else | ||
67 | "-L", "ERROR", | ||
68 | #endif | ||
69 | NULL); | ||
70 | } | ||
71 | |||
72 | static void | ||
73 | stop_arm () | ||
74 | { | ||
75 | if (NULL != arm) | ||
76 | { | ||
77 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
79 | GNUNET_OS_process_wait (arm); | ||
80 | GNUNET_OS_process_destroy (arm); | ||
81 | arm = NULL; | ||
82 | } | ||
83 | } | ||
84 | 66 | ||
85 | /** | 67 | /** |
86 | * Re-establish the connection to the service. | 68 | * Re-establish the connection to the service. |
@@ -94,14 +76,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
94 | if (nsh != NULL) | 76 | if (nsh != NULL) |
95 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 77 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
96 | nsh = NULL; | 78 | nsh = NULL; |
97 | |||
98 | if (privkey != NULL) | 79 | if (privkey != NULL) |
99 | GNUNET_CRYPTO_rsa_key_free (privkey); | 80 | GNUNET_CRYPTO_rsa_key_free (privkey); |
100 | privkey = NULL; | 81 | privkey = NULL; |
101 | |||
102 | if (NULL != arm) | ||
103 | stop_arm(); | ||
104 | |||
105 | res = 1; | 82 | res = 1; |
106 | } | 83 | } |
107 | 84 | ||
@@ -109,13 +86,13 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
109 | static void | 86 | static void |
110 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 87 | end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
111 | { | 88 | { |
89 | int c; | ||
90 | |||
112 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 91 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
113 | { | 92 | { |
114 | GNUNET_SCHEDULER_cancel (endbadly_task); | 93 | GNUNET_SCHEDULER_cancel (endbadly_task); |
115 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 94 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
116 | } | 95 | } |
117 | |||
118 | int c; | ||
119 | for (c = 0; c < RECORDS; c++) | 96 | for (c = 0; c < RECORDS; c++) |
120 | GNUNET_free_non_null((void *) s_rd[c].data); | 97 | GNUNET_free_non_null((void *) s_rd[c].data); |
121 | GNUNET_free (s_rd); | 98 | GNUNET_free (s_rd); |
@@ -123,19 +100,17 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
123 | if (privkey != NULL) | 100 | if (privkey != NULL) |
124 | GNUNET_CRYPTO_rsa_key_free (privkey); | 101 | GNUNET_CRYPTO_rsa_key_free (privkey); |
125 | privkey = NULL; | 102 | privkey = NULL; |
126 | |||
127 | if (nsh != NULL) | 103 | if (nsh != NULL) |
128 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 104 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
129 | nsh = NULL; | 105 | nsh = NULL; |
130 | |||
131 | if (NULL != arm) | ||
132 | stop_arm(); | ||
133 | } | 106 | } |
134 | 107 | ||
135 | void | 108 | |
109 | static void | ||
136 | remove_cont (void *cls, int32_t success, const char *emsg) | 110 | remove_cont (void *cls, int32_t success, const char *emsg) |
137 | { | 111 | { |
138 | char *name = cls; | 112 | char *name = cls; |
113 | |||
139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s `%s'\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg); | 114 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove record for `%s': %s `%s'\n", name, (success == GNUNET_YES) ? "SUCCESS" : "FAIL", emsg); |
140 | if (GNUNET_NO == success) | 115 | if (GNUNET_NO == success) |
141 | { | 116 | { |
@@ -149,7 +124,8 @@ remove_cont (void *cls, int32_t success, const char *emsg) | |||
149 | GNUNET_SCHEDULER_add_now(&end, NULL); | 124 | GNUNET_SCHEDULER_add_now(&end, NULL); |
150 | } | 125 | } |
151 | 126 | ||
152 | void | 127 | |
128 | static void | ||
153 | put_cont (void *cls, int32_t success, const char *emsg) | 129 | put_cont (void *cls, int32_t success, const char *emsg) |
154 | { | 130 | { |
155 | char *name = cls; | 131 | char *name = cls; |
@@ -176,53 +152,36 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
176 | } | 152 | } |
177 | } | 153 | } |
178 | 154 | ||
155 | |||
179 | static struct GNUNET_NAMESTORE_RecordData * | 156 | static struct GNUNET_NAMESTORE_RecordData * |
180 | create_record (int count) | 157 | create_record (int count) |
181 | { | 158 | { |
182 | int c; | 159 | int c; |
183 | struct GNUNET_NAMESTORE_RecordData * rd; | 160 | struct GNUNET_NAMESTORE_RecordData * rd; |
184 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
185 | 161 | ||
162 | rd = GNUNET_malloc (count * sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
186 | for (c = 0; c < RECORDS; c++) | 163 | for (c = 0; c < RECORDS; c++) |
187 | { | 164 | { |
188 | rd[c].expiration = GNUNET_TIME_absolute_get(); | 165 | rd[c].expiration = GNUNET_TIME_absolute_get(); |
189 | rd[c].record_type = TEST_RECORD_TYPE; | 166 | rd[c].record_type = TEST_RECORD_TYPE; |
190 | rd[c].data_size = TEST_RECORD_DATALEN; | 167 | rd[c].data_size = TEST_RECORD_DATALEN; |
191 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); | 168 | rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); |
192 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); | 169 | memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); |
193 | } | 170 | } |
194 | |||
195 | return rd; | 171 | return rd; |
196 | } | 172 | } |
197 | 173 | ||
198 | void | ||
199 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
200 | { | ||
201 | char *afsdir; | ||
202 | |||
203 | if (GNUNET_OK == | ||
204 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
205 | "FILENAME", &afsdir)) | ||
206 | { | ||
207 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
208 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
209 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
210 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
211 | GNUNET_free (afsdir); | ||
212 | } | ||
213 | |||
214 | } | ||
215 | 174 | ||
216 | static void | 175 | static void |
217 | run (void *cls, char *const *args, const char *cfgfile, | 176 | run (void *cls, |
218 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 177 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
219 | { | 178 | { |
220 | delete_existing_db(cfg); | 179 | char *hostkey_file; |
221 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
222 | size_t rd_ser_len; | 180 | size_t rd_ser_len; |
223 | 181 | ||
182 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | ||
183 | |||
224 | /* load privat key */ | 184 | /* load privat key */ |
225 | char *hostkey_file; | ||
226 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 185 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
227 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 186 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -247,53 +206,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
247 | GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); | 206 | GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &s_zone); |
248 | 207 | ||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone)); | 208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone)); |
250 | |||
251 | |||
252 | start_arm (cfgfile); | ||
253 | GNUNET_assert (arm != NULL); | ||
254 | |||
255 | nsh = GNUNET_NAMESTORE_connect (cfg); | 209 | nsh = GNUNET_NAMESTORE_connect (cfg); |
256 | GNUNET_break (NULL != nsh); | 210 | GNUNET_break (NULL != nsh); |
257 | |||
258 | GNUNET_break (s_rd != NULL); | 211 | GNUNET_break (s_rd != NULL); |
259 | GNUNET_break (s_name != NULL); | 212 | GNUNET_break (s_name != NULL); |
260 | |||
261 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, | 213 | GNUNET_NAMESTORE_record_put (nsh, &pubkey, s_name, |
262 | GNUNET_TIME_UNIT_FOREVER_ABS, | 214 | GNUNET_TIME_UNIT_FOREVER_ABS, |
263 | RECORDS, s_rd, s_signature, put_cont, s_name); | 215 | RECORDS, s_rd, s_signature, put_cont, s_name); |
264 | |||
265 | |||
266 | } | 216 | } |
267 | 217 | ||
268 | static int | ||
269 | check () | ||
270 | { | ||
271 | static char *const argv[] = { "test-namestore-api", | ||
272 | "-c", | ||
273 | "test_namestore_api.conf", | ||
274 | #if VERBOSE | ||
275 | "-L", "DEBUG", | ||
276 | #endif | ||
277 | NULL | ||
278 | }; | ||
279 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
280 | GNUNET_GETOPT_OPTION_END | ||
281 | }; | ||
282 | |||
283 | res = 1; | ||
284 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
285 | "nohelp", options, &run, &res); | ||
286 | return res; | ||
287 | } | ||
288 | 218 | ||
289 | int | 219 | int |
290 | main (int argc, char *argv[]) | 220 | main (int argc, char *argv[]) |
291 | { | 221 | { |
292 | int ret; | 222 | res = 1; |
293 | 223 | if (0 != | |
294 | ret = check (); | 224 | GNUNET_TESTING_service_run ("test-namestore-api-remove-not-existing-record", |
295 | GNUNET_free (s_signature); | 225 | "namestore", |
296 | return ret; | 226 | "test_namestore_api.conf", |
227 | &run, | ||
228 | NULL)) | ||
229 | return 1; | ||
230 | GNUNET_free_non_null (s_signature); | ||
231 | return res; | ||
297 | } | 232 | } |
298 | 233 | ||
299 | /* end of test_namestore_api.c */ | 234 | /* end of test_namestore_api_remove_not_existing_record.c */ |
diff --git a/src/namestore/test_namestore_api_sign_verify.c b/src/namestore/test_namestore_api_sign_verify.c index 17bfb1eff..95d222c6d 100644 --- a/src/namestore/test_namestore_api_sign_verify.c +++ b/src/namestore/test_namestore_api_sign_verify.c | |||
@@ -27,25 +27,32 @@ | |||
27 | #include "namestore.h" | 27 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 28 | #include "gnunet_signatures.h" |
29 | 29 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define RECORDS 5 | 30 | #define RECORDS 5 |
31 | |||
33 | #define TEST_RECORD_TYPE 1234 | 32 | #define TEST_RECORD_TYPE 1234 |
33 | |||
34 | #define TEST_RECORD_DATALEN 123 | 34 | #define TEST_RECORD_DATALEN 123 |
35 | |||
35 | #define TEST_RECORD_DATA 'a' | 36 | #define TEST_RECORD_DATA 'a' |
36 | 37 | ||
37 | #define TEST_REMOVE_RECORD_TYPE 4321 | 38 | #define TEST_REMOVE_RECORD_TYPE 4321 |
39 | |||
38 | #define TEST_REMOVE_RECORD_DATALEN 255 | 40 | #define TEST_REMOVE_RECORD_DATALEN 255 |
41 | |||
39 | #define TEST_REMOVE_RECORD_DATA 'b' | 42 | #define TEST_REMOVE_RECORD_DATA 'b' |
40 | 43 | ||
44 | |||
41 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 45 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
46 | |||
42 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 47 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
43 | struct GNUNET_CRYPTO_RsaSignature s_signature; | 48 | |
44 | struct GNUNET_NAMESTORE_RecordData *s_rd; | 49 | static struct GNUNET_NAMESTORE_RecordData *s_rd; |
50 | |||
45 | static char *s_name; | 51 | static char *s_name; |
46 | 52 | ||
47 | static int res; | 53 | static int res; |
48 | 54 | ||
55 | |||
49 | static struct GNUNET_NAMESTORE_RecordData * | 56 | static struct GNUNET_NAMESTORE_RecordData * |
50 | create_record (int count) | 57 | create_record (int count) |
51 | { | 58 | { |
@@ -66,7 +73,6 @@ create_record (int count) | |||
66 | } | 73 | } |
67 | 74 | ||
68 | 75 | ||
69 | |||
70 | static void | 76 | static void |
71 | run (void *cls, char *const *args, const char *cfgfile, | 77 | run (void *cls, char *const *args, const char *cfgfile, |
72 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 78 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -116,15 +122,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
116 | 122 | ||
117 | } | 123 | } |
118 | 124 | ||
119 | static int | 125 | |
120 | check () | 126 | int |
127 | main (int argc, char *argv[]) | ||
121 | { | 128 | { |
122 | static char *const argv[] = { "test-namestore-api", | 129 | static char *const argvx[] = { "test-namestore-api", |
123 | "-c", | 130 | "-c", |
124 | "test_namestore_api.conf", | 131 | "test_namestore_api.conf", |
125 | #if VERBOSE | ||
126 | "-L", "DEBUG", | ||
127 | #endif | ||
128 | NULL | 132 | NULL |
129 | }; | 133 | }; |
130 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 134 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -132,19 +136,9 @@ check () | |||
132 | }; | 136 | }; |
133 | 137 | ||
134 | res = 1; | 138 | res = 1; |
135 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | 139 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, argvx, "test-namestore-api", |
136 | "nohelp", options, &run, &res); | 140 | "nohelp", options, &run, &res); |
137 | return res; | 141 | return res; |
138 | } | 142 | } |
139 | 143 | ||
140 | int | ||
141 | main (int argc, char *argv[]) | ||
142 | { | ||
143 | int ret; | ||
144 | |||
145 | ret = check (); | ||
146 | |||
147 | return ret; | ||
148 | } | ||
149 | |||
150 | /* end of test_namestore_api_sign_verify.c */ | 144 | /* end of test_namestore_api_sign_verify.c */ |
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index f18aad93f..9a2c2d0ab 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c | |||
@@ -24,67 +24,55 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | 29 | ||
29 | #define VERBOSE GNUNET_NO | ||
30 | 30 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
32 | 32 | ||
33 | |||
33 | static struct GNUNET_NAMESTORE_Handle * nsh; | 34 | static struct GNUNET_NAMESTORE_Handle * nsh; |
34 | 35 | ||
35 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 36 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
37 | |||
36 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; | 38 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; |
37 | static struct GNUNET_OS_Process *arm; | ||
38 | 39 | ||
39 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 40 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
41 | |||
40 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 42 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
43 | |||
41 | static struct GNUNET_HashCode zone; | 44 | static struct GNUNET_HashCode zone; |
42 | 45 | ||
43 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; | 46 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; |
47 | |||
44 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; | 48 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; |
49 | |||
45 | static struct GNUNET_HashCode zone2; | 50 | static struct GNUNET_HashCode zone2; |
46 | 51 | ||
47 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 52 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
53 | |||
48 | static int res; | 54 | static int res; |
55 | |||
49 | static int returned_records; | 56 | static int returned_records; |
50 | 57 | ||
51 | struct GNUNET_CRYPTO_RsaSignature *sig_1; | 58 | static struct GNUNET_CRYPTO_RsaSignature *sig_1; |
52 | char * s_name_1; | ||
53 | struct GNUNET_NAMESTORE_RecordData *s_rd_1; | ||
54 | 59 | ||
55 | struct GNUNET_CRYPTO_RsaSignature *sig_2; | 60 | static char * s_name_1; |
56 | char * s_name_2; | ||
57 | struct GNUNET_NAMESTORE_RecordData *s_rd_2; | ||
58 | 61 | ||
59 | struct GNUNET_CRYPTO_RsaSignature *sig_3; | 62 | static struct GNUNET_NAMESTORE_RecordData *s_rd_1; |
60 | char * s_name_3; | ||
61 | struct GNUNET_NAMESTORE_RecordData *s_rd_3; | ||
62 | 63 | ||
63 | static void | 64 | static struct GNUNET_CRYPTO_RsaSignature *sig_2; |
64 | start_arm (const char *cfgname) | 65 | |
65 | { | 66 | static char * s_name_2; |
66 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | 67 | |
67 | "gnunet-service-arm", "-c", cfgname, | 68 | static struct GNUNET_NAMESTORE_RecordData *s_rd_2; |
68 | #if VERBOSE_PEERS | 69 | |
69 | "-L", "DEBUG", | 70 | static struct GNUNET_CRYPTO_RsaSignature *sig_3; |
70 | #else | 71 | |
71 | "-L", "ERROR", | 72 | static char * s_name_3; |
72 | #endif | 73 | |
73 | NULL); | 74 | static struct GNUNET_NAMESTORE_RecordData *s_rd_3; |
74 | } | ||
75 | 75 | ||
76 | static void | ||
77 | stop_arm () | ||
78 | { | ||
79 | if (NULL != arm) | ||
80 | { | ||
81 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
82 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
83 | GNUNET_OS_process_wait (arm); | ||
84 | GNUNET_OS_process_destroy (arm); | ||
85 | arm = NULL; | ||
86 | } | ||
87 | } | ||
88 | 76 | ||
89 | /** | 77 | /** |
90 | * Re-establish the connection to the service. | 78 | * Re-establish the connection to the service. |
@@ -135,10 +123,6 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
135 | if (privkey2 != NULL) | 123 | if (privkey2 != NULL) |
136 | GNUNET_CRYPTO_rsa_key_free (privkey2); | 124 | GNUNET_CRYPTO_rsa_key_free (privkey2); |
137 | privkey2 = NULL; | 125 | privkey2 = NULL; |
138 | |||
139 | if (NULL != arm) | ||
140 | stop_arm(); | ||
141 | |||
142 | res = 1; | 126 | res = 1; |
143 | } | 127 | } |
144 | 128 | ||
@@ -187,23 +171,20 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
187 | GNUNET_free ((void *)s_rd_3->data); | 171 | GNUNET_free ((void *)s_rd_3->data); |
188 | GNUNET_free (s_rd_3); | 172 | GNUNET_free (s_rd_3); |
189 | } | 173 | } |
190 | |||
191 | if (nsh != NULL) | 174 | if (nsh != NULL) |
192 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 175 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
193 | nsh = NULL; | 176 | nsh = NULL; |
194 | |||
195 | |||
196 | if (NULL != arm) | ||
197 | stop_arm(); | ||
198 | } | 177 | } |
199 | 178 | ||
200 | void zone_proc (void *cls, | 179 | |
201 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 180 | static void |
202 | struct GNUNET_TIME_Absolute expire, | 181 | zone_proc (void *cls, |
203 | const char *name, | 182 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
204 | unsigned int rd_count, | 183 | struct GNUNET_TIME_Absolute expire, |
205 | const struct GNUNET_NAMESTORE_RecordData *rd, | 184 | const char *name, |
206 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 185 | unsigned int rd_count, |
186 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
187 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
207 | { | 188 | { |
208 | int failed = GNUNET_NO; | 189 | int failed = GNUNET_NO; |
209 | if ((zone_key == NULL) && (name == NULL)) | 190 | if ((zone_key == NULL) && (name == NULL)) |
@@ -322,25 +303,8 @@ void zone_proc (void *cls, | |||
322 | } | 303 | } |
323 | } | 304 | } |
324 | 305 | ||
325 | void | ||
326 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
327 | { | ||
328 | char *afsdir; | ||
329 | |||
330 | if (GNUNET_OK == | ||
331 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
332 | "FILENAME", &afsdir)) | ||
333 | { | ||
334 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
335 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
336 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
338 | GNUNET_free (afsdir); | ||
339 | } | ||
340 | |||
341 | } | ||
342 | 306 | ||
343 | void | 307 | static void |
344 | put_cont (void *cls, int32_t success, const char *emsg) | 308 | put_cont (void *cls, int32_t success, const char *emsg) |
345 | { | 309 | { |
346 | static int c = 0; | 310 | static int c = 0; |
@@ -379,6 +343,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
379 | } | 343 | } |
380 | } | 344 | } |
381 | 345 | ||
346 | |||
382 | static struct GNUNET_NAMESTORE_RecordData * | 347 | static struct GNUNET_NAMESTORE_RecordData * |
383 | create_record (int count) | 348 | create_record (int count) |
384 | { | 349 | { |
@@ -397,14 +362,14 @@ create_record (int count) | |||
397 | return rd; | 362 | return rd; |
398 | } | 363 | } |
399 | 364 | ||
365 | |||
400 | static void | 366 | static void |
401 | run (void *cls, char *const *args, const char *cfgfile, | 367 | run (void *cls, |
402 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 368 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
403 | { | 369 | { |
404 | delete_existing_db(cfg); | ||
405 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
406 | |||
407 | char *hostkey_file; | 370 | char *hostkey_file; |
371 | |||
372 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
408 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 373 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
409 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 374 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -424,11 +389,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
424 | GNUNET_assert (privkey2 != NULL); | 389 | GNUNET_assert (privkey2 != NULL); |
425 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); | 390 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); |
426 | GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); | 391 | GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); |
427 | |||
428 | |||
429 | start_arm (cfgfile); | ||
430 | GNUNET_assert (arm != NULL); | ||
431 | |||
432 | nsh = GNUNET_NAMESTORE_connect (cfg); | 392 | nsh = GNUNET_NAMESTORE_connect (cfg); |
433 | GNUNET_break (NULL != nsh); | 393 | GNUNET_break (NULL != nsh); |
434 | 394 | ||
@@ -455,35 +415,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
455 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); | 415 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); |
456 | } | 416 | } |
457 | 417 | ||
458 | static int | ||
459 | check () | ||
460 | { | ||
461 | static char *const argv[] = { "test_namestore_api_zone_iteration", | ||
462 | "-c", | ||
463 | "test_namestore_api.conf", | ||
464 | #if VERBOSE | ||
465 | "-L", "DEBUG", | ||
466 | #endif | ||
467 | NULL | ||
468 | }; | ||
469 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
470 | GNUNET_GETOPT_OPTION_END | ||
471 | }; | ||
472 | |||
473 | res = 1; | ||
474 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test_namestore_api_zone_iteration", | ||
475 | "nohelp", options, &run, &res); | ||
476 | return res; | ||
477 | } | ||
478 | 418 | ||
479 | int | 419 | int |
480 | main (int argc, char *argv[]) | 420 | main (int argc, char *argv[]) |
481 | { | 421 | { |
482 | int ret; | 422 | res = 1; |
483 | 423 | if (0 != | |
484 | ret = check (); | 424 | GNUNET_TESTING_service_run ("test-namestore-api-zone-iteration", |
485 | 425 | "namestore", | |
486 | return ret; | 426 | "test_namestore_api.conf", |
427 | &run, | ||
428 | NULL)) | ||
429 | return 1; | ||
430 | return res; | ||
487 | } | 431 | } |
488 | 432 | ||
433 | |||
489 | /* end of test_namestore_api_zone_iteration.c */ | 434 | /* end of test_namestore_api_zone_iteration.c */ |
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c index b21c860c8..b76acb4dd 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c | |||
@@ -23,68 +23,56 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_testing_lib-new.h" | ||
26 | #include "gnunet_namestore_service.h" | 27 | #include "gnunet_namestore_service.h" |
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | 29 | ||
29 | #define VERBOSE GNUNET_NO | ||
30 | 30 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
32 | 32 | ||
33 | |||
33 | static struct GNUNET_NAMESTORE_Handle * nsh; | 34 | static struct GNUNET_NAMESTORE_Handle * nsh; |
34 | 35 | ||
35 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 36 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
37 | |||
36 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; | 38 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; |
37 | static struct GNUNET_OS_Process *arm; | ||
38 | 39 | ||
39 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 40 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
41 | |||
40 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 42 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
43 | |||
41 | static struct GNUNET_CRYPTO_ShortHashCode zone; | 44 | static struct GNUNET_CRYPTO_ShortHashCode zone; |
42 | 45 | ||
43 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; | 46 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; |
47 | |||
44 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; | 48 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; |
49 | |||
45 | static struct GNUNET_CRYPTO_ShortHashCode zone2; | 50 | static struct GNUNET_CRYPTO_ShortHashCode zone2; |
46 | 51 | ||
47 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 52 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
53 | |||
48 | static int res; | 54 | static int res; |
55 | |||
49 | static int returned_records; | 56 | static int returned_records; |
50 | 57 | ||
51 | struct GNUNET_CRYPTO_RsaSignature *sig_1; | 58 | static struct GNUNET_CRYPTO_RsaSignature *sig_1; |
52 | char * s_name_1; | ||
53 | struct GNUNET_NAMESTORE_RecordData *s_rd_1; | ||
54 | 59 | ||
55 | struct GNUNET_CRYPTO_RsaSignature *sig_2; | 60 | static char * s_name_1; |
56 | char * s_name_2; | ||
57 | struct GNUNET_NAMESTORE_RecordData *s_rd_2; | ||
58 | 61 | ||
59 | struct GNUNET_CRYPTO_RsaSignature *sig_3; | 62 | static struct GNUNET_NAMESTORE_RecordData *s_rd_1; |
60 | char * s_name_3; | ||
61 | struct GNUNET_NAMESTORE_RecordData *s_rd_3; | ||
62 | 63 | ||
63 | static void | 64 | static struct GNUNET_CRYPTO_RsaSignature *sig_2; |
64 | start_arm (const char *cfgname) | 65 | |
65 | { | 66 | static char * s_name_2; |
66 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | 67 | |
67 | "gnunet-service-arm", "-c", cfgname, | 68 | static struct GNUNET_NAMESTORE_RecordData *s_rd_2; |
68 | #if VERBOSE_PEERS | 69 | |
69 | "-L", "DEBUG", | 70 | static struct GNUNET_CRYPTO_RsaSignature *sig_3; |
70 | #else | 71 | |
71 | "-L", "ERROR", | 72 | static char * s_name_3; |
72 | #endif | 73 | |
73 | NULL); | 74 | static struct GNUNET_NAMESTORE_RecordData *s_rd_3; |
74 | } | ||
75 | 75 | ||
76 | static void | ||
77 | stop_arm () | ||
78 | { | ||
79 | if (NULL != arm) | ||
80 | { | ||
81 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
82 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
83 | GNUNET_OS_process_wait (arm); | ||
84 | GNUNET_OS_process_destroy (arm); | ||
85 | arm = NULL; | ||
86 | } | ||
87 | } | ||
88 | 76 | ||
89 | /** | 77 | /** |
90 | * Re-establish the connection to the service. | 78 | * Re-establish the connection to the service. |
@@ -104,14 +92,12 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
104 | if (nsh != NULL) | 92 | if (nsh != NULL) |
105 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 93 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
106 | nsh = NULL; | 94 | nsh = NULL; |
107 | |||
108 | GNUNET_free_non_null(sig_1); | 95 | GNUNET_free_non_null(sig_1); |
109 | GNUNET_free_non_null(sig_2); | 96 | GNUNET_free_non_null(sig_2); |
110 | GNUNET_free_non_null(sig_3); | 97 | GNUNET_free_non_null(sig_3); |
111 | GNUNET_free_non_null(s_name_1); | 98 | GNUNET_free_non_null(s_name_1); |
112 | GNUNET_free_non_null(s_name_2); | 99 | GNUNET_free_non_null(s_name_2); |
113 | GNUNET_free_non_null(s_name_3); | 100 | GNUNET_free_non_null(s_name_3); |
114 | |||
115 | if (s_rd_1 != NULL) | 101 | if (s_rd_1 != NULL) |
116 | { | 102 | { |
117 | GNUNET_free ((void *)s_rd_1->data); | 103 | GNUNET_free ((void *)s_rd_1->data); |
@@ -135,10 +121,6 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
135 | if (privkey2 != NULL) | 121 | if (privkey2 != NULL) |
136 | GNUNET_CRYPTO_rsa_key_free (privkey2); | 122 | GNUNET_CRYPTO_rsa_key_free (privkey2); |
137 | privkey2 = NULL; | 123 | privkey2 = NULL; |
138 | |||
139 | if (NULL != arm) | ||
140 | stop_arm(); | ||
141 | |||
142 | res = 1; | 124 | res = 1; |
143 | } | 125 | } |
144 | 126 | ||
@@ -151,17 +133,14 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
151 | GNUNET_SCHEDULER_cancel (stopiteration_task); | 133 | GNUNET_SCHEDULER_cancel (stopiteration_task); |
152 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; | 134 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; |
153 | } | 135 | } |
154 | |||
155 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) | 136 | if (endbadly_task != GNUNET_SCHEDULER_NO_TASK) |
156 | { | 137 | { |
157 | GNUNET_SCHEDULER_cancel (endbadly_task); | 138 | GNUNET_SCHEDULER_cancel (endbadly_task); |
158 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 139 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
159 | } | 140 | } |
160 | |||
161 | if (privkey != NULL) | 141 | if (privkey != NULL) |
162 | GNUNET_CRYPTO_rsa_key_free (privkey); | 142 | GNUNET_CRYPTO_rsa_key_free (privkey); |
163 | privkey = NULL; | 143 | privkey = NULL; |
164 | |||
165 | if (privkey2 != NULL) | 144 | if (privkey2 != NULL) |
166 | GNUNET_CRYPTO_rsa_key_free (privkey2); | 145 | GNUNET_CRYPTO_rsa_key_free (privkey2); |
167 | privkey2 = NULL; | 146 | privkey2 = NULL; |
@@ -187,23 +166,20 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
187 | GNUNET_free ((void *)s_rd_3->data); | 166 | GNUNET_free ((void *)s_rd_3->data); |
188 | GNUNET_free (s_rd_3); | 167 | GNUNET_free (s_rd_3); |
189 | } | 168 | } |
190 | |||
191 | if (nsh != NULL) | 169 | if (nsh != NULL) |
192 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 170 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
193 | nsh = NULL; | 171 | nsh = NULL; |
194 | |||
195 | |||
196 | if (NULL != arm) | ||
197 | stop_arm(); | ||
198 | } | 172 | } |
199 | 173 | ||
200 | void zone_proc (void *cls, | 174 | |
201 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 175 | static void |
202 | struct GNUNET_TIME_Absolute expire, | 176 | zone_proc (void *cls, |
203 | const char *name, | 177 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
204 | unsigned int rd_count, | 178 | struct GNUNET_TIME_Absolute expire, |
205 | const struct GNUNET_NAMESTORE_RecordData *rd, | 179 | const char *name, |
206 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 180 | unsigned int rd_count, |
181 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
182 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
207 | { | 183 | { |
208 | int failed = GNUNET_NO; | 184 | int failed = GNUNET_NO; |
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_short_h2s (&zone)); | 185 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_short_h2s (&zone)); |
@@ -285,25 +261,8 @@ void zone_proc (void *cls, | |||
285 | } | 261 | } |
286 | } | 262 | } |
287 | 263 | ||
288 | void | ||
289 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
290 | { | ||
291 | char *afsdir; | ||
292 | |||
293 | if (GNUNET_OK == | ||
294 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
295 | "FILENAME", &afsdir)) | ||
296 | { | ||
297 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
298 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
299 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
301 | GNUNET_free (afsdir); | ||
302 | } | ||
303 | |||
304 | } | ||
305 | 264 | ||
306 | void | 265 | static void |
307 | put_cont (void *cls, int32_t success, const char *emsg) | 266 | put_cont (void *cls, int32_t success, const char *emsg) |
308 | { | 267 | { |
309 | static int c = 0; | 268 | static int c = 0; |
@@ -343,6 +302,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
343 | } | 302 | } |
344 | } | 303 | } |
345 | 304 | ||
305 | |||
346 | static struct GNUNET_NAMESTORE_RecordData * | 306 | static struct GNUNET_NAMESTORE_RecordData * |
347 | create_record (int count) | 307 | create_record (int count) |
348 | { | 308 | { |
@@ -361,14 +321,14 @@ create_record (int count) | |||
361 | return rd; | 321 | return rd; |
362 | } | 322 | } |
363 | 323 | ||
324 | |||
364 | static void | 325 | static void |
365 | run (void *cls, char *const *args, const char *cfgfile, | 326 | run (void *cls, |
366 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 327 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
367 | { | 328 | { |
368 | delete_existing_db(cfg); | ||
369 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
370 | |||
371 | char *hostkey_file; | 329 | char *hostkey_file; |
330 | |||
331 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
372 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 332 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
373 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 333 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 334 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -386,26 +346,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
386 | GNUNET_assert (privkey2 != NULL); | 346 | GNUNET_assert (privkey2 != NULL); |
387 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); | 347 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); |
388 | GNUNET_CRYPTO_short_hash (&pubkey2, sizeof (pubkey), &zone2); | 348 | GNUNET_CRYPTO_short_hash (&pubkey2, sizeof (pubkey), &zone2); |
389 | |||
390 | |||
391 | start_arm (cfgfile); | ||
392 | GNUNET_assert (arm != NULL); | ||
393 | |||
394 | nsh = GNUNET_NAMESTORE_connect (cfg); | 349 | nsh = GNUNET_NAMESTORE_connect (cfg); |
395 | GNUNET_break (NULL != nsh); | 350 | GNUNET_break (NULL != nsh); |
396 | 351 | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); |
398 | |||
399 | GNUNET_asprintf(&s_name_1, "dummy1"); | 353 | GNUNET_asprintf(&s_name_1, "dummy1"); |
400 | s_rd_1 = create_record(1); | 354 | s_rd_1 = create_record(1); |
401 | sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_1[0].expiration ,s_name_1, s_rd_1, 1); | 355 | sig_1 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_1[0].expiration ,s_name_1, s_rd_1, 1); |
402 | GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL); | 356 | GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_1, s_rd_1, &put_cont, NULL); |
403 | 357 | ||
404 | |||
405 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); | 358 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); |
406 | GNUNET_asprintf(&s_name_2, "dummy2"); | 359 | GNUNET_asprintf(&s_name_2, "dummy2"); |
407 | s_rd_2 = create_record(1); | 360 | s_rd_2 = create_record(1); |
408 | |||
409 | sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_2[0].expiration, s_name_2, s_rd_2, 1); | 361 | sig_2 = GNUNET_NAMESTORE_create_signature(privkey, s_rd_2[0].expiration, s_name_2, s_rd_2, 1); |
410 | GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL); | 362 | GNUNET_NAMESTORE_record_create(nsh, privkey, s_name_2, s_rd_2, &put_cont, NULL); |
411 | 363 | ||
@@ -417,35 +369,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
417 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); | 369 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); |
418 | } | 370 | } |
419 | 371 | ||
420 | static int | ||
421 | check () | ||
422 | { | ||
423 | static char *const argv[] = { "test_namestore_api_zone_iteration", | ||
424 | "-c", | ||
425 | "test_namestore_api.conf", | ||
426 | #if VERBOSE | ||
427 | "-L", "DEBUG", | ||
428 | #endif | ||
429 | NULL | ||
430 | }; | ||
431 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
432 | GNUNET_GETOPT_OPTION_END | ||
433 | }; | ||
434 | |||
435 | res = 1; | ||
436 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test_namestore_api_zone_iteration", | ||
437 | "nohelp", options, &run, &res); | ||
438 | return res; | ||
439 | } | ||
440 | 372 | ||
441 | int | 373 | int |
442 | main (int argc, char *argv[]) | 374 | main (int argc, char *argv[]) |
443 | { | 375 | { |
444 | int ret; | 376 | res = 1; |
445 | 377 | if (0 != | |
446 | ret = check (); | 378 | GNUNET_TESTING_service_run ("test-namestore-api-zone-iteration-specific-zone", |
447 | 379 | "namestore", | |
448 | return ret; | 380 | "test_namestore_api.conf", |
381 | &run, | ||
382 | NULL)) | ||
383 | return 1; | ||
384 | return res; | ||
449 | } | 385 | } |
450 | 386 | ||
451 | /* end of test_namestore_api_zone_iteration_specific_zone.c */ | 387 | /* end of test_namestore_api_zone_iteration_specific_zone.c */ |
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c index 90031edc7..71ae43362 100644 --- a/src/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/namestore/test_namestore_api_zone_iteration_stop.c | |||
@@ -23,68 +23,55 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_testing_lib-new.h" | ||
26 | #include "gnunet_namestore_service.h" | 27 | #include "gnunet_namestore_service.h" |
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | 29 | ||
29 | #define VERBOSE GNUNET_NO | ||
30 | 30 | ||
31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 31 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
32 | 32 | ||
33 | static struct GNUNET_NAMESTORE_Handle * nsh; | 33 | static struct GNUNET_NAMESTORE_Handle * nsh; |
34 | 34 | ||
35 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 35 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
36 | |||
36 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; | 37 | static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task; |
37 | static struct GNUNET_OS_Process *arm; | ||
38 | 38 | ||
39 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 39 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
40 | |||
40 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 41 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
42 | |||
41 | static struct GNUNET_HashCode zone; | 43 | static struct GNUNET_HashCode zone; |
42 | 44 | ||
43 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; | 45 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey2; |
46 | |||
44 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; | 47 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey2; |
48 | |||
45 | static struct GNUNET_HashCode zone2; | 49 | static struct GNUNET_HashCode zone2; |
46 | 50 | ||
47 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 51 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
52 | |||
48 | static int res; | 53 | static int res; |
54 | |||
49 | static int returned_records; | 55 | static int returned_records; |
50 | 56 | ||
51 | struct GNUNET_CRYPTO_RsaSignature *sig_1; | 57 | static struct GNUNET_CRYPTO_RsaSignature *sig_1; |
52 | char * s_name_1; | ||
53 | struct GNUNET_NAMESTORE_RecordData *s_rd_1; | ||
54 | 58 | ||
55 | struct GNUNET_CRYPTO_RsaSignature *sig_2; | 59 | static char * s_name_1; |
56 | char * s_name_2; | ||
57 | struct GNUNET_NAMESTORE_RecordData *s_rd_2; | ||
58 | 60 | ||
59 | struct GNUNET_CRYPTO_RsaSignature *sig_3; | 61 | static struct GNUNET_NAMESTORE_RecordData *s_rd_1; |
60 | char * s_name_3; | ||
61 | struct GNUNET_NAMESTORE_RecordData *s_rd_3; | ||
62 | 62 | ||
63 | static void | 63 | static struct GNUNET_CRYPTO_RsaSignature *sig_2; |
64 | start_arm (const char *cfgname) | 64 | |
65 | { | 65 | static char * s_name_2; |
66 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | 66 | |
67 | "gnunet-service-arm", "-c", cfgname, | 67 | static struct GNUNET_NAMESTORE_RecordData *s_rd_2; |
68 | #if VERBOSE_PEERS | 68 | |
69 | "-L", "DEBUG", | 69 | static struct GNUNET_CRYPTO_RsaSignature *sig_3; |
70 | #else | 70 | |
71 | "-L", "ERROR", | 71 | static char * s_name_3; |
72 | #endif | 72 | |
73 | NULL); | 73 | static struct GNUNET_NAMESTORE_RecordData *s_rd_3; |
74 | } | ||
75 | 74 | ||
76 | static void | ||
77 | stop_arm () | ||
78 | { | ||
79 | if (NULL != arm) | ||
80 | { | ||
81 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
82 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
83 | GNUNET_OS_process_wait (arm); | ||
84 | GNUNET_OS_process_destroy (arm); | ||
85 | arm = NULL; | ||
86 | } | ||
87 | } | ||
88 | 75 | ||
89 | /** | 76 | /** |
90 | * Re-establish the connection to the service. | 77 | * Re-establish the connection to the service. |
@@ -100,18 +87,15 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
100 | GNUNET_SCHEDULER_cancel (stopiteration_task); | 87 | GNUNET_SCHEDULER_cancel (stopiteration_task); |
101 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; | 88 | stopiteration_task = GNUNET_SCHEDULER_NO_TASK; |
102 | } | 89 | } |
103 | |||
104 | if (nsh != NULL) | 90 | if (nsh != NULL) |
105 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 91 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
106 | nsh = NULL; | 92 | nsh = NULL; |
107 | |||
108 | GNUNET_free_non_null(sig_1); | 93 | GNUNET_free_non_null(sig_1); |
109 | GNUNET_free_non_null(sig_2); | 94 | GNUNET_free_non_null(sig_2); |
110 | GNUNET_free_non_null(sig_3); | 95 | GNUNET_free_non_null(sig_3); |
111 | GNUNET_free_non_null(s_name_1); | 96 | GNUNET_free_non_null(s_name_1); |
112 | GNUNET_free_non_null(s_name_2); | 97 | GNUNET_free_non_null(s_name_2); |
113 | GNUNET_free_non_null(s_name_3); | 98 | GNUNET_free_non_null(s_name_3); |
114 | |||
115 | if (s_rd_1 != NULL) | 99 | if (s_rd_1 != NULL) |
116 | { | 100 | { |
117 | GNUNET_free ((void *)s_rd_1->data); | 101 | GNUNET_free ((void *)s_rd_1->data); |
@@ -127,7 +111,6 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
127 | GNUNET_free ((void *)s_rd_3->data); | 111 | GNUNET_free ((void *)s_rd_3->data); |
128 | GNUNET_free (s_rd_3); | 112 | GNUNET_free (s_rd_3); |
129 | } | 113 | } |
130 | |||
131 | if (privkey != NULL) | 114 | if (privkey != NULL) |
132 | GNUNET_CRYPTO_rsa_key_free (privkey); | 115 | GNUNET_CRYPTO_rsa_key_free (privkey); |
133 | privkey = NULL; | 116 | privkey = NULL; |
@@ -135,10 +118,6 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
135 | if (privkey2 != NULL) | 118 | if (privkey2 != NULL) |
136 | GNUNET_CRYPTO_rsa_key_free (privkey2); | 119 | GNUNET_CRYPTO_rsa_key_free (privkey2); |
137 | privkey2 = NULL; | 120 | privkey2 = NULL; |
138 | |||
139 | if (NULL != arm) | ||
140 | stop_arm(); | ||
141 | |||
142 | res = 1; | 121 | res = 1; |
143 | } | 122 | } |
144 | 123 | ||
@@ -157,11 +136,9 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
157 | GNUNET_SCHEDULER_cancel (endbadly_task); | 136 | GNUNET_SCHEDULER_cancel (endbadly_task); |
158 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 137 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
159 | } | 138 | } |
160 | |||
161 | if (privkey != NULL) | 139 | if (privkey != NULL) |
162 | GNUNET_CRYPTO_rsa_key_free (privkey); | 140 | GNUNET_CRYPTO_rsa_key_free (privkey); |
163 | privkey = NULL; | 141 | privkey = NULL; |
164 | |||
165 | if (privkey2 != NULL) | 142 | if (privkey2 != NULL) |
166 | GNUNET_CRYPTO_rsa_key_free (privkey2); | 143 | GNUNET_CRYPTO_rsa_key_free (privkey2); |
167 | privkey2 = NULL; | 144 | privkey2 = NULL; |
@@ -187,13 +164,9 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
187 | GNUNET_free ((void *)s_rd_3->data); | 164 | GNUNET_free ((void *)s_rd_3->data); |
188 | GNUNET_free (s_rd_3); | 165 | GNUNET_free (s_rd_3); |
189 | } | 166 | } |
190 | |||
191 | if (nsh != NULL) | 167 | if (nsh != NULL) |
192 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 168 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
193 | nsh = NULL; | 169 | nsh = NULL; |
194 | |||
195 | if (NULL != arm) | ||
196 | stop_arm(); | ||
197 | if (returned_records == 1) | 170 | if (returned_records == 1) |
198 | res = 0; | 171 | res = 0; |
199 | else | 172 | else |
@@ -201,13 +174,15 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
201 | 174 | ||
202 | } | 175 | } |
203 | 176 | ||
204 | void zone_proc (void *cls, | 177 | |
205 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 178 | static void |
206 | struct GNUNET_TIME_Absolute expire, | 179 | zone_proc (void *cls, |
207 | const char *name, | 180 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
208 | unsigned int rd_count, | 181 | struct GNUNET_TIME_Absolute expire, |
209 | const struct GNUNET_NAMESTORE_RecordData *rd, | 182 | const char *name, |
210 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 183 | unsigned int rd_count, |
184 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
185 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
211 | { | 186 | { |
212 | int failed = GNUNET_NO; | 187 | int failed = GNUNET_NO; |
213 | 188 | ||
@@ -336,25 +311,8 @@ void zone_proc (void *cls, | |||
336 | } | 311 | } |
337 | } | 312 | } |
338 | 313 | ||
339 | void | ||
340 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
341 | { | ||
342 | char *afsdir; | ||
343 | |||
344 | if (GNUNET_OK == | ||
345 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
346 | "FILENAME", &afsdir)) | ||
347 | { | ||
348 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
349 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
350 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
351 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
352 | GNUNET_free (afsdir); | ||
353 | } | ||
354 | |||
355 | } | ||
356 | 314 | ||
357 | void | 315 | static void |
358 | put_cont (void *cls, int32_t success, const char *emsg) | 316 | put_cont (void *cls, int32_t success, const char *emsg) |
359 | { | 317 | { |
360 | static int c = 0; | 318 | static int c = 0; |
@@ -393,6 +351,7 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
393 | } | 351 | } |
394 | } | 352 | } |
395 | 353 | ||
354 | |||
396 | static struct GNUNET_NAMESTORE_RecordData * | 355 | static struct GNUNET_NAMESTORE_RecordData * |
397 | create_record (int count) | 356 | create_record (int count) |
398 | { | 357 | { |
@@ -411,14 +370,14 @@ create_record (int count) | |||
411 | return rd; | 370 | return rd; |
412 | } | 371 | } |
413 | 372 | ||
373 | |||
414 | static void | 374 | static void |
415 | run (void *cls, char *const *args, const char *cfgfile, | 375 | run (void *cls, |
416 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 376 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
417 | { | 377 | { |
418 | delete_existing_db(cfg); | ||
419 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
420 | |||
421 | char *hostkey_file; | 378 | char *hostkey_file; |
379 | |||
380 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL); | ||
422 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 381 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
423 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 382 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
@@ -437,10 +396,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
437 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); | 396 | GNUNET_CRYPTO_rsa_key_get_public(privkey2, &pubkey2); |
438 | GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); | 397 | GNUNET_CRYPTO_hash(&pubkey2, sizeof (pubkey), &zone2); |
439 | 398 | ||
440 | |||
441 | start_arm (cfgfile); | ||
442 | GNUNET_assert (arm != NULL); | ||
443 | |||
444 | nsh = GNUNET_NAMESTORE_connect (cfg); | 399 | nsh = GNUNET_NAMESTORE_connect (cfg); |
445 | GNUNET_break (NULL != nsh); | 400 | GNUNET_break (NULL != nsh); |
446 | 401 | ||
@@ -467,35 +422,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
467 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); | 422 | GNUNET_NAMESTORE_record_put (nsh, &pubkey2, s_name_3, GNUNET_TIME_UNIT_FOREVER_ABS, 1, s_rd_3, sig_3, &put_cont, NULL); |
468 | } | 423 | } |
469 | 424 | ||
470 | static int | ||
471 | check () | ||
472 | { | ||
473 | static char *const argv[] = { "test_namestore_api_zone_iteration", | ||
474 | "-c", | ||
475 | "test_namestore_api.conf", | ||
476 | #if VERBOSE | ||
477 | "-L", "DEBUG", | ||
478 | #endif | ||
479 | NULL | ||
480 | }; | ||
481 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
482 | GNUNET_GETOPT_OPTION_END | ||
483 | }; | ||
484 | |||
485 | res = 1; | ||
486 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test_namestore_api_zone_iteration", | ||
487 | "nohelp", options, &run, &res); | ||
488 | return res; | ||
489 | } | ||
490 | 425 | ||
491 | int | 426 | int |
492 | main (int argc, char *argv[]) | 427 | main (int argc, char *argv[]) |
493 | { | 428 | { |
494 | int ret; | 429 | res = 1; |
495 | 430 | if (0 != | |
496 | ret = check (); | 431 | GNUNET_TESTING_service_run ("test-namestore-api-zone-iteration-stop", |
497 | 432 | "namestore", | |
498 | return ret; | 433 | "test_namestore_api.conf", |
434 | &run, | ||
435 | NULL)) | ||
436 | return 1; | ||
437 | return res; | ||
499 | } | 438 | } |
500 | 439 | ||
501 | /* end of test_namestore_api_zone_iteration.c */ | 440 | |
441 | /* end of test_namestore_api_zone_iteration_stop.c */ | ||
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c index 6efbaf534..e5db28165 100644 --- a/src/namestore/test_namestore_api_zone_to_name.c +++ b/src/namestore/test_namestore_api_zone_to_name.c | |||
@@ -24,63 +24,41 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
26 | #include "gnunet_namestore_service.h" | 26 | #include "gnunet_namestore_service.h" |
27 | #include "gnunet_testing_lib-new.h" | ||
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_signatures.h" | 29 | #include "gnunet_signatures.h" |
29 | 30 | ||
30 | #define VERBOSE GNUNET_NO | ||
31 | |||
32 | #define RECORDS 5 | 31 | #define RECORDS 5 |
32 | |||
33 | #define TEST_RECORD_TYPE 1234 | 33 | #define TEST_RECORD_TYPE 1234 |
34 | |||
34 | #define TEST_RECORD_DATALEN 123 | 35 | #define TEST_RECORD_DATALEN 123 |
36 | |||
35 | #define TEST_RECORD_DATA 'a' | 37 | #define TEST_RECORD_DATA 'a' |
36 | 38 | ||
37 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
38 | 40 | ||
41 | |||
39 | static struct GNUNET_NAMESTORE_Handle * nsh; | 42 | static struct GNUNET_NAMESTORE_Handle * nsh; |
40 | 43 | ||
41 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; | 44 | static GNUNET_SCHEDULER_TaskIdentifier endbadly_task; |
42 | static struct GNUNET_OS_Process *arm; | ||
43 | 45 | ||
44 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; | 46 | static struct GNUNET_CRYPTO_RsaPrivateKey * privkey; |
47 | |||
45 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; | 48 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey; |
46 | 49 | ||
47 | struct GNUNET_TIME_Absolute expire; | 50 | static struct GNUNET_TIME_Absolute expire; |
48 | 51 | ||
49 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; | 52 | static struct GNUNET_CRYPTO_ShortHashCode s_zone; |
53 | |||
50 | static struct GNUNET_CRYPTO_ShortHashCode s_zone_value; | 54 | static struct GNUNET_CRYPTO_ShortHashCode s_zone_value; |
51 | 55 | ||
52 | char * s_name; | 56 | static char * s_name; |
53 | 57 | ||
54 | struct GNUNET_NAMESTORE_RecordData *s_rd; | 58 | static struct GNUNET_CRYPTO_RsaSignature *s_signature; |
55 | struct GNUNET_CRYPTO_RsaSignature *s_signature; | ||
56 | 59 | ||
57 | static int res; | 60 | static int res; |
58 | 61 | ||
59 | static void | ||
60 | start_arm (const char *cfgname) | ||
61 | { | ||
62 | arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", | ||
63 | "gnunet-service-arm", "-c", cfgname, | ||
64 | #if VERBOSE_PEERS | ||
65 | "-L", "DEBUG", | ||
66 | #else | ||
67 | "-L", "ERROR", | ||
68 | #endif | ||
69 | NULL); | ||
70 | } | ||
71 | |||
72 | static void | ||
73 | stop_arm () | ||
74 | { | ||
75 | if (NULL != arm) | ||
76 | { | ||
77 | if (0 != GNUNET_OS_process_kill (arm, SIGTERM)) | ||
78 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
79 | GNUNET_OS_process_wait (arm); | ||
80 | GNUNET_OS_process_destroy (arm); | ||
81 | arm = NULL; | ||
82 | } | ||
83 | } | ||
84 | 62 | ||
85 | /** | 63 | /** |
86 | * Re-establish the connection to the service. | 64 | * Re-establish the connection to the service. |
@@ -94,14 +72,9 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
94 | if (nsh != NULL) | 72 | if (nsh != NULL) |
95 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 73 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
96 | nsh = NULL; | 74 | nsh = NULL; |
97 | |||
98 | if (privkey != NULL) | 75 | if (privkey != NULL) |
99 | GNUNET_CRYPTO_rsa_key_free (privkey); | 76 | GNUNET_CRYPTO_rsa_key_free (privkey); |
100 | privkey = NULL; | 77 | privkey = NULL; |
101 | |||
102 | if (NULL != arm) | ||
103 | stop_arm(); | ||
104 | |||
105 | res = 1; | 78 | res = 1; |
106 | } | 79 | } |
107 | 80 | ||
@@ -114,26 +87,23 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
114 | GNUNET_SCHEDULER_cancel (endbadly_task); | 87 | GNUNET_SCHEDULER_cancel (endbadly_task); |
115 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; | 88 | endbadly_task = GNUNET_SCHEDULER_NO_TASK; |
116 | } | 89 | } |
117 | |||
118 | if (privkey != NULL) | 90 | if (privkey != NULL) |
119 | GNUNET_CRYPTO_rsa_key_free (privkey); | 91 | GNUNET_CRYPTO_rsa_key_free (privkey); |
120 | privkey = NULL; | 92 | privkey = NULL; |
121 | |||
122 | if (nsh != NULL) | 93 | if (nsh != NULL) |
123 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 94 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
124 | nsh = NULL; | 95 | nsh = NULL; |
125 | |||
126 | if (NULL != arm) | ||
127 | stop_arm(); | ||
128 | } | 96 | } |
129 | 97 | ||
130 | void zone_to_name_proc (void *cls, | 98 | |
131 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 99 | static void |
132 | struct GNUNET_TIME_Absolute expire, | 100 | zone_to_name_proc (void *cls, |
133 | const char *n, | 101 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
134 | unsigned int rd_count, | 102 | struct GNUNET_TIME_Absolute expire, |
135 | const struct GNUNET_NAMESTORE_RecordData *rd, | 103 | const char *n, |
136 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 104 | unsigned int rd_count, |
105 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
106 | const struct GNUNET_CRYPTO_RsaSignature *signature) | ||
137 | { | 107 | { |
138 | int fail = GNUNET_NO; | 108 | int fail = GNUNET_NO; |
139 | 109 | ||
@@ -169,26 +139,7 @@ void zone_to_name_proc (void *cls, | |||
169 | } | 139 | } |
170 | 140 | ||
171 | 141 | ||
172 | void | 142 | static void |
173 | delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
174 | { | ||
175 | char *afsdir; | ||
176 | |||
177 | if (GNUNET_OK == | ||
178 | GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite", | ||
179 | "FILENAME", &afsdir)) | ||
180 | { | ||
181 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
182 | if (GNUNET_OK == GNUNET_DISK_file_test (afsdir)) | ||
183 | if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir)) | ||
184 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir); | ||
185 | GNUNET_free (afsdir); | ||
186 | } | ||
187 | |||
188 | } | ||
189 | |||
190 | |||
191 | void | ||
192 | put_cont (void *cls, int32_t success, const char *emsg) | 143 | put_cont (void *cls, int32_t success, const char *emsg) |
193 | { | 144 | { |
194 | char *name = cls; | 145 | char *name = cls; |
@@ -209,16 +160,13 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
209 | } | 160 | } |
210 | } | 161 | } |
211 | 162 | ||
163 | |||
212 | static void | 164 | static void |
213 | run (void *cls, char *const *args, const char *cfgfile, | 165 | run (void *cls, |
214 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 166 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
215 | { | 167 | { |
216 | delete_existing_db(cfg); | ||
217 | |||
218 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); | 168 | endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,endbadly, NULL); |
219 | GNUNET_asprintf(&s_name, "dummy"); | 169 | GNUNET_asprintf(&s_name, "dummy"); |
220 | |||
221 | |||
222 | /* load privat key */ | 170 | /* load privat key */ |
223 | char *hostkey_file; | 171 | char *hostkey_file; |
224 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 172 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, |
@@ -241,10 +189,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
241 | rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode); | 189 | rd.data_size = sizeof (struct GNUNET_CRYPTO_ShortHashCode); |
242 | rd.data = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | 190 | rd.data = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_ShortHashCode)); |
243 | memcpy ((char *) rd.data, &s_zone_value, sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | 191 | memcpy ((char *) rd.data, &s_zone_value, sizeof (struct GNUNET_CRYPTO_ShortHashCode)); |
244 | |||
245 | start_arm (cfgfile); | ||
246 | GNUNET_assert (arm != NULL); | ||
247 | |||
248 | nsh = GNUNET_NAMESTORE_connect (cfg); | 192 | nsh = GNUNET_NAMESTORE_connect (cfg); |
249 | GNUNET_break (NULL != nsh); | 193 | GNUNET_break (NULL != nsh); |
250 | 194 | ||
@@ -255,34 +199,20 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
255 | GNUNET_free ((void *) rd.data); | 199 | GNUNET_free ((void *) rd.data); |
256 | } | 200 | } |
257 | 201 | ||
258 | static int | ||
259 | check () | ||
260 | { | ||
261 | static char *const argv[] = { "test-namestore-api", | ||
262 | "-c", | ||
263 | "test_namestore_api.conf", | ||
264 | #if VERBOSE | ||
265 | "-L", "DEBUG", | ||
266 | #endif | ||
267 | NULL | ||
268 | }; | ||
269 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
270 | GNUNET_GETOPT_OPTION_END | ||
271 | }; | ||
272 | 202 | ||
273 | res = 1; | ||
274 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
275 | "nohelp", options, &run, &res); | ||
276 | return res; | ||
277 | } | ||
278 | 203 | ||
279 | int | 204 | int |
280 | main (int argc, char *argv[]) | 205 | main (int argc, char *argv[]) |
281 | { | 206 | { |
282 | int ret; | 207 | res = 1; |
283 | 208 | if (0 != | |
284 | ret = check (); | 209 | GNUNET_TESTING_service_run ("test-namestore-api-zone-to-name", |
285 | return ret; | 210 | "namestore", |
211 | "test_namestore_api.conf", | ||
212 | &run, | ||
213 | NULL)) | ||
214 | return 1; | ||
215 | return res; | ||
286 | } | 216 | } |
287 | 217 | ||
288 | /* end of test_namestore_api.c */ | 218 | /* end of test_namestore_api_zone_to_name.c */ |
diff --git a/src/namestore/test_namestore_record_serialization.c b/src/namestore/test_namestore_record_serialization.c index 5e952539b..48560aee9 100644 --- a/src/namestore/test_namestore_record_serialization.c +++ b/src/namestore/test_namestore_record_serialization.c | |||
@@ -32,6 +32,7 @@ | |||
32 | 32 | ||
33 | static int res; | 33 | static int res; |
34 | 34 | ||
35 | |||
35 | static void | 36 | static void |
36 | run (void *cls, char *const *args, const char *cfgfile, | 37 | run (void *cls, char *const *args, const char *cfgfile, |
37 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 38 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -128,9 +129,6 @@ check () | |||
128 | static char *const argv[] = { "test_namestore_record_serialization", | 129 | static char *const argv[] = { "test_namestore_record_serialization", |
129 | "-c", | 130 | "-c", |
130 | "test_namestore_api.conf", | 131 | "test_namestore_api.conf", |
131 | #if VERBOSE | ||
132 | "-L", "DEBUG", | ||
133 | #endif | ||
134 | NULL | 132 | NULL |
135 | }; | 133 | }; |
136 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 134 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |