diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-26 18:19:15 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-26 18:19:15 +0000 |
commit | 27ed8fcbc85a361864948edb517d47804c2b5a56 (patch) | |
tree | 01626713ea5b2ead4691f13eb66a1574b1c0c7fd /src/datastore/test_plugin_datastore.c | |
parent | b6c71d97d2a4bb3cb0e0e0ac1cd2a4e145748cc6 (diff) | |
download | gnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.tar.gz gnunet-27ed8fcbc85a361864948edb517d47804c2b5a56.zip |
datastore and fs fixes from Easter
Diffstat (limited to 'src/datastore/test_plugin_datastore.c')
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 89 |
1 files changed, 35 insertions, 54 deletions
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index d38e908ac..f0961f51e 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -65,6 +65,7 @@ struct CpsRunContext | |||
65 | enum RunPhase phase; | 65 | enum RunPhase phase; |
66 | unsigned int cnt; | 66 | unsigned int cnt; |
67 | unsigned int i; | 67 | unsigned int i; |
68 | uint64_t offset; | ||
68 | }; | 69 | }; |
69 | 70 | ||
70 | 71 | ||
@@ -120,6 +121,11 @@ put_value (struct GNUNET_DATASTORE_PluginFunctions * api, | |||
120 | value[0] = k; | 121 | value[0] = k; |
121 | msg = NULL; | 122 | msg = NULL; |
122 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); | 123 | prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100); |
124 | #if VERBOSE | ||
125 | fprintf (stderr, | ||
126 | "putting type %u, anon %u under key %s\n", | ||
127 | i+1, i, GNUNET_h2s (&key)); | ||
128 | #endif | ||
123 | if (GNUNET_OK != api->put (api->cls, | 129 | if (GNUNET_OK != api->put (api->cls, |
124 | &key, | 130 | &key, |
125 | size, | 131 | size, |
@@ -149,9 +155,11 @@ test (void *cls, | |||
149 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 155 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
150 | 156 | ||
151 | 157 | ||
158 | static uint64_t guid; | ||
159 | |||
160 | |||
152 | static int | 161 | static int |
153 | iterate_one_shot (void *cls, | 162 | iterate_one_shot (void *cls, |
154 | void *next_cls, | ||
155 | const GNUNET_HashCode * key, | 163 | const GNUNET_HashCode * key, |
156 | uint32_t size, | 164 | uint32_t size, |
157 | const void *data, | 165 | const void *data, |
@@ -164,57 +172,21 @@ iterate_one_shot (void *cls, | |||
164 | { | 172 | { |
165 | struct CpsRunContext *crc = cls; | 173 | struct CpsRunContext *crc = cls; |
166 | 174 | ||
167 | GNUNET_assert (NULL == next_cls); | ||
168 | GNUNET_assert (key != NULL); | 175 | GNUNET_assert (key != NULL); |
176 | guid = uid; | ||
169 | crc->phase++; | 177 | crc->phase++; |
170 | #if VERBOSE | 178 | #if VERBOSE |
171 | fprintf (stderr, | 179 | fprintf (stderr, |
172 | "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | 180 | "Found result type=%u, priority=%u, size=%u, expire=%llu, key %s\n", |
173 | type, priority, size, | 181 | type, priority, size, |
174 | (unsigned long long) expiration.abs_value); | 182 | (unsigned long long) expiration.abs_value, |
183 | GNUNET_h2s (key)); | ||
175 | #endif | 184 | #endif |
176 | GNUNET_SCHEDULER_add_now (&test, crc); | 185 | GNUNET_SCHEDULER_add_now (&test, crc); |
177 | return GNUNET_OK; | 186 | return GNUNET_OK; |
178 | } | 187 | } |
179 | 188 | ||
180 | 189 | ||
181 | static uint64_t guid; | ||
182 | |||
183 | static int | ||
184 | iterate_with_next (void *cls, | ||
185 | void *next_cls, | ||
186 | const GNUNET_HashCode * key, | ||
187 | uint32_t size, | ||
188 | const void *data, | ||
189 | enum GNUNET_BLOCK_Type type, | ||
190 | uint32_t priority, | ||
191 | uint32_t anonymity, | ||
192 | struct GNUNET_TIME_Absolute | ||
193 | expiration, | ||
194 | uint64_t uid) | ||
195 | { | ||
196 | struct CpsRunContext *crc = cls; | ||
197 | |||
198 | if (key == NULL) | ||
199 | { | ||
200 | crc->phase++; | ||
201 | GNUNET_SCHEDULER_add_now (&test, crc); | ||
202 | return GNUNET_OK; | ||
203 | } | ||
204 | guid = uid; | ||
205 | #if VERBOSE | ||
206 | fprintf (stderr, | ||
207 | "Found result type=%u, priority=%u, size=%u, expire=%llu\n", | ||
208 | type, priority, size, | ||
209 | (unsigned long long) expiration.abs_value); | ||
210 | #endif | ||
211 | crc->cnt++; | ||
212 | crc->api->next_request (next_cls, | ||
213 | GNUNET_NO); | ||
214 | return GNUNET_OK; | ||
215 | } | ||
216 | |||
217 | |||
218 | /** | 190 | /** |
219 | * Function called when the service shuts | 191 | * Function called when the service shuts |
220 | * down. Unloads our datastore plugin. | 192 | * down. Unloads our datastore plugin. |
@@ -274,12 +246,19 @@ test (void *cls, | |||
274 | 246 | ||
275 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 247 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
276 | { | 248 | { |
249 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
250 | "Test aborted.\n"); | ||
277 | crc->phase = RP_ERROR; | 251 | crc->phase = RP_ERROR; |
278 | ok = 1; | ||
279 | } | 252 | } |
253 | #if VERBOSE | ||
254 | fprintf (stderr, "In phase %d, iteration %u\n", | ||
255 | crc->phase, | ||
256 | crc->cnt); | ||
257 | #endif | ||
280 | switch (crc->phase) | 258 | switch (crc->phase) |
281 | { | 259 | { |
282 | case RP_ERROR: | 260 | case RP_ERROR: |
261 | ok = 1; | ||
283 | GNUNET_break (0); | 262 | GNUNET_break (0); |
284 | crc->api->drop (crc->api->cls); | 263 | crc->api->drop (crc->api->cls); |
285 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); | 264 | GNUNET_SCHEDULER_add_now (&cleaning_task, crc); |
@@ -289,7 +268,7 @@ test (void *cls, | |||
289 | for (j=0;j<PUT_10;j++) | 268 | for (j=0;j<PUT_10;j++) |
290 | { | 269 | { |
291 | put_value (crc->api, j, crc->i); | 270 | put_value (crc->api, j, crc->i); |
292 | cs = crc->api->get_size (crc->api->cls); | 271 | cs = crc->api->estimate_size (crc->api->cls); |
293 | GNUNET_assert (os < cs); | 272 | GNUNET_assert (os < cs); |
294 | os = cs; | 273 | os = cs; |
295 | } | 274 | } |
@@ -305,11 +284,12 @@ test (void *cls, | |||
305 | break; | 284 | break; |
306 | } | 285 | } |
307 | gen_key (5, &key); | 286 | gen_key (5, &key); |
308 | crc->api->get (crc->api->cls, | 287 | crc->api->get_key (crc->api->cls, |
309 | &key, NULL, | 288 | crc->offset++, |
310 | GNUNET_BLOCK_TYPE_ANY, | 289 | &key, NULL, |
311 | &iterate_with_next, | 290 | GNUNET_BLOCK_TYPE_ANY, |
312 | crc); | 291 | &iterate_one_shot, |
292 | crc); | ||
313 | break; | 293 | break; |
314 | case RP_UPDATE: | 294 | case RP_UPDATE: |
315 | GNUNET_assert (GNUNET_OK == | 295 | GNUNET_assert (GNUNET_OK == |
@@ -329,18 +309,19 @@ test (void *cls, | |||
329 | GNUNET_SCHEDULER_add_now (&test, crc); | 309 | GNUNET_SCHEDULER_add_now (&test, crc); |
330 | break; | 310 | break; |
331 | } | 311 | } |
332 | crc->api->iter_zero_anonymity (crc->api->cls, | 312 | crc->api->get_zero_anonymity (crc->api->cls, |
333 | 1, | 313 | 0, |
334 | &iterate_with_next, | 314 | 1, |
335 | crc); | 315 | &iterate_one_shot, |
316 | crc); | ||
336 | break; | 317 | break; |
337 | case RP_REPL_GET: | 318 | case RP_REPL_GET: |
338 | crc->api->replication_get (crc->api->cls, | 319 | crc->api->get_replication (crc->api->cls, |
339 | &iterate_one_shot, | 320 | &iterate_one_shot, |
340 | crc); | 321 | crc); |
341 | break; | 322 | break; |
342 | case RP_EXPI_GET: | 323 | case RP_EXPI_GET: |
343 | crc->api->expiration_get (crc->api->cls, | 324 | crc->api->get_expiration (crc->api->cls, |
344 | &iterate_one_shot, | 325 | &iterate_one_shot, |
345 | crc); | 326 | crc); |
346 | break; | 327 | break; |