test_orphan.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. set -eu
  3. echo "=== Orphan tests ==="
  4. rm -rf blocks
  5. tests/test.py << TEST
  6. lfs_format(&lfs, &cfg) => 0;
  7. TEST
  8. echo "--- Orphan test ---"
  9. tests/test.py << TEST
  10. lfs_mount(&lfs, &cfg) => 0;
  11. lfs_mkdir(&lfs, "parent") => 0;
  12. lfs_mkdir(&lfs, "parent/orphan") => 0;
  13. lfs_mkdir(&lfs, "parent/child") => 0;
  14. lfs_remove(&lfs, "parent/orphan") => 0;
  15. TEST
  16. # corrupt most recent commit, this should be the update to the previous
  17. # linked-list entry and should orphan the child
  18. tests/corrupt.py
  19. tests/test.py << TEST
  20. lfs_mount(&lfs, &cfg) => 0;
  21. lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
  22. lfs_ssize_t before = lfs_fs_size(&lfs);
  23. before => 8;
  24. lfs_unmount(&lfs) => 0;
  25. lfs_mount(&lfs, &cfg) => 0;
  26. lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
  27. lfs_ssize_t orphaned = lfs_fs_size(&lfs);
  28. orphaned => 8;
  29. lfs_mkdir(&lfs, "parent/otherchild") => 0;
  30. lfs_stat(&lfs, "parent/orphan", &info) => LFS_ERR_NOENT;
  31. lfs_ssize_t deorphaned = lfs_fs_size(&lfs);
  32. deorphaned => 8;
  33. lfs_unmount(&lfs) => 0;
  34. TEST
  35. echo "--- Results ---"
  36. tests/stats.py