diff options
Diffstat (limited to 'src/datastore/test_datastore_api.c')
-rw-r--r-- | src/datastore/test_datastore_api.c | 280 |
1 files changed, 104 insertions, 176 deletions
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 39b7a1ae2..3dff4a588 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c | |||
@@ -134,8 +134,8 @@ struct CpsRunContext | |||
134 | }; | 134 | }; |
135 | 135 | ||
136 | 136 | ||
137 | static void | 137 | static void run_continuation (void *cls, |
138 | run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 138 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
139 | 139 | ||
140 | 140 | ||
141 | static void | 141 | static void |
@@ -146,14 +146,14 @@ check_success (void *cls, int success, const char *msg) | |||
146 | if (GNUNET_OK != success) | 146 | if (GNUNET_OK != success) |
147 | { | 147 | { |
148 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
149 | "Operation %d/%d not successfull: `%s'\n", | 149 | "Operation %d/%d not successfull: `%s'\n", crc->phase, crc->i, |
150 | crc->phase, crc->i, msg); | 150 | msg); |
151 | crc->phase = RP_ERROR; | 151 | crc->phase = RP_ERROR; |
152 | } | 152 | } |
153 | GNUNET_free_non_null (crc->data); | 153 | GNUNET_free_non_null (crc->data); |
154 | crc->data = NULL; | 154 | crc->data = NULL; |
155 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 155 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
156 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 156 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
@@ -163,40 +163,33 @@ get_reserved (void *cls, int success, const char *msg) | |||
163 | struct CpsRunContext *crc = cls; | 163 | struct CpsRunContext *crc = cls; |
164 | 164 | ||
165 | if (0 >= success) | 165 | if (0 >= success) |
166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error obtaining reservation: `%s'\n", |
167 | "Error obtaining reservation: `%s'\n", msg); | 167 | msg); |
168 | GNUNET_assert (0 < success); | 168 | GNUNET_assert (0 < success); |
169 | crc->rid = success; | 169 | crc->rid = success; |
170 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 170 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
171 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 171 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | static void | 175 | static void |
176 | check_value (void *cls, | 176 | check_value (void *cls, const GNUNET_HashCode * key, size_t size, |
177 | const GNUNET_HashCode * key, | 177 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
178 | size_t size, | 178 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
179 | const void *data, | 179 | uint64_t uid) |
180 | enum GNUNET_BLOCK_Type type, | ||
181 | uint32_t priority, | ||
182 | uint32_t anonymity, | ||
183 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
184 | { | 180 | { |
185 | struct CpsRunContext *crc = cls; | 181 | struct CpsRunContext *crc = cls; |
186 | int i; | 182 | int i; |
187 | 183 | ||
188 | i = crc->i; | 184 | i = crc->i; |
189 | #if 0 | 185 | #if 0 |
186 | fprintf (stderr, "Check value got `%s' of size %u, type %d, expire %llu\n", | ||
187 | GNUNET_h2s (key), (unsigned int) size, type, | ||
188 | (unsigned long long) expiration.abs_value); | ||
190 | fprintf (stderr, | 189 | fprintf (stderr, |
191 | "Check value got `%s' of size %u, type %d, expire %llu\n", | 190 | "Check value iteration %d wants size %u, type %d, expire %llu\n", i, |
192 | GNUNET_h2s (key), | 191 | (unsigned int) get_size (i), get_type (i), |
193 | (unsigned int) size, | 192 | (unsigned long long) get_expiration (i).abs_value); |
194 | type, (unsigned long long) expiration.abs_value); | ||
195 | fprintf (stderr, | ||
196 | "Check value iteration %d wants size %u, type %d, expire %llu\n", | ||
197 | i, | ||
198 | (unsigned int) get_size (i), | ||
199 | get_type (i), (unsigned long long) get_expiration (i).abs_value); | ||
200 | #endif | 193 | #endif |
201 | GNUNET_assert (size == get_size (i)); | 194 | GNUNET_assert (size == get_size (i)); |
202 | GNUNET_assert (0 == memcmp (data, get_data (i), size)); | 195 | GNUNET_assert (0 == memcmp (data, get_data (i), size)); |
@@ -210,20 +203,16 @@ check_value (void *cls, | |||
210 | crc->phase = RP_DEL; | 203 | crc->phase = RP_DEL; |
211 | crc->i = ITERATIONS; | 204 | crc->i = ITERATIONS; |
212 | } | 205 | } |
213 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 206 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
214 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 207 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
215 | } | 208 | } |
216 | 209 | ||
217 | 210 | ||
218 | static void | 211 | static void |
219 | delete_value (void *cls, | 212 | delete_value (void *cls, const GNUNET_HashCode * key, size_t size, |
220 | const GNUNET_HashCode * key, | 213 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
221 | size_t size, | 214 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
222 | const void *data, | 215 | uint64_t uid) |
223 | enum GNUNET_BLOCK_Type type, | ||
224 | uint32_t priority, | ||
225 | uint32_t anonymity, | ||
226 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
227 | { | 216 | { |
228 | struct CpsRunContext *crc = cls; | 217 | struct CpsRunContext *crc = cls; |
229 | 218 | ||
@@ -234,39 +223,31 @@ delete_value (void *cls, | |||
234 | crc->data = GNUNET_malloc (size); | 223 | crc->data = GNUNET_malloc (size); |
235 | memcpy (crc->data, data, size); | 224 | memcpy (crc->data, data, size); |
236 | crc->phase = RP_DO_DEL; | 225 | crc->phase = RP_DO_DEL; |
237 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 226 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
238 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 227 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
239 | } | 228 | } |
240 | 229 | ||
241 | 230 | ||
242 | static void | 231 | static void |
243 | check_nothing (void *cls, | 232 | check_nothing (void *cls, const GNUNET_HashCode * key, size_t size, |
244 | const GNUNET_HashCode * key, | 233 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
245 | size_t size, | 234 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
246 | const void *data, | 235 | uint64_t uid) |
247 | enum GNUNET_BLOCK_Type type, | ||
248 | uint32_t priority, | ||
249 | uint32_t anonymity, | ||
250 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
251 | { | 236 | { |
252 | struct CpsRunContext *crc = cls; | 237 | struct CpsRunContext *crc = cls; |
253 | 238 | ||
254 | GNUNET_assert (key == NULL); | 239 | GNUNET_assert (key == NULL); |
255 | if (crc->i == 0) | 240 | if (crc->i == 0) |
256 | crc->phase = RP_RESERVE; | 241 | crc->phase = RP_RESERVE; |
257 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 242 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
258 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 243 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
259 | } | 244 | } |
260 | 245 | ||
261 | 246 | ||
262 | static void | 247 | static void |
263 | check_multiple (void *cls, | 248 | check_multiple (void *cls, const GNUNET_HashCode * key, size_t size, |
264 | const GNUNET_HashCode * key, | 249 | const void *data, enum GNUNET_BLOCK_Type type, |
265 | size_t size, | 250 | uint32_t priority, uint32_t anonymity, |
266 | const void *data, | ||
267 | enum GNUNET_BLOCK_Type type, | ||
268 | uint32_t priority, | ||
269 | uint32_t anonymity, | ||
270 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 251 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
271 | { | 252 | { |
272 | struct CpsRunContext *crc = cls; | 253 | struct CpsRunContext *crc = cls; |
@@ -290,34 +271,30 @@ check_multiple (void *cls, | |||
290 | } | 271 | } |
291 | if (priority == get_priority (42)) | 272 | if (priority == get_priority (42)) |
292 | crc->uid = uid; | 273 | crc->uid = uid; |
293 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 274 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
294 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 275 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
295 | } | 276 | } |
296 | 277 | ||
297 | 278 | ||
298 | static void | 279 | static void |
299 | check_update (void *cls, | 280 | check_update (void *cls, const GNUNET_HashCode * key, size_t size, |
300 | const GNUNET_HashCode * key, | 281 | const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, |
301 | size_t size, | 282 | uint32_t anonymity, struct GNUNET_TIME_Absolute expiration, |
302 | const void *data, | 283 | uint64_t uid) |
303 | enum GNUNET_BLOCK_Type type, | ||
304 | uint32_t priority, | ||
305 | uint32_t anonymity, | ||
306 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | ||
307 | { | 284 | { |
308 | struct CpsRunContext *crc = cls; | 285 | struct CpsRunContext *crc = cls; |
309 | 286 | ||
310 | GNUNET_assert (key != NULL); | 287 | GNUNET_assert (key != NULL); |
311 | if ((anonymity == get_anonymity (42)) && | 288 | if ((anonymity == get_anonymity (42)) && (size == get_size (42)) && |
312 | (size == get_size (42)) && (priority == get_priority (42) + 100)) | 289 | (priority == get_priority (42) + 100)) |
313 | crc->phase = RP_DONE; | 290 | crc->phase = RP_DONE; |
314 | else | 291 | else |
315 | { | 292 | { |
316 | GNUNET_assert (size == get_size (43)); | 293 | GNUNET_assert (size == get_size (43)); |
317 | crc->offset++; | 294 | crc->offset++; |
318 | } | 295 | } |
319 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 296 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
320 | crc, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 297 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
321 | } | 298 | } |
322 | 299 | ||
323 | 300 | ||
@@ -334,21 +311,15 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
334 | { | 311 | { |
335 | case RP_PUT: | 312 | case RP_PUT: |
336 | #if VERBOSE | 313 | #if VERBOSE |
337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "PUT", |
338 | "Executing `%s' number %u\n", "PUT", crc->i); | 315 | crc->i); |
339 | #endif | 316 | #endif |
340 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 317 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
341 | GNUNET_DATASTORE_put (datastore, | 318 | GNUNET_DATASTORE_put (datastore, 0, &crc->key, get_size (crc->i), |
342 | 0, | 319 | get_data (crc->i), get_type (crc->i), |
343 | &crc->key, | 320 | get_priority (crc->i), get_anonymity (crc->i), 0, |
344 | get_size (crc->i), | 321 | get_expiration (crc->i), 1, 1, TIMEOUT, |
345 | get_data (crc->i), | 322 | &check_success, crc); |
346 | get_type (crc->i), | ||
347 | get_priority (crc->i), | ||
348 | get_anonymity (crc->i), | ||
349 | 0, | ||
350 | get_expiration (crc->i), | ||
351 | 1, 1, TIMEOUT, &check_success, crc); | ||
352 | crc->i++; | 323 | crc->i++; |
353 | if (crc->i == ITERATIONS) | 324 | if (crc->i == ITERATIONS) |
354 | crc->phase = RP_GET; | 325 | crc->phase = RP_GET; |
@@ -356,36 +327,31 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
356 | case RP_GET: | 327 | case RP_GET: |
357 | crc->i--; | 328 | crc->i--; |
358 | #if VERBOSE | 329 | #if VERBOSE |
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", |
360 | "Executing `%s' number %u\n", "GET", crc->i); | 331 | crc->i); |
361 | #endif | 332 | #endif |
362 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 333 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
363 | GNUNET_DATASTORE_get_key (datastore, | 334 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
364 | crc->offset, | 335 | get_type (crc->i), 1, 1, TIMEOUT, &check_value, |
365 | &crc->key, | 336 | crc); |
366 | get_type (crc->i), | ||
367 | 1, 1, TIMEOUT, &check_value, crc); | ||
368 | break; | 337 | break; |
369 | case RP_DEL: | 338 | case RP_DEL: |
370 | crc->i--; | 339 | crc->i--; |
371 | #if VERBOSE | 340 | #if VERBOSE |
372 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DEL", |
373 | "Executing `%s' number %u\n", "DEL", crc->i); | 342 | crc->i); |
374 | #endif | 343 | #endif |
375 | crc->data = NULL; | 344 | crc->data = NULL; |
376 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 345 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
377 | GNUNET_assert (NULL != | 346 | GNUNET_assert (NULL != |
378 | GNUNET_DATASTORE_get_key (datastore, | 347 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
379 | crc->offset, | 348 | get_type (crc->i), 1, 1, TIMEOUT, |
380 | &crc->key, | ||
381 | get_type (crc->i), | ||
382 | 1, 1, TIMEOUT, | ||
383 | &delete_value, crc)); | 349 | &delete_value, crc)); |
384 | break; | 350 | break; |
385 | case RP_DO_DEL: | 351 | case RP_DO_DEL: |
386 | #if VERBOSE | 352 | #if VERBOSE |
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "DO_DEL", |
388 | "Executing `%s' number %u\n", "DO_DEL", crc->i); | 354 | crc->i); |
389 | #endif | 355 | #endif |
390 | if (crc->i == 0) | 356 | if (crc->i == 0) |
391 | { | 357 | { |
@@ -397,95 +363,63 @@ run_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
397 | crc->phase = RP_DEL; | 363 | crc->phase = RP_DEL; |
398 | } | 364 | } |
399 | GNUNET_assert (NULL != | 365 | GNUNET_assert (NULL != |
400 | GNUNET_DATASTORE_remove (datastore, | 366 | GNUNET_DATASTORE_remove (datastore, &crc->key, crc->size, |
401 | &crc->key, | 367 | crc->data, 1, 1, TIMEOUT, |
402 | crc->size, | ||
403 | crc->data, | ||
404 | 1, 1, TIMEOUT, | ||
405 | &check_success, crc)); | 368 | &check_success, crc)); |
406 | break; | 369 | break; |
407 | case RP_DELVALIDATE: | 370 | case RP_DELVALIDATE: |
408 | crc->i--; | 371 | crc->i--; |
409 | #if VERBOSE | 372 | #if VERBOSE |
410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", |
411 | "Executing `%s' number %u\n", "DEL-VALIDATE", crc->i); | 374 | "DEL-VALIDATE", crc->i); |
412 | #endif | 375 | #endif |
413 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); | 376 | GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); |
414 | GNUNET_assert (NULL != | 377 | GNUNET_assert (NULL != |
415 | GNUNET_DATASTORE_get_key (datastore, | 378 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
416 | crc->offset, | 379 | get_type (crc->i), 1, 1, TIMEOUT, |
417 | &crc->key, | ||
418 | get_type (crc->i), | ||
419 | 1, 1, TIMEOUT, | ||
420 | &check_nothing, crc)); | 380 | &check_nothing, crc)); |
421 | break; | 381 | break; |
422 | case RP_RESERVE: | 382 | case RP_RESERVE: |
423 | crc->phase = RP_PUT_MULTIPLE; | 383 | crc->phase = RP_PUT_MULTIPLE; |
424 | GNUNET_DATASTORE_reserve (datastore, | 384 | GNUNET_DATASTORE_reserve (datastore, 128 * 1024, 2, 1, 1, TIMEOUT, |
425 | 128 * 1024, 2, 1, 1, TIMEOUT, &get_reserved, crc); | 385 | &get_reserved, crc); |
426 | break; | 386 | break; |
427 | case RP_PUT_MULTIPLE: | 387 | case RP_PUT_MULTIPLE: |
428 | crc->phase = RP_PUT_MULTIPLE_NEXT; | 388 | crc->phase = RP_PUT_MULTIPLE_NEXT; |
429 | GNUNET_DATASTORE_put (datastore, | 389 | GNUNET_DATASTORE_put (datastore, crc->rid, &crc->key, get_size (42), |
430 | crc->rid, | 390 | get_data (42), get_type (42), get_priority (42), |
431 | &crc->key, | 391 | get_anonymity (42), 0, get_expiration (42), 1, 1, |
432 | get_size (42), | 392 | TIMEOUT, &check_success, crc); |
433 | get_data (42), | ||
434 | get_type (42), | ||
435 | get_priority (42), | ||
436 | get_anonymity (42), | ||
437 | 0, | ||
438 | get_expiration (42), | ||
439 | 1, 1, TIMEOUT, &check_success, crc); | ||
440 | break; | 393 | break; |
441 | case RP_PUT_MULTIPLE_NEXT: | 394 | case RP_PUT_MULTIPLE_NEXT: |
442 | crc->phase = RP_GET_MULTIPLE; | 395 | crc->phase = RP_GET_MULTIPLE; |
443 | GNUNET_DATASTORE_put (datastore, | 396 | GNUNET_DATASTORE_put (datastore, crc->rid, &crc->key, get_size (43), |
444 | crc->rid, | 397 | get_data (43), get_type (42), get_priority (43), |
445 | &crc->key, | 398 | get_anonymity (43), 0, get_expiration (43), 1, 1, |
446 | get_size (43), | 399 | TIMEOUT, &check_success, crc); |
447 | get_data (43), | ||
448 | get_type (42), | ||
449 | get_priority (43), | ||
450 | get_anonymity (43), | ||
451 | 0, | ||
452 | get_expiration (43), | ||
453 | 1, 1, TIMEOUT, &check_success, crc); | ||
454 | break; | 400 | break; |
455 | case RP_GET_MULTIPLE: | 401 | case RP_GET_MULTIPLE: |
456 | GNUNET_assert (NULL != | 402 | GNUNET_assert (NULL != |
457 | GNUNET_DATASTORE_get_key (datastore, | 403 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
458 | crc->offset, | 404 | get_type (42), 1, 1, TIMEOUT, |
459 | &crc->key, | ||
460 | get_type (42), | ||
461 | 1, 1, TIMEOUT, | ||
462 | &check_multiple, crc)); | 405 | &check_multiple, crc)); |
463 | break; | 406 | break; |
464 | case RP_GET_MULTIPLE_NEXT: | 407 | case RP_GET_MULTIPLE_NEXT: |
465 | GNUNET_assert (NULL != | 408 | GNUNET_assert (NULL != |
466 | GNUNET_DATASTORE_get_key (datastore, | 409 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
467 | crc->offset, | 410 | get_type (42), 1, 1, TIMEOUT, |
468 | &crc->key, | ||
469 | get_type (42), | ||
470 | 1, 1, TIMEOUT, | ||
471 | &check_multiple, crc)); | 411 | &check_multiple, crc)); |
472 | break; | 412 | break; |
473 | case RP_UPDATE: | 413 | case RP_UPDATE: |
474 | GNUNET_assert (crc->uid > 0); | 414 | GNUNET_assert (crc->uid > 0); |
475 | crc->phase = RP_UPDATE_VALIDATE; | 415 | crc->phase = RP_UPDATE_VALIDATE; |
476 | GNUNET_DATASTORE_update (datastore, | 416 | GNUNET_DATASTORE_update (datastore, crc->uid, 100, get_expiration (42), 1, |
477 | crc->uid, | 417 | 1, TIMEOUT, &check_success, crc); |
478 | 100, | ||
479 | get_expiration (42), | ||
480 | 1, 1, TIMEOUT, &check_success, crc); | ||
481 | break; | 418 | break; |
482 | case RP_UPDATE_VALIDATE: | 419 | case RP_UPDATE_VALIDATE: |
483 | GNUNET_assert (NULL != | 420 | GNUNET_assert (NULL != |
484 | GNUNET_DATASTORE_get_key (datastore, | 421 | GNUNET_DATASTORE_get_key (datastore, crc->offset, &crc->key, |
485 | crc->offset, | 422 | get_type (42), 1, 1, TIMEOUT, |
486 | &crc->key, | ||
487 | get_type (42), | ||
488 | 1, 1, TIMEOUT, | ||
489 | &check_update, crc)); | 423 | &check_update, crc)); |
490 | break; | 424 | break; |
491 | case RP_DONE: | 425 | case RP_DONE: |
@@ -513,8 +447,7 @@ run_tests (void *cls, int32_t success, const char *msg) | |||
513 | switch (success) | 447 | switch (success) |
514 | { | 448 | { |
515 | case GNUNET_YES: | 449 | case GNUNET_YES: |
516 | GNUNET_SCHEDULER_add_continuation (&run_continuation, | 450 | GNUNET_SCHEDULER_add_continuation (&run_continuation, crc, |
517 | crc, | ||
518 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 451 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
519 | return; | 452 | return; |
520 | case GNUNET_NO: | 453 | case GNUNET_NO: |
@@ -534,9 +467,8 @@ run_tests (void *cls, int32_t success, const char *msg) | |||
534 | 467 | ||
535 | 468 | ||
536 | static void | 469 | static void |
537 | run (void *cls, | 470 | run (void *cls, char *const *args, const char *cfgfile, |
538 | char *const *args, | 471 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
539 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
540 | { | 472 | { |
541 | struct CpsRunContext *crc; | 473 | struct CpsRunContext *crc; |
542 | static GNUNET_HashCode zkey; | 474 | static GNUNET_HashCode zkey; |
@@ -547,10 +479,8 @@ run (void *cls, | |||
547 | now = GNUNET_TIME_absolute_get (); | 479 | now = GNUNET_TIME_absolute_get (); |
548 | datastore = GNUNET_DATASTORE_connect (cfg); | 480 | datastore = GNUNET_DATASTORE_connect (cfg); |
549 | if (NULL == | 481 | if (NULL == |
550 | GNUNET_DATASTORE_put (datastore, 0, | 482 | GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", |
551 | &zkey, 4, "TEST", | 483 | GNUNET_BLOCK_TYPE_TEST, 0, 0, 0, |
552 | GNUNET_BLOCK_TYPE_TEST, | ||
553 | 0, 0, 0, | ||
554 | GNUNET_TIME_relative_to_absolute | 484 | GNUNET_TIME_relative_to_absolute |
555 | (GNUNET_TIME_UNIT_SECONDS), 0, 1, | 485 | (GNUNET_TIME_UNIT_SECONDS), 0, 1, |
556 | GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) | 486 | GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) |
@@ -582,21 +512,20 @@ check () | |||
582 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 512 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
583 | GNUNET_GETOPT_OPTION_END | 513 | GNUNET_GETOPT_OPTION_END |
584 | }; | 514 | }; |
585 | GNUNET_snprintf (cfg_name, | 515 | GNUNET_snprintf (cfg_name, sizeof (cfg_name), |
586 | sizeof (cfg_name), | ||
587 | "test_datastore_api_data_%s.conf", plugin_name); | 516 | "test_datastore_api_data_%s.conf", plugin_name); |
588 | #if START_DATASTORE | 517 | #if START_DATASTORE |
589 | proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 518 | proc = |
590 | "gnunet-service-arm", | 519 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
520 | "gnunet-service-arm", | ||
591 | #if VERBOSE | 521 | #if VERBOSE |
592 | "-L", "DEBUG", | 522 | "-L", "DEBUG", |
593 | #endif | 523 | #endif |
594 | "-c", cfg_name, NULL); | 524 | "-c", cfg_name, NULL); |
595 | #endif | 525 | #endif |
596 | GNUNET_assert (NULL != proc); | 526 | GNUNET_assert (NULL != proc); |
597 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 527 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
598 | argv, "test-datastore-api", "nohelp", | 528 | "test-datastore-api", "nohelp", options, &run, NULL); |
599 | options, &run, NULL); | ||
600 | #if START_DATASTORE | 529 | #if START_DATASTORE |
601 | sleep (1); /* give datastore chance to receive 'DROP' request */ | 530 | sleep (1); /* give datastore chance to receive 'DROP' request */ |
602 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) | 531 | if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) |
@@ -630,9 +559,8 @@ main (int argc, char *argv[]) | |||
630 | else | 559 | else |
631 | pos = (char *) plugin_name; | 560 | pos = (char *) plugin_name; |
632 | 561 | ||
633 | GNUNET_snprintf (dir_name, | 562 | GNUNET_snprintf (dir_name, sizeof (dir_name), "/tmp/test-gnunet-datastore-%s", |
634 | sizeof (dir_name), | 563 | plugin_name); |
635 | "/tmp/test-gnunet-datastore-%s", plugin_name); | ||
636 | GNUNET_DISK_directory_remove (dir_name); | 564 | GNUNET_DISK_directory_remove (dir_name); |
637 | GNUNET_log_setup ("test-datastore-api", | 565 | GNUNET_log_setup ("test-datastore-api", |
638 | #if VERBOSE | 566 | #if VERBOSE |