test_orphan.sh 1.1 KB

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