test_dirs.sh 1.7 KB

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