diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 10:34:07 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-07 10:34:07 +0000 |
commit | 18d7b243b873410c7101d97bd8c9fabb36bdb404 (patch) | |
tree | 9feae8ee71f2a144938c0536afe9dd554bfd015e /src/namestore/test_namestore_api_zone_iteration_specific_zone.c | |
parent | 55656c4720d237f883bff2d54ad7365d0ecb793d (diff) | |
download | gnunet-18d7b243b873410c7101d97bd8c9fabb36bdb404.tar.gz gnunet-18d7b243b873410c7101d97bd8c9fabb36bdb404.zip |
- final zone iteration code
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration_specific_zone.c')
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_specific_zone.c | 47 |
1 files changed, 39 insertions, 8 deletions
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 7d98eefb0..7cdcea42a 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c | |||
@@ -18,8 +18,8 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file namestore/test_namestore_api_zone_iteration.c | 21 | * @file namestore/test_namestore_api_zone_iteration_specific_zone.c |
22 | * @brief testcase for namestore_api.c zone iteration functionality | 22 | * @brief testcase for zone iteration functionality: iterate of a specific zone |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_common.h" | 25 | #include "gnunet_common.h" |
@@ -46,6 +46,7 @@ static GNUNET_HashCode zone2; | |||
46 | 46 | ||
47 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; | 47 | static struct GNUNET_NAMESTORE_ZoneIterator *zi; |
48 | static int res; | 48 | static int res; |
49 | static int returned_records; | ||
49 | 50 | ||
50 | struct GNUNET_CRYPTO_RsaSignature *sig_1; | 51 | struct GNUNET_CRYPTO_RsaSignature *sig_1; |
51 | char * s_name_1; | 52 | char * s_name_1; |
@@ -106,8 +107,10 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
106 | 107 | ||
107 | GNUNET_free_non_null(sig_1); | 108 | GNUNET_free_non_null(sig_1); |
108 | GNUNET_free_non_null(sig_2); | 109 | GNUNET_free_non_null(sig_2); |
110 | GNUNET_free_non_null(sig_3); | ||
109 | GNUNET_free_non_null(s_name_1); | 111 | GNUNET_free_non_null(s_name_1); |
110 | GNUNET_free_non_null(s_name_2); | 112 | GNUNET_free_non_null(s_name_2); |
113 | GNUNET_free_non_null(s_name_3); | ||
111 | 114 | ||
112 | if (s_rd_1 != NULL) | 115 | if (s_rd_1 != NULL) |
113 | { | 116 | { |
@@ -119,11 +122,20 @@ endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
119 | GNUNET_free ((void *)s_rd_2->data); | 122 | GNUNET_free ((void *)s_rd_2->data); |
120 | GNUNET_free (s_rd_2); | 123 | GNUNET_free (s_rd_2); |
121 | } | 124 | } |
125 | if (s_rd_3 != NULL) | ||
126 | { | ||
127 | GNUNET_free ((void *)s_rd_3->data); | ||
128 | GNUNET_free (s_rd_3); | ||
129 | } | ||
122 | 130 | ||
123 | if (privkey != NULL) | 131 | if (privkey != NULL) |
124 | GNUNET_CRYPTO_rsa_key_free (privkey); | 132 | GNUNET_CRYPTO_rsa_key_free (privkey); |
125 | privkey = NULL; | 133 | privkey = NULL; |
126 | 134 | ||
135 | if (privkey2 != NULL) | ||
136 | GNUNET_CRYPTO_rsa_key_free (privkey2); | ||
137 | privkey2 = NULL; | ||
138 | |||
127 | if (NULL != arm) | 139 | if (NULL != arm) |
128 | stop_arm(); | 140 | stop_arm(); |
129 | 141 | ||
@@ -150,10 +162,16 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
150 | GNUNET_CRYPTO_rsa_key_free (privkey); | 162 | GNUNET_CRYPTO_rsa_key_free (privkey); |
151 | privkey = NULL; | 163 | privkey = NULL; |
152 | 164 | ||
165 | if (privkey2 != NULL) | ||
166 | GNUNET_CRYPTO_rsa_key_free (privkey2); | ||
167 | privkey2 = NULL; | ||
168 | |||
153 | GNUNET_free (sig_1); | 169 | GNUNET_free (sig_1); |
154 | GNUNET_free (sig_2); | 170 | GNUNET_free (sig_2); |
171 | GNUNET_free (sig_3); | ||
155 | GNUNET_free (s_name_1); | 172 | GNUNET_free (s_name_1); |
156 | GNUNET_free (s_name_2); | 173 | GNUNET_free (s_name_2); |
174 | GNUNET_free (s_name_3); | ||
157 | if (s_rd_1 != NULL) | 175 | if (s_rd_1 != NULL) |
158 | { | 176 | { |
159 | GNUNET_free ((void *)s_rd_1->data); | 177 | GNUNET_free ((void *)s_rd_1->data); |
@@ -164,6 +182,11 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
164 | GNUNET_free ((void *)s_rd_2->data); | 182 | GNUNET_free ((void *)s_rd_2->data); |
165 | GNUNET_free (s_rd_2); | 183 | GNUNET_free (s_rd_2); |
166 | } | 184 | } |
185 | if (s_rd_3 != NULL) | ||
186 | { | ||
187 | GNUNET_free ((void *)s_rd_3->data); | ||
188 | GNUNET_free (s_rd_3); | ||
189 | } | ||
167 | 190 | ||
168 | if (nsh != NULL) | 191 | if (nsh != NULL) |
169 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); | 192 | GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES); |
@@ -186,7 +209,13 @@ void zone_proc (void *cls, | |||
186 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_h2s (&zone)); | 209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for zone `%s'\n", GNUNET_h2s (&zone)); |
187 | if ((zone_key == NULL) && (name == NULL)) | 210 | if ((zone_key == NULL) && (name == NULL)) |
188 | { | 211 | { |
189 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received last result, iteration done\n"); | 212 | GNUNET_break (2 == returned_records); |
213 | if (2 == returned_records) | ||
214 | res = 0; | ||
215 | else | ||
216 | res = 1; | ||
217 | |||
218 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received last result, iteration done after %u records\n", returned_records); | ||
190 | GNUNET_SCHEDULER_add_now (&end, NULL); | 219 | GNUNET_SCHEDULER_add_now (&end, NULL); |
191 | } | 220 | } |
192 | else | 221 | else |
@@ -236,14 +265,15 @@ void zone_proc (void *cls, | |||
236 | } | 265 | } |
237 | else | 266 | else |
238 | { | 267 | { |
239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing result `%s'\n", name); | 268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Comparing result failed: got name `%s'\n", name); |
269 | res = 1; | ||
240 | GNUNET_break (0); | 270 | GNUNET_break (0); |
241 | GNUNET_SCHEDULER_add_now (&end, NULL); | 271 | GNUNET_SCHEDULER_add_now (&end, NULL); |
242 | } | 272 | } |
243 | 273 | ||
244 | if (failed == GNUNET_NO) | 274 | if (failed == GNUNET_NO) |
245 | { | 275 | { |
246 | res --; | 276 | returned_records ++; |
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Telling namestore to send the next result\n"); | 277 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Telling namestore to send the next result\n"); |
248 | GNUNET_NAMESTORE_zone_iterator_next (zi); | 278 | GNUNET_NAMESTORE_zone_iterator_next (zi); |
249 | } | 279 | } |
@@ -291,9 +321,10 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
291 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 321 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
292 | } | 322 | } |
293 | 323 | ||
294 | if (c == 2) | 324 | if (c == 3) |
295 | { | 325 | { |
296 | res = 2; | 326 | res = 1; |
327 | returned_records = 0; | ||
297 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over zone `%s'\n", | 328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over zone `%s'\n", |
298 | GNUNET_h2s(&zone)); | 329 | GNUNET_h2s(&zone)); |
299 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 330 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
@@ -408,4 +439,4 @@ main (int argc, char *argv[]) | |||
408 | return ret; | 439 | return ret; |
409 | } | 440 | } |
410 | 441 | ||
411 | /* end of test_namestore_api_zone_iteration.c */ | 442 | /* end of test_namestore_api_zone_iteration_specific_zone.c */ |