diff options
Diffstat (limited to 'src/fs/test_fs_meta_data.c')
-rw-r--r-- | src/fs/test_fs_meta_data.c | 117 |
1 files changed, 115 insertions, 2 deletions
diff --git a/src/fs/test_fs_meta_data.c b/src/fs/test_fs_meta_data.c index bee7844ea..4e7439d7b 100644 --- a/src/fs/test_fs_meta_data.c +++ b/src/fs/test_fs_meta_data.c | |||
@@ -352,19 +352,132 @@ check () | |||
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | static int | ||
356 | test_bigmeta_rw (void) | ||
357 | { | ||
358 | static char meta[1024 * 1024 * 10]; | ||
359 | struct GNUNET_BIO_WriteHandle *wh; | ||
360 | struct GNUNET_BIO_ReadHandle *rh; | ||
361 | char *filename = GNUNET_DISK_mktemp ("gnunet_bio"); | ||
362 | struct GNUNET_FS_MetaData *mdR = NULL; | ||
363 | |||
364 | memset (meta, 'b', sizeof (meta)); | ||
365 | meta[sizeof (meta) - 1] = '\0'; | ||
366 | |||
367 | wh = GNUNET_BIO_write_open_file (filename); | ||
368 | GNUNET_assert (NULL != wh); | ||
369 | if (GNUNET_OK != GNUNET_BIO_write_int32 (wh, | ||
370 | "test-bigmeta-rw-int32", | ||
371 | sizeof (meta))) | ||
372 | { | ||
373 | GNUNET_BIO_write_close (wh, NULL); | ||
374 | return 1; | ||
375 | } | ||
376 | if (GNUNET_OK != GNUNET_BIO_write (wh, | ||
377 | "test-bigmeta-rw-bytes", | ||
378 | meta, | ||
379 | sizeof (meta))) | ||
380 | { | ||
381 | GNUNET_BIO_write_close (wh, NULL); | ||
382 | return 1; | ||
383 | } | ||
384 | GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL)); | ||
385 | |||
386 | rh = GNUNET_BIO_read_open_file (filename); | ||
387 | GNUNET_assert (NULL != rh); | ||
388 | GNUNET_assert (GNUNET_SYSERR == | ||
389 | GNUNET_FS_read_meta_data (rh, | ||
390 | "test-bigmeta-rw-metadata", | ||
391 | &mdR)); | ||
392 | GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL)); | ||
393 | |||
394 | GNUNET_assert (NULL == mdR); | ||
395 | |||
396 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename)); | ||
397 | GNUNET_free (filename); | ||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static int | ||
402 | test_fakemeta_rw (void) | ||
403 | { | ||
404 | struct GNUNET_BIO_WriteHandle *wh; | ||
405 | struct GNUNET_BIO_ReadHandle *rh; | ||
406 | char *filename = GNUNET_DISK_mktemp ("gnunet_bio"); | ||
407 | struct GNUNET_FS_MetaData *mdR = NULL; | ||
408 | |||
409 | wh = GNUNET_BIO_write_open_file (filename); | ||
410 | GNUNET_assert (NULL != wh); | ||
411 | if (GNUNET_OK != GNUNET_BIO_write_int32 (wh, | ||
412 | "test-fakestring-rw-int32", | ||
413 | 2)) | ||
414 | { | ||
415 | GNUNET_BIO_write_close (wh, NULL); | ||
416 | return 1; | ||
417 | } | ||
418 | GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL)); | ||
419 | |||
420 | rh = GNUNET_BIO_read_open_file (filename); | ||
421 | GNUNET_assert (NULL != rh); | ||
422 | GNUNET_assert (GNUNET_SYSERR == | ||
423 | GNUNET_FS_read_meta_data (rh, | ||
424 | "test-fakestring-rw-metadata", | ||
425 | &mdR)); | ||
426 | GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL)); | ||
427 | |||
428 | GNUNET_assert (NULL == mdR); | ||
429 | |||
430 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename)); | ||
431 | GNUNET_free (filename); | ||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | static int | ||
436 | test_fakebigmeta_rw (void) | ||
437 | { | ||
438 | struct GNUNET_BIO_WriteHandle *wh; | ||
439 | struct GNUNET_BIO_ReadHandle *rh; | ||
440 | char *filename = GNUNET_DISK_mktemp ("gnunet_bio"); | ||
441 | struct GNUNET_FS_MetaData *mdR = NULL; | ||
442 | int32_t wNum = 1024 * 1024 * 10; | ||
443 | |||
444 | wh = GNUNET_BIO_write_open_file (filename); | ||
445 | GNUNET_assert (NULL != wh); | ||
446 | GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_int32 (wh, | ||
447 | "test-fakebigmeta-rw-int32", | ||
448 | wNum)); | ||
449 | GNUNET_assert (GNUNET_OK == GNUNET_BIO_write_close (wh, NULL)); | ||
450 | |||
451 | rh = GNUNET_BIO_read_open_file (filename); | ||
452 | GNUNET_assert (NULL != rh); | ||
453 | GNUNET_assert (GNUNET_SYSERR == | ||
454 | GNUNET_FS_read_meta_data (rh, | ||
455 | "test-fakebigmeta-rw-metadata", | ||
456 | &mdR)); | ||
457 | GNUNET_assert (GNUNET_SYSERR == GNUNET_BIO_read_close (rh, NULL)); | ||
458 | |||
459 | GNUNET_assert (NULL == mdR); | ||
460 | |||
461 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename)); | ||
462 | GNUNET_free (filename); | ||
463 | return 0; | ||
464 | } | ||
465 | |||
355 | int | 466 | int |
356 | main (int argc, char *argv[]) | 467 | main (int argc, char *argv[]) |
357 | { | 468 | { |
358 | int failureCount = 0; | 469 | int failureCount = 0; |
359 | int i; | 470 | int i; |
360 | 471 | ||
361 | GNUNET_log_setup ("test-container-meta-data", "WARNING", NULL); | 472 | GNUNET_log_setup ("test-fs-meta-data", "WARNING", NULL); |
362 | for (i = 0; i < 255; i++) | 473 | for (i = 0; i < 255; i++) |
363 | failureCount += testMeta (i); | 474 | failureCount += testMeta (i); |
364 | for (i = 1; i < 255; i++) | 475 | for (i = 1; i < 255; i++) |
365 | failureCount += testMetaMore (i); | 476 | failureCount += testMetaMore (i); |
366 | failureCount += testMetaLink (); | 477 | failureCount += testMetaLink (); |
367 | 478 | failureCount += test_fakebigmeta_rw (); | |
479 | failureCount += test_fakemeta_rw (); | ||
480 | failureCount += test_bigmeta_rw (); | ||
368 | int ret = check (); | 481 | int ret = check (); |
369 | 482 | ||
370 | if (ret == 1) | 483 | if (ret == 1) |