aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/namestore/test_hostkeybin827 -> 0 bytes
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c10
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c136
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c16
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c142
5 files changed, 90 insertions, 214 deletions
diff --git a/src/namestore/test_hostkey b/src/namestore/test_hostkey
index 81f461e7d..e69de29bb 100644
--- a/src/namestore/test_hostkey
+++ b/src/namestore/test_hostkey
Binary files differ
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index f6ec01ffc..64bfb6949 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -376,6 +376,9 @@ run (void *cls,
376} 376}
377 377
378 378
379#include "test_common.c"
380
381
379int 382int
380main (int argc, 383main (int argc,
381 char *argv[]) 384 char *argv[])
@@ -383,13 +386,8 @@ main (int argc,
383 const char *plugin_name; 386 const char *plugin_name;
384 char *cfg_name; 387 char *cfg_name;
385 388
386 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 389 SETUP_CFG (plugin_name, cfg_name);
387 GNUNET_asprintf (&cfg_name,
388 "test_namestore_api_%s.conf",
389 plugin_name);
390 res = 1; 390 res = 1;
391 GNUNET_DISK_purge_cfg_dir (cfg_name,
392 "GNUNET_TEST_HOME");
393 if (0 != 391 if (0 !=
394 GNUNET_TESTING_peer_run ("test-namestore-api-monitoring-existing", 392 GNUNET_TESTING_peer_run ("test-namestore-api-monitoring-existing",
395 cfg_name, 393 cfg_name,
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index 088422ca3..9df6c98cc 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -37,8 +37,6 @@
37 37
38static struct GNUNET_NAMESTORE_Handle * nsh; 38static struct GNUNET_NAMESTORE_Handle * nsh;
39 39
40static struct GNUNET_SCHEDULER_Task * endbadly_task;
41
42static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; 40static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey;
43 41
44static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey2; 42static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey2;
@@ -71,7 +69,7 @@ static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
71 * @param tc scheduler context 69 * @param tc scheduler context
72 */ 70 */
73static void 71static void
74endbadly (void *cls) 72end (void *cls)
75{ 73{
76 if (NULL != zi) 74 if (NULL != zi)
77 { 75 {
@@ -83,9 +81,9 @@ endbadly (void *cls)
83 GNUNET_NAMESTORE_disconnect (nsh); 81 GNUNET_NAMESTORE_disconnect (nsh);
84 nsh = NULL; 82 nsh = NULL;
85 } 83 }
86 GNUNET_free_non_null(s_name_1); 84 GNUNET_free_non_null (s_name_1);
87 GNUNET_free_non_null(s_name_2); 85 GNUNET_free_non_null (s_name_2);
88 GNUNET_free_non_null(s_name_3); 86 GNUNET_free_non_null (s_name_3);
89 87
90 if (s_rd_1 != NULL) 88 if (s_rd_1 != NULL)
91 { 89 {
@@ -104,99 +102,50 @@ endbadly (void *cls)
104 } 102 }
105 103
106 if (privkey != NULL) 104 if (privkey != NULL)
107 GNUNET_free (privkey);
108 privkey = NULL;
109
110 if (privkey2 != NULL)
111 GNUNET_free (privkey2);
112 privkey2 = NULL;
113 res = 1;
114}
115
116
117static void
118end (void *cls)
119{
120 if (NULL != zi)
121 { 105 {
122 GNUNET_NAMESTORE_zone_iteration_stop (zi);
123 zi = NULL;
124 }
125 if (endbadly_task != NULL)
126 {
127 GNUNET_SCHEDULER_cancel (endbadly_task);
128 endbadly_task = NULL;
129 }
130
131 if (privkey != NULL)
132 GNUNET_free (privkey); 106 GNUNET_free (privkey);
133 privkey = NULL; 107 privkey = NULL;
134
135 if (privkey2 != NULL)
136 GNUNET_free (privkey2);
137 privkey2 = NULL;
138
139 GNUNET_free (s_name_1);
140 GNUNET_free (s_name_2);
141 GNUNET_free (s_name_3);
142 if (s_rd_1 != NULL)
143 {
144 GNUNET_free ((void *)s_rd_1->data);
145 GNUNET_free (s_rd_1);
146 } 108 }
147 if (s_rd_2 != NULL) 109 if (privkey2 != NULL)
148 {
149 GNUNET_free ((void *)s_rd_2->data);
150 GNUNET_free (s_rd_2);
151 }
152 if (s_rd_3 != NULL)
153 { 110 {
154 GNUNET_free ((void *)s_rd_3->data); 111 GNUNET_free (privkey2);
155 GNUNET_free (s_rd_3); 112 privkey2 = NULL;
156 } 113 }
157 if (nsh != NULL)
158 GNUNET_NAMESTORE_disconnect (nsh);
159 nsh = NULL;
160} 114}
161 115
162 116
163static int 117static int
164check_zone_1 (const char *label, unsigned int rd_count, 118check_zone_1 (const char *label, unsigned int rd_count,
165 const struct GNUNET_GNSRECORD_Data *rd) 119 const struct GNUNET_GNSRECORD_Data *rd)
166{ 120{
167 int failed = GNUNET_NO; 121 for (unsigned int c = 0; c< rd_count ; c++)
168 int c;
169 for (c = 0; c< rd_count ; c++)
170 { 122 {
171 if (rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) 123 if ( (rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) &&
172 if (0 != strcmp (rd[c].data, ZONE_NICK_1)) 124 (0 != strcmp (rd[c].data, ZONE_NICK_1)) )
173 { 125 {
174 GNUNET_break (0); 126 GNUNET_break (0);
175 return GNUNET_YES; 127 return GNUNET_YES;
176 } 128 }
177 } 129 }
178 return failed; 130 return GNUNET_NO;
179} 131}
180 132
133
181static int 134static int
182check_zone_2 (const char *label, 135check_zone_2 (const char *label,
183 unsigned int rd_count, 136 unsigned int rd_count,
184 const struct GNUNET_GNSRECORD_Data *rd) 137 const struct GNUNET_GNSRECORD_Data *rd)
185{ 138{
186 int failed = GNUNET_NO; 139 for (unsigned int c = 0; c< rd_count ; c++)
187 int c;
188
189 for (c = 0; c< rd_count ; c++)
190 { 140 {
191 if (rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) 141 if ( (rd[c].record_type == GNUNET_GNSRECORD_TYPE_NICK) &&
192 if (0 != strcmp (rd[c].data, ZONE_NICK_2)) 142 (0 != strcmp (rd[c].data, ZONE_NICK_2)) )
193 { 143 {
194 GNUNET_break (0); 144 GNUNET_break (0);
195 return GNUNET_YES; 145 return GNUNET_YES;
196 } 146 }
197 } 147 }
198 148 return GNUNET_NO;
199 return failed;
200} 149}
201 150
202 151
@@ -208,7 +157,7 @@ zone_proc_end (void *cls)
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
209 "Received last result, iteration done after receing %u results\n", 158 "Received last result, iteration done after receing %u results\n",
210 returned_records); 159 returned_records);
211 GNUNET_SCHEDULER_add_now (&end, NULL); 160 GNUNET_SCHEDULER_shutdown ();
212} 161}
213 162
214 163
@@ -254,7 +203,7 @@ zone_proc (void *cls,
254 { 203 {
255 GNUNET_break (0); 204 GNUNET_break (0);
256 res = 1; 205 res = 1;
257 GNUNET_SCHEDULER_add_now (&end, NULL); 206 GNUNET_SCHEDULER_shutdown ();
258 } 207 }
259} 208}
260 209
@@ -283,9 +232,7 @@ put_cont (void *cls,
283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", 232 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n",
284 emsg); 233 emsg);
285 GNUNET_break (0); 234 GNUNET_break (0);
286 if (NULL != endbadly_task) 235 GNUNET_SCHEDULER_shutdown ();
287 GNUNET_SCHEDULER_cancel (endbadly_task);
288 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
289 return; 236 return;
290 } 237 }
291 238
@@ -306,9 +253,7 @@ put_cont (void *cls,
306 { 253 {
307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); 254 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n");
308 GNUNET_break (0); 255 GNUNET_break (0);
309 if (NULL != endbadly_task) 256 GNUNET_SCHEDULER_shutdown ();
310 GNUNET_SCHEDULER_cancel (endbadly_task);
311 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
312 return; 257 return;
313 } 258 }
314 } 259 }
@@ -406,9 +351,7 @@ empty_zone_proc (void *cls,
406 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 351 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
407 _("Expected empty zone but received zone private key\n")); 352 _("Expected empty zone but received zone private key\n"));
408 GNUNET_break (0); 353 GNUNET_break (0);
409 if (endbadly_task != NULL) 354 GNUNET_SCHEDULER_shutdown ();
410 GNUNET_SCHEDULER_cancel (endbadly_task);
411 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
412 return; 355 return;
413 } 356 }
414 if ((NULL != label) || (NULL != rd) || (0 != rd_count)) 357 if ((NULL != label) || (NULL != rd) || (0 != rd_count))
@@ -416,9 +359,7 @@ empty_zone_proc (void *cls,
416 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 359 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
417 _("Expected no zone content but received data\n")); 360 _("Expected no zone content but received data\n"));
418 GNUNET_break (0); 361 GNUNET_break (0);
419 if (endbadly_task != NULL) 362 GNUNET_SCHEDULER_shutdown ();
420 GNUNET_SCHEDULER_cancel (endbadly_task);
421 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
422 return; 363 return;
423 } 364 }
424 GNUNET_assert (0); 365 GNUNET_assert (0);
@@ -454,12 +395,10 @@ run (void *cls,
454 const struct GNUNET_CONFIGURATION_Handle *cfg, 395 const struct GNUNET_CONFIGURATION_Handle *cfg,
455 struct GNUNET_TESTING_Peer *peer) 396 struct GNUNET_TESTING_Peer *peer)
456{ 397{
457 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
458 &endbadly,
459 NULL);
460 nsh = GNUNET_NAMESTORE_connect (cfg); 398 nsh = GNUNET_NAMESTORE_connect (cfg);
461 GNUNET_break (NULL != nsh); 399 GNUNET_break (NULL != nsh);
462 400 GNUNET_SCHEDULER_add_shutdown (&end,
401 NULL);
463 /* first, iterate over empty namestore */ 402 /* first, iterate over empty namestore */
464 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 403 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
465 NULL, 404 NULL,
@@ -474,8 +413,7 @@ run (void *cls,
474 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 413 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
475 "Failed to create zone iterator\n"); 414 "Failed to create zone iterator\n");
476 GNUNET_break (0); 415 GNUNET_break (0);
477 GNUNET_SCHEDULER_cancel (endbadly_task); 416 GNUNET_SCHEDULER_shutdown ();
478 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
479 } 417 }
480} 418}
481 419
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 0be9bab98..cbcd94cd5 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -98,9 +98,9 @@ end (void *cls)
98 GNUNET_free (privkey2); 98 GNUNET_free (privkey2);
99 privkey2 = NULL; 99 privkey2 = NULL;
100 } 100 }
101 GNUNET_free (s_name_1); 101 GNUNET_free_non_null (s_name_1);
102 GNUNET_free (s_name_2); 102 GNUNET_free_non_null (s_name_2);
103 GNUNET_free (s_name_3); 103 GNUNET_free_non_null (s_name_3);
104 if (s_rd_1 != NULL) 104 if (s_rd_1 != NULL)
105 { 105 {
106 GNUNET_free ((void *)s_rd_1->data); 106 GNUNET_free ((void *)s_rd_1->data);
@@ -429,19 +429,17 @@ run (void *cls,
429} 429}
430 430
431 431
432#include "test_common.c"
433
434
432int 435int
433main (int argc, char *argv[]) 436main (int argc, char *argv[])
434{ 437{
435 const char *plugin_name; 438 const char *plugin_name;
436 char *cfg_name; 439 char *cfg_name;
437 440
438 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 441 SETUP_CFG (plugin_name, cfg_name);
439 GNUNET_asprintf (&cfg_name,
440 "test_namestore_api_%s.conf",
441 plugin_name);
442 res = 1; 442 res = 1;
443 GNUNET_DISK_purge_cfg_dir (cfg_name,
444 "GNUNET_TEST_HOME");
445 if (0 != 443 if (0 !=
446 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-specific-zone", 444 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-specific-zone",
447 cfg_name, 445 cfg_name,
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index 5b54e100e..38da3136c 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -18,7 +18,7 @@
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19*/
20/** 20/**
21 * @file namestore/test_namestore_api_zone_iteration.c 21 * @file namestore/test_namestore_api_zone_iteration_stop.c
22 * @brief testcase for zone iteration functionality: stop iterating of zones 22 * @brief testcase for zone iteration functionality: stop iterating of zones
23 */ 23 */
24#include "platform.h" 24#include "platform.h"
@@ -34,8 +34,6 @@
34 34
35static struct GNUNET_NAMESTORE_Handle * nsh; 35static struct GNUNET_NAMESTORE_Handle * nsh;
36 36
37static struct GNUNET_SCHEDULER_Task * endbadly_task;
38
39static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; 37static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey;
40 38
41static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey2; 39static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey2;
@@ -59,29 +57,27 @@ static char * s_name_3;
59static struct GNUNET_GNSRECORD_Data *s_rd_3; 57static struct GNUNET_GNSRECORD_Data *s_rd_3;
60 58
61 59
62
63/** 60/**
64 * Re-establish the connection to the service. 61 * Re-establish the connection to the service.
65 * 62 *
66 * @param cls handle to use to re-connect. 63 * @param cls handle to use to re-connect.
67 */ 64 */
68static void 65static void
69endbadly (void *cls) 66end (void *cls)
70{ 67{
71 if (NULL != zi) 68 if (NULL != zi)
72 { 69 {
73 GNUNET_NAMESTORE_zone_iteration_stop (zi); 70 GNUNET_NAMESTORE_zone_iteration_stop (zi);
74 zi = NULL; 71 zi = NULL;
75 } 72 }
76
77 if (nsh != NULL) 73 if (nsh != NULL)
74 {
78 GNUNET_NAMESTORE_disconnect (nsh); 75 GNUNET_NAMESTORE_disconnect (nsh);
79 nsh = NULL; 76 nsh = NULL;
80 77 }
81 GNUNET_free_non_null(s_name_1); 78 GNUNET_free_non_null (s_name_1);
82 GNUNET_free_non_null(s_name_2); 79 GNUNET_free_non_null (s_name_2);
83 GNUNET_free_non_null(s_name_3); 80 GNUNET_free_non_null (s_name_3);
84
85 if (s_rd_1 != NULL) 81 if (s_rd_1 != NULL)
86 { 82 {
87 GNUNET_free ((void *)s_rd_1->data); 83 GNUNET_free ((void *)s_rd_1->data);
@@ -97,62 +93,23 @@ endbadly (void *cls)
97 GNUNET_free ((void *)s_rd_3->data); 93 GNUNET_free ((void *)s_rd_3->data);
98 GNUNET_free (s_rd_3); 94 GNUNET_free (s_rd_3);
99 } 95 }
100
101 if (privkey != NULL) 96 if (privkey != NULL)
97 {
102 GNUNET_free (privkey); 98 GNUNET_free (privkey);
103 privkey = NULL; 99 privkey = NULL;
104 100 }
105 if (privkey2 != NULL) 101 if (privkey2 != NULL)
102 {
106 GNUNET_free (privkey2); 103 GNUNET_free (privkey2);
107 privkey2 = NULL; 104 privkey2 = NULL;
108 res = 1; 105 }
109} 106}
110 107
111 108
112static void 109static void
113end (void *cls) 110delayed_end (void *cls)
114{ 111{
115 if (NULL != zi) 112 GNUNET_SCHEDULER_shutdown ();
116 {
117 GNUNET_NAMESTORE_zone_iteration_stop (zi);
118 zi = NULL;
119 }
120
121 if (endbadly_task != NULL)
122 {
123 GNUNET_SCHEDULER_cancel (endbadly_task);
124 endbadly_task = NULL;
125 }
126
127 if (privkey != NULL)
128 GNUNET_free (privkey);
129 privkey = NULL;
130
131 if (privkey2 != NULL)
132 GNUNET_free (privkey2);
133 privkey2 = NULL;
134
135 GNUNET_free (s_name_1);
136 GNUNET_free (s_name_2);
137 GNUNET_free (s_name_3);
138 if (s_rd_1 != NULL)
139 {
140 GNUNET_free ((void *)s_rd_1->data);
141 GNUNET_free (s_rd_1);
142 }
143 if (s_rd_2 != NULL)
144 {
145 GNUNET_free ((void *)s_rd_2->data);
146 GNUNET_free (s_rd_2);
147 }
148 if (s_rd_3 != NULL)
149 {
150 GNUNET_free ((void *)s_rd_3->data);
151 GNUNET_free (s_rd_3);
152 }
153 if (nsh != NULL)
154 GNUNET_NAMESTORE_disconnect (nsh);
155 nsh = NULL;
156} 113}
157 114
158 115
@@ -257,16 +214,13 @@ zone_proc (void *cls,
257 if (1 == returned_records) 214 if (1 == returned_records)
258 { 215 {
259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 216 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
260 "Telling namestore to stop zone iteration\n"); 217 "Telling namestore to stop zone iteration\n");
261 GNUNET_NAMESTORE_zone_iteration_stop (zi); 218 GNUNET_NAMESTORE_zone_iteration_stop (zi);
262 zi = NULL; 219 zi = NULL;
263 if (NULL != endbadly_task)
264 {
265 GNUNET_SCHEDULER_cancel (endbadly_task);
266 endbadly_task = NULL;
267 }
268 res = 0; 220 res = 0;
269 GNUNET_SCHEDULER_add_delayed (WAIT, &end, NULL); 221 GNUNET_SCHEDULER_add_delayed (WAIT,
222 &delayed_end,
223 NULL);
270 return; 224 return;
271 } 225 }
272 returned_records ++; 226 returned_records ++;
@@ -278,7 +232,7 @@ zone_proc (void *cls,
278 else 232 else
279 { 233 {
280 GNUNET_break (0); 234 GNUNET_break (0);
281 GNUNET_SCHEDULER_add_now (&end, NULL); 235 GNUNET_SCHEDULER_shutdown ();
282 } 236 }
283} 237}
284 238
@@ -314,9 +268,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
314 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n", 268 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to created records: `%s'\n",
315 emsg); 269 emsg);
316 GNUNET_break (0); 270 GNUNET_break (0);
317 if (NULL != endbadly_task) 271 GNUNET_SCHEDULER_shutdown ();
318 GNUNET_SCHEDULER_cancel (endbadly_task);
319 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
320 return; 272 return;
321 } 273 }
322 274
@@ -339,9 +291,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
339 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 291 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
340 "Failed to create zone iterator\n"); 292 "Failed to create zone iterator\n");
341 GNUNET_break (0); 293 GNUNET_break (0);
342 if (NULL != endbadly_task) 294 GNUNET_SCHEDULER_shutdown ();
343 GNUNET_SCHEDULER_cancel (endbadly_task);
344 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
345 return; 295 return;
346 } 296 }
347 } 297 }
@@ -387,9 +337,7 @@ empty_zone_proc (void *cls,
387 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 337 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
388 _("Expected empty zone but received zone private key\n")); 338 _("Expected empty zone but received zone private key\n"));
389 GNUNET_break (0); 339 GNUNET_break (0);
390 if (endbadly_task != NULL) 340 GNUNET_SCHEDULER_shutdown ();
391 GNUNET_SCHEDULER_cancel (endbadly_task);
392 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
393 return; 341 return;
394 } 342 }
395 if ((NULL != label) || (NULL != rd) || (0 != rd_count)) 343 if ((NULL != label) || (NULL != rd) || (0 != rd_count))
@@ -397,9 +345,7 @@ empty_zone_proc (void *cls,
397 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 345 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
398 _("Expected no zone content but received data\n")); 346 _("Expected no zone content but received data\n"));
399 GNUNET_break (0); 347 GNUNET_break (0);
400 if (endbadly_task != NULL) 348 GNUNET_SCHEDULER_shutdown ();
401 GNUNET_SCHEDULER_cancel (endbadly_task);
402 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
403 return; 349 return;
404 } 350 }
405 GNUNET_assert (0); 351 GNUNET_assert (0);
@@ -476,43 +422,39 @@ run (void *cls,
476 const struct GNUNET_CONFIGURATION_Handle *cfg, 422 const struct GNUNET_CONFIGURATION_Handle *cfg,
477 struct GNUNET_TESTING_Peer *peer) 423 struct GNUNET_TESTING_Peer *peer)
478{ 424{
479 endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
480 &endbadly,
481 NULL);
482 nsh = GNUNET_NAMESTORE_connect (cfg); 425 nsh = GNUNET_NAMESTORE_connect (cfg);
483 GNUNET_break (NULL != nsh); 426 GNUNET_break (NULL != nsh);
427 GNUNET_SCHEDULER_add_shutdown (&end,
428 NULL);
484 /* first, iterate over empty namestore */ 429 /* first, iterate over empty namestore */
485 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 430 zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
486 NULL, 431 NULL,
487 &fail_cb, 432 &fail_cb,
488 NULL, 433 NULL,
489 &empty_zone_proc, 434 &empty_zone_proc,
490 nsh, 435 nsh,
491 &empty_zone_proc_end, 436 &empty_zone_proc_end,
492 nsh); 437 nsh);
493 if (NULL == zi) 438 if (NULL == zi)
494 { 439 {
495 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 440 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
496 "Failed to create zone iterator\n"); 441 "Failed to create zone iterator\n");
497 GNUNET_break (0); 442 GNUNET_break (0);
498 GNUNET_SCHEDULER_cancel (endbadly_task); 443 GNUNET_SCHEDULER_shutdown ();
499 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
500 } 444 }
501} 445}
502 446
503 447
448#include "test_common.c"
449
450
504int 451int
505main (int argc, char *argv[]) 452main (int argc, char *argv[])
506{ 453{
507 const char *plugin_name; 454 const char *plugin_name;
508 char *cfg_name; 455 char *cfg_name;
509 456
510 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]); 457 SETUP_CFG (plugin_name, cfg_name);
511 GNUNET_asprintf (&cfg_name,
512 "test_namestore_api_%s.conf",
513 plugin_name);
514 GNUNET_DISK_purge_cfg_dir (cfg_name,
515 "GNUNET_TEST_HOME");
516 res = 1; 458 res = 1;
517 if (0 != 459 if (0 !=
518 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-stop", 460 GNUNET_TESTING_peer_run ("test-namestore-api-zone-iteration-stop",