test_dirs.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. set -eu
  3. echo "=== Directory tests ==="
  4. rm -rf blocks
  5. tests/test.py << TEST
  6. lfs_format(&lfs, &config) => 0;
  7. TEST
  8. echo "--- Root directory ---"
  9. tests/test.py << TEST
  10. lfs_mount(&lfs, &config) => 0;
  11. lfs_dir_open(&lfs, &dir[0], "/") => 0;
  12. lfs_dir_close(&lfs, &dir[0]) => 0;
  13. lfs_unmount(&lfs) => 0;
  14. TEST
  15. echo "--- Directory creation ---"
  16. tests/test.py << TEST
  17. lfs_mount(&lfs, &config) => 0;
  18. lfs_mkdir(&lfs, "potato") => 0;
  19. lfs_unmount(&lfs) => 0;
  20. TEST
  21. echo "--- File creation ---"
  22. tests/test.py << TEST
  23. lfs_mount(&lfs, &config) => 0;
  24. lfs_file_open(&lfs, &file[0], "burito", LFS_O_CREAT | LFS_O_WRONLY) => 0;
  25. lfs_file_close(&lfs, &file[0]) => 0;
  26. lfs_unmount(&lfs) => 0;
  27. TEST
  28. echo "--- Directory iteration ---"
  29. tests/test.py << TEST
  30. lfs_mount(&lfs, &config) => 0;
  31. lfs_dir_open(&lfs, &dir[0], "/") => 0;
  32. lfs_dir_read(&lfs, &dir[0], &info) => 1;
  33. strcmp(info.name, ".") => 0;
  34. info.type => LFS_TYPE_DIR;
  35. lfs_dir_read(&lfs, &dir[0], &info) => 1;
  36. strcmp(info.name, "..") => 0;
  37. info.type => LFS_TYPE_DIR;
  38. lfs_dir_read(&lfs, &dir[0], &info) => 1;
  39. strcmp(info.name, "potato") => 0;
  40. info.type => LFS_TYPE_DIR;
  41. lfs_dir_read(&lfs, &dir[0], &info) => 1;
  42. strcmp(info.name, "burito") => 0;
  43. info.type => LFS_TYPE_REG;
  44. lfs_dir_read(&lfs, &dir[0], &info) => 0;
  45. lfs_dir_close(&lfs, &dir[0]) => 0;
  46. lfs_unmount(&lfs) => 0;
  47. TEST
  48. echo "--- Directory failures ---"
  49. tests/test.py << TEST
  50. lfs_mount(&lfs, &config) => 0;
  51. lfs_mkdir(&lfs, "potato") => LFS_ERROR_EXISTS;
  52. lfs_dir_open(&lfs, &dir[0], "tomato") => LFS_ERROR_NO_ENTRY;
  53. lfs_dir_open(&lfs, &dir[0], "burito") => LFS_ERROR_NOT_DIR;
  54. lfs_file_open(&lfs, &file[0], "tomato", LFS_O_RDONLY) => LFS_ERROR_NO_ENTRY;
  55. lfs_file_open(&lfs, &file[0], "potato", LFS_O_RDONLY) => LFS_ERROR_IS_DIR;
  56. lfs_unmount(&lfs) => 0;
  57. TEST
  58. echo "--- Results ---"
  59. tests/stats.py