test_relocations.toml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # specific corner cases worth explicitly testing for
  2. [[case]] # dangling split dir test
  3. define.ITERATIONS = 20
  4. define.COUNT = 10
  5. code = '''
  6. lfs_format(&lfs, &cfg) => 0;
  7. // fill up filesystem so only ~16 blocks are left
  8. lfs_mount(&lfs, &cfg) => 0;
  9. lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
  10. memset(buffer, 0, 512);
  11. while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
  12. lfs_file_write(&lfs, &file, buffer, 512) => 512;
  13. }
  14. lfs_file_close(&lfs, &file) => 0;
  15. // make a child dir to use in bounded space
  16. lfs_mkdir(&lfs, "child") => 0;
  17. lfs_unmount(&lfs) => 0;
  18. lfs_mount(&lfs, &cfg) => 0;
  19. for (int j = 0; j < ITERATIONS; j++) {
  20. for (int i = 0; i < COUNT; i++) {
  21. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  22. lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
  23. lfs_file_close(&lfs, &file) => 0;
  24. }
  25. lfs_dir_open(&lfs, &dir, "child") => 0;
  26. lfs_dir_read(&lfs, &dir, &info) => 1;
  27. lfs_dir_read(&lfs, &dir, &info) => 1;
  28. for (int i = 0; i < COUNT; i++) {
  29. sprintf(path, "test%03d_loooooooooooooooooong_name", i);
  30. lfs_dir_read(&lfs, &dir, &info) => 1;
  31. strcmp(info.name, path) => 0;
  32. }
  33. lfs_dir_read(&lfs, &dir, &info) => 0;
  34. lfs_dir_close(&lfs, &dir) => 0;
  35. if (j == ITERATIONS-1) {
  36. break;
  37. }
  38. for (int i = 0; i < COUNT; i++) {
  39. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  40. lfs_remove(&lfs, path) => 0;
  41. }
  42. }
  43. lfs_unmount(&lfs) => 0;
  44. lfs_mount(&lfs, &cfg) => 0;
  45. lfs_dir_open(&lfs, &dir, "child") => 0;
  46. lfs_dir_read(&lfs, &dir, &info) => 1;
  47. lfs_dir_read(&lfs, &dir, &info) => 1;
  48. for (int i = 0; i < COUNT; i++) {
  49. sprintf(path, "test%03d_loooooooooooooooooong_name", i);
  50. lfs_dir_read(&lfs, &dir, &info) => 1;
  51. strcmp(info.name, path) => 0;
  52. }
  53. lfs_dir_read(&lfs, &dir, &info) => 0;
  54. lfs_dir_close(&lfs, &dir) => 0;
  55. for (int i = 0; i < COUNT; i++) {
  56. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  57. lfs_remove(&lfs, path) => 0;
  58. }
  59. lfs_unmount(&lfs) => 0;
  60. '''
  61. [[case]] # outdated head test
  62. define.ITERATIONS = 20
  63. define.COUNT = 10
  64. code = '''
  65. lfs_format(&lfs, &cfg) => 0;
  66. // fill up filesystem so only ~16 blocks are left
  67. lfs_mount(&lfs, &cfg) => 0;
  68. lfs_file_open(&lfs, &file, "padding", LFS_O_CREAT | LFS_O_WRONLY) => 0;
  69. memset(buffer, 0, 512);
  70. while (LFS_BLOCK_COUNT - lfs_fs_size(&lfs) > 16) {
  71. lfs_file_write(&lfs, &file, buffer, 512) => 512;
  72. }
  73. lfs_file_close(&lfs, &file) => 0;
  74. // make a child dir to use in bounded space
  75. lfs_mkdir(&lfs, "child") => 0;
  76. lfs_unmount(&lfs) => 0;
  77. lfs_mount(&lfs, &cfg) => 0;
  78. for (int j = 0; j < ITERATIONS; j++) {
  79. for (int i = 0; i < COUNT; i++) {
  80. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  81. lfs_file_open(&lfs, &file, path, LFS_O_CREAT | LFS_O_WRONLY) => 0;
  82. lfs_file_close(&lfs, &file) => 0;
  83. }
  84. lfs_dir_open(&lfs, &dir, "child") => 0;
  85. lfs_dir_read(&lfs, &dir, &info) => 1;
  86. lfs_dir_read(&lfs, &dir, &info) => 1;
  87. for (int i = 0; i < COUNT; i++) {
  88. sprintf(path, "test%03d_loooooooooooooooooong_name", i);
  89. lfs_dir_read(&lfs, &dir, &info) => 1;
  90. strcmp(info.name, path) => 0;
  91. info.size => 0;
  92. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  93. lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
  94. lfs_file_write(&lfs, &file, "hi", 2) => 2;
  95. lfs_file_close(&lfs, &file) => 0;
  96. }
  97. lfs_dir_read(&lfs, &dir, &info) => 0;
  98. lfs_dir_rewind(&lfs, &dir) => 0;
  99. lfs_dir_read(&lfs, &dir, &info) => 1;
  100. lfs_dir_read(&lfs, &dir, &info) => 1;
  101. for (int i = 0; i < COUNT; i++) {
  102. sprintf(path, "test%03d_loooooooooooooooooong_name", i);
  103. lfs_dir_read(&lfs, &dir, &info) => 1;
  104. strcmp(info.name, path) => 0;
  105. info.size => 2;
  106. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  107. lfs_file_open(&lfs, &file, path, LFS_O_WRONLY) => 0;
  108. lfs_file_write(&lfs, &file, "hi", 2) => 2;
  109. lfs_file_close(&lfs, &file) => 0;
  110. }
  111. lfs_dir_read(&lfs, &dir, &info) => 0;
  112. lfs_dir_rewind(&lfs, &dir) => 0;
  113. lfs_dir_read(&lfs, &dir, &info) => 1;
  114. lfs_dir_read(&lfs, &dir, &info) => 1;
  115. for (int i = 0; i < COUNT; i++) {
  116. sprintf(path, "test%03d_loooooooooooooooooong_name", i);
  117. lfs_dir_read(&lfs, &dir, &info) => 1;
  118. strcmp(info.name, path) => 0;
  119. info.size => 2;
  120. }
  121. lfs_dir_read(&lfs, &dir, &info) => 0;
  122. lfs_dir_close(&lfs, &dir) => 0;
  123. for (int i = 0; i < COUNT; i++) {
  124. sprintf(path, "child/test%03d_loooooooooooooooooong_name", i);
  125. lfs_remove(&lfs, path) => 0;
  126. }
  127. }
  128. lfs_unmount(&lfs) => 0;
  129. '''