1# These tests are for some specific corner cases with neighboring inline files.
2# Note that these tests are intended for 512 byte inline sizes. They should
3# still pass with other inline sizes but wouldn't be testing anything.
4
5defines.CACHE_SIZE = 512
6if = 'CACHE_SIZE % PROG_SIZE == 0 && CACHE_SIZE == 512'
7
8[cases.test_entries_grow]
9code = '''
10    uint8_t wbuffer[1024];
11    uint8_t rbuffer[1024];
12
13    lfs_t lfs;
14    lfs_format(&lfs, cfg) => 0;
15    lfs_mount(&lfs, cfg) => 0;
16
17    // write hi0 20
18    char path[1024];
19    lfs_size_t size;
20    sprintf(path, "hi0"); size = 20;
21    lfs_file_t file;
22    lfs_file_open(&lfs, &file, path,
23            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
24    memset(wbuffer, 'c', size);
25    lfs_file_write(&lfs, &file, wbuffer, size) => size;
26    lfs_file_size(&lfs, &file) => size;
27    lfs_file_close(&lfs, &file) => 0;
28    // write hi1 20
29    sprintf(path, "hi1"); size = 20;
30    lfs_file_open(&lfs, &file, path,
31            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
32    memset(wbuffer, 'c', size);
33    lfs_file_write(&lfs, &file, wbuffer, size) => size;
34    lfs_file_size(&lfs, &file) => size;
35    lfs_file_close(&lfs, &file) => 0;
36    // write hi2 20
37    sprintf(path, "hi2"); size = 20;
38    lfs_file_open(&lfs, &file, path,
39            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
40    memset(wbuffer, 'c', size);
41    lfs_file_write(&lfs, &file, wbuffer, size) => size;
42    lfs_file_size(&lfs, &file) => size;
43    lfs_file_close(&lfs, &file) => 0;
44    // write hi3 20
45    sprintf(path, "hi3"); size = 20;
46    lfs_file_open(&lfs, &file, path,
47            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
48    memset(wbuffer, 'c', size);
49    lfs_file_write(&lfs, &file, wbuffer, size) => size;
50    lfs_file_size(&lfs, &file) => size;
51    lfs_file_close(&lfs, &file) => 0;
52
53    // read hi1 20
54    sprintf(path, "hi1"); size = 20;
55    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
56    lfs_file_size(&lfs, &file) => size;
57    lfs_file_read(&lfs, &file, rbuffer, size) => size;
58    memcmp(rbuffer, wbuffer, size) => 0;
59    lfs_file_close(&lfs, &file) => 0;
60    // write hi1 200
61    sprintf(path, "hi1"); size = 200;
62    lfs_file_open(&lfs, &file, path,
63            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
64    memset(wbuffer, 'c', size);
65    lfs_file_write(&lfs, &file, wbuffer, size) => size;
66    lfs_file_size(&lfs, &file) => size;
67    lfs_file_close(&lfs, &file) => 0;
68
69    // read hi0 20
70    sprintf(path, "hi0"); size = 20;
71    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
72    lfs_file_size(&lfs, &file) => size;
73    lfs_file_read(&lfs, &file, rbuffer, size) => size;
74    memcmp(rbuffer, wbuffer, size) => 0;
75    lfs_file_close(&lfs, &file) => 0;
76    // read hi1 200
77    sprintf(path, "hi1"); size = 200;
78    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
79    lfs_file_size(&lfs, &file) => size;
80    lfs_file_read(&lfs, &file, rbuffer, size) => size;
81    memcmp(rbuffer, wbuffer, size) => 0;
82    lfs_file_close(&lfs, &file) => 0;
83    // read hi2 20
84    sprintf(path, "hi2"); size = 20;
85    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
86    lfs_file_size(&lfs, &file) => size;
87    lfs_file_read(&lfs, &file, rbuffer, size) => size;
88    memcmp(rbuffer, wbuffer, size) => 0;
89    lfs_file_close(&lfs, &file) => 0;
90    // read hi3 20
91    sprintf(path, "hi3"); size = 20;
92    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
93    lfs_file_size(&lfs, &file) => size;
94    lfs_file_read(&lfs, &file, rbuffer, size) => size;
95    memcmp(rbuffer, wbuffer, size) => 0;
96    lfs_file_close(&lfs, &file) => 0;
97
98    lfs_unmount(&lfs) => 0;
99'''
100
101[cases.test_entries_shrink]
102code = '''
103    uint8_t wbuffer[1024];
104    uint8_t rbuffer[1024];
105
106    lfs_t lfs;
107    lfs_format(&lfs, cfg) => 0;
108    lfs_mount(&lfs, cfg) => 0;
109
110    // write hi0 20
111    char path[1024];
112    lfs_size_t size;
113    sprintf(path, "hi0"); size = 20;
114    lfs_file_t file;
115    lfs_file_open(&lfs, &file, path,
116            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
117    memset(wbuffer, 'c', size);
118    lfs_file_write(&lfs, &file, wbuffer, size) => size;
119    lfs_file_size(&lfs, &file) => size;
120    lfs_file_close(&lfs, &file) => 0;
121    // write hi1 200
122    sprintf(path, "hi1"); size = 200;
123    lfs_file_open(&lfs, &file, path,
124            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
125    memset(wbuffer, 'c', size);
126    lfs_file_write(&lfs, &file, wbuffer, size) => size;
127    lfs_file_size(&lfs, &file) => size;
128    lfs_file_close(&lfs, &file) => 0;
129    // write hi2 20
130    sprintf(path, "hi2"); size = 20;
131    lfs_file_open(&lfs, &file, path,
132            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
133    memset(wbuffer, 'c', size);
134    lfs_file_write(&lfs, &file, wbuffer, size) => size;
135    lfs_file_size(&lfs, &file) => size;
136    lfs_file_close(&lfs, &file) => 0;
137    // write hi3 20
138    sprintf(path, "hi3"); size = 20;
139    lfs_file_open(&lfs, &file, path,
140            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
141    memset(wbuffer, 'c', size);
142    lfs_file_write(&lfs, &file, wbuffer, size) => size;
143    lfs_file_size(&lfs, &file) => size;
144    lfs_file_close(&lfs, &file) => 0;
145
146    // read hi1 200
147    sprintf(path, "hi1"); size = 200;
148    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
149    lfs_file_size(&lfs, &file) => size;
150    lfs_file_read(&lfs, &file, rbuffer, size) => size;
151    memcmp(rbuffer, wbuffer, size) => 0;
152    lfs_file_close(&lfs, &file) => 0;
153    // write hi1 20
154    sprintf(path, "hi1"); size = 20;
155    lfs_file_open(&lfs, &file, path,
156            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
157    memset(wbuffer, 'c', size);
158    lfs_file_write(&lfs, &file, wbuffer, size) => size;
159    lfs_file_size(&lfs, &file) => size;
160    lfs_file_close(&lfs, &file) => 0;
161
162    // read hi0 20
163    sprintf(path, "hi0"); size = 20;
164    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
165    lfs_file_size(&lfs, &file) => size;
166    lfs_file_read(&lfs, &file, rbuffer, size) => size;
167    memcmp(rbuffer, wbuffer, size) => 0;
168    lfs_file_close(&lfs, &file) => 0;
169    // read hi1 20
170    sprintf(path, "hi1"); size = 20;
171    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
172    lfs_file_size(&lfs, &file) => size;
173    lfs_file_read(&lfs, &file, rbuffer, size) => size;
174    memcmp(rbuffer, wbuffer, size) => 0;
175    lfs_file_close(&lfs, &file) => 0;
176    // read hi2 20
177    sprintf(path, "hi2"); size = 20;
178    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
179    lfs_file_size(&lfs, &file) => size;
180    lfs_file_read(&lfs, &file, rbuffer, size) => size;
181    memcmp(rbuffer, wbuffer, size) => 0;
182    lfs_file_close(&lfs, &file) => 0;
183    // read hi3 20
184    sprintf(path, "hi3"); size = 20;
185    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
186    lfs_file_size(&lfs, &file) => size;
187    lfs_file_read(&lfs, &file, rbuffer, size) => size;
188    memcmp(rbuffer, wbuffer, size) => 0;
189    lfs_file_close(&lfs, &file) => 0;
190
191    lfs_unmount(&lfs) => 0;
192'''
193
194[cases.test_entries_spill]
195code = '''
196    uint8_t wbuffer[1024];
197    uint8_t rbuffer[1024];
198
199    lfs_t lfs;
200    lfs_format(&lfs, cfg) => 0;
201    lfs_mount(&lfs, cfg) => 0;
202
203    // write hi0 200
204    char path[1024];
205    lfs_size_t size;
206    sprintf(path, "hi0"); size = 200;
207    lfs_file_t file;
208    lfs_file_open(&lfs, &file, path,
209            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
210    memset(wbuffer, 'c', size);
211    lfs_file_write(&lfs, &file, wbuffer, size) => size;
212    lfs_file_size(&lfs, &file) => size;
213    lfs_file_close(&lfs, &file) => 0;
214    // write hi1 200
215    sprintf(path, "hi1"); size = 200;
216    lfs_file_open(&lfs, &file, path,
217            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
218    memset(wbuffer, 'c', size);
219    lfs_file_write(&lfs, &file, wbuffer, size) => size;
220    lfs_file_size(&lfs, &file) => size;
221    lfs_file_close(&lfs, &file) => 0;
222    // write hi2 200
223    sprintf(path, "hi2"); size = 200;
224    lfs_file_open(&lfs, &file, path,
225            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
226    memset(wbuffer, 'c', size);
227    lfs_file_write(&lfs, &file, wbuffer, size) => size;
228    lfs_file_size(&lfs, &file) => size;
229    lfs_file_close(&lfs, &file) => 0;
230    // write hi3 200
231    sprintf(path, "hi3"); size = 200;
232    lfs_file_open(&lfs, &file, path,
233            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
234    memset(wbuffer, 'c', size);
235    lfs_file_write(&lfs, &file, wbuffer, size) => size;
236    lfs_file_size(&lfs, &file) => size;
237    lfs_file_close(&lfs, &file) => 0;
238
239    // read hi0 200
240    sprintf(path, "hi0"); size = 200;
241    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
242    lfs_file_size(&lfs, &file) => size;
243    lfs_file_read(&lfs, &file, rbuffer, size) => size;
244    memcmp(rbuffer, wbuffer, size) => 0;
245    lfs_file_close(&lfs, &file) => 0;
246    // read hi1 200
247    sprintf(path, "hi1"); size = 200;
248    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
249    lfs_file_size(&lfs, &file) => size;
250    lfs_file_read(&lfs, &file, rbuffer, size) => size;
251    memcmp(rbuffer, wbuffer, size) => 0;
252    lfs_file_close(&lfs, &file) => 0;
253    // read hi2 200
254    sprintf(path, "hi2"); size = 200;
255    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
256    lfs_file_size(&lfs, &file) => size;
257    lfs_file_read(&lfs, &file, rbuffer, size) => size;
258    memcmp(rbuffer, wbuffer, size) => 0;
259    lfs_file_close(&lfs, &file) => 0;
260    // read hi3 200
261    sprintf(path, "hi3"); size = 200;
262    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
263    lfs_file_size(&lfs, &file) => size;
264    lfs_file_read(&lfs, &file, rbuffer, size) => size;
265    memcmp(rbuffer, wbuffer, size) => 0;
266    lfs_file_close(&lfs, &file) => 0;
267
268    lfs_unmount(&lfs) => 0;
269'''
270
271[cases.test_entries_push_spill]
272code = '''
273    uint8_t wbuffer[1024];
274    uint8_t rbuffer[1024];
275
276    lfs_t lfs;
277    lfs_format(&lfs, cfg) => 0;
278    lfs_mount(&lfs, cfg) => 0;
279
280    // write hi0 200
281    char path[1024];
282    lfs_size_t size;
283    sprintf(path, "hi0"); size = 200;
284    lfs_file_t file;
285    lfs_file_open(&lfs, &file, path,
286            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
287    memset(wbuffer, 'c', size);
288    lfs_file_write(&lfs, &file, wbuffer, size) => size;
289    lfs_file_size(&lfs, &file) => size;
290    lfs_file_close(&lfs, &file) => 0;
291    // write hi1 20
292    sprintf(path, "hi1"); size = 20;
293    lfs_file_open(&lfs, &file, path,
294            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
295    memset(wbuffer, 'c', size);
296    lfs_file_write(&lfs, &file, wbuffer, size) => size;
297    lfs_file_size(&lfs, &file) => size;
298    lfs_file_close(&lfs, &file) => 0;
299    // write hi2 200
300    sprintf(path, "hi2"); size = 200;
301    lfs_file_open(&lfs, &file, path,
302            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
303    memset(wbuffer, 'c', size);
304    lfs_file_write(&lfs, &file, wbuffer, size) => size;
305    lfs_file_size(&lfs, &file) => size;
306    lfs_file_close(&lfs, &file) => 0;
307    // write hi3 200
308    sprintf(path, "hi3"); size = 200;
309    lfs_file_open(&lfs, &file, path,
310            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
311    memset(wbuffer, 'c', size);
312    lfs_file_write(&lfs, &file, wbuffer, size) => size;
313    lfs_file_size(&lfs, &file) => size;
314    lfs_file_close(&lfs, &file) => 0;
315
316    // read hi1 20
317    sprintf(path, "hi1"); size = 20;
318    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
319    lfs_file_size(&lfs, &file) => size;
320    lfs_file_read(&lfs, &file, rbuffer, size) => size;
321    memcmp(rbuffer, wbuffer, size) => 0;
322    lfs_file_close(&lfs, &file) => 0;
323    // write hi1 200
324    sprintf(path, "hi1"); size = 200;
325    lfs_file_open(&lfs, &file, path,
326            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
327    memset(wbuffer, 'c', size);
328    lfs_file_write(&lfs, &file, wbuffer, size) => size;
329    lfs_file_size(&lfs, &file) => size;
330    lfs_file_close(&lfs, &file) => 0;
331
332    // read hi0 200
333    sprintf(path, "hi0"); size = 200;
334    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
335    lfs_file_size(&lfs, &file) => size;
336    lfs_file_read(&lfs, &file, rbuffer, size) => size;
337    memcmp(rbuffer, wbuffer, size) => 0;
338    lfs_file_close(&lfs, &file) => 0;
339    // read hi1 200
340    sprintf(path, "hi1"); size = 200;
341    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
342    lfs_file_size(&lfs, &file) => size;
343    lfs_file_read(&lfs, &file, rbuffer, size) => size;
344    memcmp(rbuffer, wbuffer, size) => 0;
345    lfs_file_close(&lfs, &file) => 0;
346    // read hi2 200
347    sprintf(path, "hi2"); size = 200;
348    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
349    lfs_file_size(&lfs, &file) => size;
350    lfs_file_read(&lfs, &file, rbuffer, size) => size;
351    memcmp(rbuffer, wbuffer, size) => 0;
352    lfs_file_close(&lfs, &file) => 0;
353    // read hi3 200
354    sprintf(path, "hi3"); size = 200;
355    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
356    lfs_file_size(&lfs, &file) => size;
357    lfs_file_read(&lfs, &file, rbuffer, size) => size;
358    memcmp(rbuffer, wbuffer, size) => 0;
359    lfs_file_close(&lfs, &file) => 0;
360
361    lfs_unmount(&lfs) => 0;
362'''
363
364[cases.test_entries_push_spill_two]
365code = '''
366    uint8_t wbuffer[1024];
367    uint8_t rbuffer[1024];
368
369    lfs_t lfs;
370    lfs_format(&lfs, cfg) => 0;
371    lfs_mount(&lfs, cfg) => 0;
372
373    // write hi0 200
374    char path[1024];
375    lfs_size_t size;
376    sprintf(path, "hi0"); size = 200;
377    lfs_file_t file;
378    lfs_file_open(&lfs, &file, path,
379            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
380    memset(wbuffer, 'c', size);
381    lfs_file_write(&lfs, &file, wbuffer, size) => size;
382    lfs_file_size(&lfs, &file) => size;
383    lfs_file_close(&lfs, &file) => 0;
384    // write hi1 20
385    sprintf(path, "hi1"); size = 20;
386    lfs_file_open(&lfs, &file, path,
387            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
388    memset(wbuffer, 'c', size);
389    lfs_file_write(&lfs, &file, wbuffer, size) => size;
390    lfs_file_size(&lfs, &file) => size;
391    lfs_file_close(&lfs, &file) => 0;
392    // write hi2 200
393    sprintf(path, "hi2"); size = 200;
394    lfs_file_open(&lfs, &file, path,
395            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
396    memset(wbuffer, 'c', size);
397    lfs_file_write(&lfs, &file, wbuffer, size) => size;
398    lfs_file_size(&lfs, &file) => size;
399    lfs_file_close(&lfs, &file) => 0;
400    // write hi3 200
401    sprintf(path, "hi3"); size = 200;
402    lfs_file_open(&lfs, &file, path,
403            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
404    memset(wbuffer, 'c', size);
405    lfs_file_write(&lfs, &file, wbuffer, size) => size;
406    lfs_file_size(&lfs, &file) => size;
407    lfs_file_close(&lfs, &file) => 0;
408    // write hi4 200
409    sprintf(path, "hi4"); size = 200;
410    lfs_file_open(&lfs, &file, path,
411            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
412    memset(wbuffer, 'c', size);
413    lfs_file_write(&lfs, &file, wbuffer, size) => size;
414    lfs_file_size(&lfs, &file) => size;
415    lfs_file_close(&lfs, &file) => 0;
416
417    // read hi1 20
418    sprintf(path, "hi1"); size = 20;
419    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
420    lfs_file_size(&lfs, &file) => size;
421    lfs_file_read(&lfs, &file, rbuffer, size) => size;
422    memcmp(rbuffer, wbuffer, size) => 0;
423    lfs_file_close(&lfs, &file) => 0;
424    // write hi1 200
425    sprintf(path, "hi1"); size = 200;
426    lfs_file_open(&lfs, &file, path,
427            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
428    memset(wbuffer, 'c', size);
429    lfs_file_write(&lfs, &file, wbuffer, size) => size;
430    lfs_file_size(&lfs, &file) => size;
431    lfs_file_close(&lfs, &file) => 0;
432
433    // read hi0 200
434    sprintf(path, "hi0"); size = 200;
435    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
436    lfs_file_size(&lfs, &file) => size;
437    lfs_file_read(&lfs, &file, rbuffer, size) => size;
438    memcmp(rbuffer, wbuffer, size) => 0;
439    lfs_file_close(&lfs, &file) => 0;
440    // read hi1 200
441    sprintf(path, "hi1"); size = 200;
442    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
443    lfs_file_size(&lfs, &file) => size;
444    lfs_file_read(&lfs, &file, rbuffer, size) => size;
445    memcmp(rbuffer, wbuffer, size) => 0;
446    lfs_file_close(&lfs, &file) => 0;
447    // read hi2 200
448    sprintf(path, "hi2"); size = 200;
449    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
450    lfs_file_size(&lfs, &file) => size;
451    lfs_file_read(&lfs, &file, rbuffer, size) => size;
452    memcmp(rbuffer, wbuffer, size) => 0;
453    lfs_file_close(&lfs, &file) => 0;
454    // read hi3 200
455    sprintf(path, "hi3"); size = 200;
456    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
457    lfs_file_size(&lfs, &file) => size;
458    lfs_file_read(&lfs, &file, rbuffer, size) => size;
459    memcmp(rbuffer, wbuffer, size) => 0;
460    lfs_file_close(&lfs, &file) => 0;
461    // read hi4 200
462    sprintf(path, "hi4"); size = 200;
463    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
464    lfs_file_size(&lfs, &file) => size;
465    lfs_file_read(&lfs, &file, rbuffer, size) => size;
466    memcmp(rbuffer, wbuffer, size) => 0;
467    lfs_file_close(&lfs, &file) => 0;
468
469    lfs_unmount(&lfs) => 0;
470'''
471
472[cases.test_entries_drop]
473code = '''
474    uint8_t wbuffer[1024];
475    uint8_t rbuffer[1024];
476
477    lfs_t lfs;
478    lfs_format(&lfs, cfg) => 0;
479    lfs_mount(&lfs, cfg) => 0;
480
481    // write hi0 200
482    char path[1024];
483    lfs_size_t size;
484    sprintf(path, "hi0"); size = 200;
485    lfs_file_t file;
486    lfs_file_open(&lfs, &file, path,
487            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
488    memset(wbuffer, 'c', size);
489    lfs_file_write(&lfs, &file, wbuffer, size) => size;
490    lfs_file_size(&lfs, &file) => size;
491    lfs_file_close(&lfs, &file) => 0;
492    // write hi1 200
493    sprintf(path, "hi1"); size = 200;
494    lfs_file_open(&lfs, &file, path,
495            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
496    memset(wbuffer, 'c', size);
497    lfs_file_write(&lfs, &file, wbuffer, size) => size;
498    lfs_file_size(&lfs, &file) => size;
499    lfs_file_close(&lfs, &file) => 0;
500    // write hi2 200
501    sprintf(path, "hi2"); size = 200;
502    lfs_file_open(&lfs, &file, path,
503            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
504    memset(wbuffer, 'c', size);
505    lfs_file_write(&lfs, &file, wbuffer, size) => size;
506    lfs_file_size(&lfs, &file) => size;
507    lfs_file_close(&lfs, &file) => 0;
508    // write hi3 200
509    sprintf(path, "hi3"); size = 200;
510    lfs_file_open(&lfs, &file, path,
511            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
512    memset(wbuffer, 'c', size);
513    lfs_file_write(&lfs, &file, wbuffer, size) => size;
514    lfs_file_size(&lfs, &file) => size;
515    lfs_file_close(&lfs, &file) => 0;
516
517    lfs_remove(&lfs, "hi1") => 0;
518    struct lfs_info info;
519    lfs_stat(&lfs, "hi1", &info) => LFS_ERR_NOENT;
520    // read hi0 200
521    sprintf(path, "hi0"); size = 200;
522    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
523    lfs_file_size(&lfs, &file) => size;
524    lfs_file_read(&lfs, &file, rbuffer, size) => size;
525    memcmp(rbuffer, wbuffer, size) => 0;
526    lfs_file_close(&lfs, &file) => 0;
527    // read hi2 200
528    sprintf(path, "hi2"); size = 200;
529    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
530    lfs_file_size(&lfs, &file) => size;
531    lfs_file_read(&lfs, &file, rbuffer, size) => size;
532    memcmp(rbuffer, wbuffer, size) => 0;
533    lfs_file_close(&lfs, &file) => 0;
534    // read hi3 200
535    sprintf(path, "hi3"); size = 200;
536    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
537    lfs_file_size(&lfs, &file) => size;
538    lfs_file_read(&lfs, &file, rbuffer, size) => size;
539    memcmp(rbuffer, wbuffer, size) => 0;
540    lfs_file_close(&lfs, &file) => 0;
541
542    lfs_remove(&lfs, "hi2") => 0;
543    lfs_stat(&lfs, "hi2", &info) => LFS_ERR_NOENT;
544    // read hi0 200
545    sprintf(path, "hi0"); size = 200;
546    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
547    lfs_file_size(&lfs, &file) => size;
548    lfs_file_read(&lfs, &file, rbuffer, size) => size;
549    memcmp(rbuffer, wbuffer, size) => 0;
550    lfs_file_close(&lfs, &file) => 0;
551    // read hi3 200
552    sprintf(path, "hi3"); size = 200;
553    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
554    lfs_file_size(&lfs, &file) => size;
555    lfs_file_read(&lfs, &file, rbuffer, size) => size;
556    memcmp(rbuffer, wbuffer, size) => 0;
557    lfs_file_close(&lfs, &file) => 0;
558
559    lfs_remove(&lfs, "hi3") => 0;
560    lfs_stat(&lfs, "hi3", &info) => LFS_ERR_NOENT;
561    // read hi0 200
562    sprintf(path, "hi0"); size = 200;
563    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
564    lfs_file_size(&lfs, &file) => size;
565    lfs_file_read(&lfs, &file, rbuffer, size) => size;
566    memcmp(rbuffer, wbuffer, size) => 0;
567    lfs_file_close(&lfs, &file) => 0;
568
569    lfs_remove(&lfs, "hi0") => 0;
570    lfs_stat(&lfs, "hi0", &info) => LFS_ERR_NOENT;
571
572    lfs_unmount(&lfs) => 0;
573'''
574
575[cases.test_entries_create_too_big]
576code = '''
577    lfs_t lfs;
578    lfs_format(&lfs, cfg) => 0;
579
580    lfs_mount(&lfs, cfg) => 0;
581    char path[1024];
582    memset(path, 'm', 200);
583    path[200] = '\0';
584
585    lfs_size_t size = 400;
586    lfs_file_t file;
587    lfs_file_open(&lfs, &file, path,
588            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
589    uint8_t wbuffer[1024];
590    memset(wbuffer, 'c', size);
591    lfs_file_write(&lfs, &file, wbuffer, size) => size;
592    lfs_file_close(&lfs, &file) => 0;
593
594    size = 400;
595    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
596    uint8_t rbuffer[1024];
597    lfs_file_read(&lfs, &file, rbuffer, size) => size;
598    memcmp(rbuffer, wbuffer, size) => 0;
599    lfs_file_close(&lfs, &file) => 0;
600    lfs_unmount(&lfs) => 0;
601'''
602
603[cases.test_entries_resize_too_big]
604code = '''
605    lfs_t lfs;
606    lfs_format(&lfs, cfg) => 0;
607
608    lfs_mount(&lfs, cfg) => 0;
609    char path[1024];
610    memset(path, 'm', 200);
611    path[200] = '\0';
612
613    lfs_size_t size = 40;
614    lfs_file_t file;
615    lfs_file_open(&lfs, &file, path,
616            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
617    uint8_t wbuffer[1024];
618    memset(wbuffer, 'c', size);
619    lfs_file_write(&lfs, &file, wbuffer, size) => size;
620    lfs_file_close(&lfs, &file) => 0;
621
622    size = 40;
623    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
624    uint8_t rbuffer[1024];
625    lfs_file_read(&lfs, &file, rbuffer, size) => size;
626    memcmp(rbuffer, wbuffer, size) => 0;
627    lfs_file_close(&lfs, &file) => 0;
628
629    size = 400;
630    lfs_file_open(&lfs, &file, path,
631            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
632    memset(wbuffer, 'c', size);
633    lfs_file_write(&lfs, &file, wbuffer, size) => size;
634    lfs_file_close(&lfs, &file) => 0;
635
636    size = 400;
637    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
638    lfs_file_read(&lfs, &file, rbuffer, size) => size;
639    memcmp(rbuffer, wbuffer, size) => 0;
640    lfs_file_close(&lfs, &file) => 0;
641    lfs_unmount(&lfs) => 0;
642'''
643