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
5define.LFS_CACHE_SIZE = 512
6if = 'LFS_CACHE_SIZE % LFS_PROG_SIZE == 0 && LFS_CACHE_SIZE == 512'
7
8[[case]] # entry grow test
9code = '''
10    uint8_t wbuffer[1024];
11    uint8_t rbuffer[1024];
12
13    lfs_format(&lfs, &cfg) => 0;
14    lfs_mount(&lfs, &cfg) => 0;
15
16    // write hi0 20
17    sprintf(path, "hi0"); size = 20;
18    lfs_file_open(&lfs, &file, path,
19            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
20    memset(wbuffer, 'c', size);
21    lfs_file_write(&lfs, &file, wbuffer, size) => size;
22    lfs_file_size(&lfs, &file) => size;
23    lfs_file_close(&lfs, &file) => 0;
24    // write hi1 20
25    sprintf(path, "hi1"); size = 20;
26    lfs_file_open(&lfs, &file, path,
27            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
28    memset(wbuffer, 'c', size);
29    lfs_file_write(&lfs, &file, wbuffer, size) => size;
30    lfs_file_size(&lfs, &file) => size;
31    lfs_file_close(&lfs, &file) => 0;
32    // write hi2 20
33    sprintf(path, "hi2"); size = 20;
34    lfs_file_open(&lfs, &file, path,
35            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
36    memset(wbuffer, 'c', size);
37    lfs_file_write(&lfs, &file, wbuffer, size) => size;
38    lfs_file_size(&lfs, &file) => size;
39    lfs_file_close(&lfs, &file) => 0;
40    // write hi3 20
41    sprintf(path, "hi3"); size = 20;
42    lfs_file_open(&lfs, &file, path,
43            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
44    memset(wbuffer, 'c', size);
45    lfs_file_write(&lfs, &file, wbuffer, size) => size;
46    lfs_file_size(&lfs, &file) => size;
47    lfs_file_close(&lfs, &file) => 0;
48
49    // read hi1 20
50    sprintf(path, "hi1"); size = 20;
51    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
52    lfs_file_size(&lfs, &file) => size;
53    lfs_file_read(&lfs, &file, rbuffer, size) => size;
54    memcmp(rbuffer, wbuffer, size) => 0;
55    lfs_file_close(&lfs, &file) => 0;
56    // write hi1 200
57    sprintf(path, "hi1"); size = 200;
58    lfs_file_open(&lfs, &file, path,
59            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
60    memset(wbuffer, 'c', size);
61    lfs_file_write(&lfs, &file, wbuffer, size) => size;
62    lfs_file_size(&lfs, &file) => size;
63    lfs_file_close(&lfs, &file) => 0;
64
65    // read hi0 20
66    sprintf(path, "hi0"); size = 20;
67    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
68    lfs_file_size(&lfs, &file) => size;
69    lfs_file_read(&lfs, &file, rbuffer, size) => size;
70    memcmp(rbuffer, wbuffer, size) => 0;
71    lfs_file_close(&lfs, &file) => 0;
72    // read hi1 200
73    sprintf(path, "hi1"); size = 200;
74    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
75    lfs_file_size(&lfs, &file) => size;
76    lfs_file_read(&lfs, &file, rbuffer, size) => size;
77    memcmp(rbuffer, wbuffer, size) => 0;
78    lfs_file_close(&lfs, &file) => 0;
79    // read hi2 20
80    sprintf(path, "hi2"); size = 20;
81    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
82    lfs_file_size(&lfs, &file) => size;
83    lfs_file_read(&lfs, &file, rbuffer, size) => size;
84    memcmp(rbuffer, wbuffer, size) => 0;
85    lfs_file_close(&lfs, &file) => 0;
86    // read hi3 20
87    sprintf(path, "hi3"); size = 20;
88    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
89    lfs_file_size(&lfs, &file) => size;
90    lfs_file_read(&lfs, &file, rbuffer, size) => size;
91    memcmp(rbuffer, wbuffer, size) => 0;
92    lfs_file_close(&lfs, &file) => 0;
93
94    lfs_unmount(&lfs) => 0;
95'''
96
97[[case]] # entry shrink test
98code = '''
99    uint8_t wbuffer[1024];
100    uint8_t rbuffer[1024];
101
102    lfs_format(&lfs, &cfg) => 0;
103    lfs_mount(&lfs, &cfg) => 0;
104
105    // write hi0 20
106    sprintf(path, "hi0"); size = 20;
107    lfs_file_open(&lfs, &file, path,
108            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
109    memset(wbuffer, 'c', size);
110    lfs_file_write(&lfs, &file, wbuffer, size) => size;
111    lfs_file_size(&lfs, &file) => size;
112    lfs_file_close(&lfs, &file) => 0;
113    // write hi1 200
114    sprintf(path, "hi1"); size = 200;
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 hi2 20
122    sprintf(path, "hi2"); size = 20;
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 hi3 20
130    sprintf(path, "hi3"); 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
138    // read hi1 200
139    sprintf(path, "hi1"); size = 200;
140    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
141    lfs_file_size(&lfs, &file) => size;
142    lfs_file_read(&lfs, &file, rbuffer, size) => size;
143    memcmp(rbuffer, wbuffer, size) => 0;
144    lfs_file_close(&lfs, &file) => 0;
145    // write hi1 20
146    sprintf(path, "hi1"); size = 20;
147    lfs_file_open(&lfs, &file, path,
148            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
149    memset(wbuffer, 'c', size);
150    lfs_file_write(&lfs, &file, wbuffer, size) => size;
151    lfs_file_size(&lfs, &file) => size;
152    lfs_file_close(&lfs, &file) => 0;
153
154    // read hi0 20
155    sprintf(path, "hi0"); size = 20;
156    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
157    lfs_file_size(&lfs, &file) => size;
158    lfs_file_read(&lfs, &file, rbuffer, size) => size;
159    memcmp(rbuffer, wbuffer, size) => 0;
160    lfs_file_close(&lfs, &file) => 0;
161    // read hi1 20
162    sprintf(path, "hi1"); size = 20;
163    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
164    lfs_file_size(&lfs, &file) => size;
165    lfs_file_read(&lfs, &file, rbuffer, size) => size;
166    memcmp(rbuffer, wbuffer, size) => 0;
167    lfs_file_close(&lfs, &file) => 0;
168    // read hi2 20
169    sprintf(path, "hi2"); size = 20;
170    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
171    lfs_file_size(&lfs, &file) => size;
172    lfs_file_read(&lfs, &file, rbuffer, size) => size;
173    memcmp(rbuffer, wbuffer, size) => 0;
174    lfs_file_close(&lfs, &file) => 0;
175    // read hi3 20
176    sprintf(path, "hi3"); size = 20;
177    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
178    lfs_file_size(&lfs, &file) => size;
179    lfs_file_read(&lfs, &file, rbuffer, size) => size;
180    memcmp(rbuffer, wbuffer, size) => 0;
181    lfs_file_close(&lfs, &file) => 0;
182
183    lfs_unmount(&lfs) => 0;
184'''
185
186[[case]] # entry spill test
187code = '''
188    uint8_t wbuffer[1024];
189    uint8_t rbuffer[1024];
190
191    lfs_format(&lfs, &cfg) => 0;
192    lfs_mount(&lfs, &cfg) => 0;
193
194    // write hi0 200
195    sprintf(path, "hi0"); size = 200;
196    lfs_file_open(&lfs, &file, path,
197            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
198    memset(wbuffer, 'c', size);
199    lfs_file_write(&lfs, &file, wbuffer, size) => size;
200    lfs_file_size(&lfs, &file) => size;
201    lfs_file_close(&lfs, &file) => 0;
202    // write hi1 200
203    sprintf(path, "hi1"); size = 200;
204    lfs_file_open(&lfs, &file, path,
205            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
206    memset(wbuffer, 'c', size);
207    lfs_file_write(&lfs, &file, wbuffer, size) => size;
208    lfs_file_size(&lfs, &file) => size;
209    lfs_file_close(&lfs, &file) => 0;
210    // write hi2 200
211    sprintf(path, "hi2"); size = 200;
212    lfs_file_open(&lfs, &file, path,
213            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
214    memset(wbuffer, 'c', size);
215    lfs_file_write(&lfs, &file, wbuffer, size) => size;
216    lfs_file_size(&lfs, &file) => size;
217    lfs_file_close(&lfs, &file) => 0;
218    // write hi3 200
219    sprintf(path, "hi3"); size = 200;
220    lfs_file_open(&lfs, &file, path,
221            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
222    memset(wbuffer, 'c', size);
223    lfs_file_write(&lfs, &file, wbuffer, size) => size;
224    lfs_file_size(&lfs, &file) => size;
225    lfs_file_close(&lfs, &file) => 0;
226
227    // read hi0 200
228    sprintf(path, "hi0"); size = 200;
229    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
230    lfs_file_size(&lfs, &file) => size;
231    lfs_file_read(&lfs, &file, rbuffer, size) => size;
232    memcmp(rbuffer, wbuffer, size) => 0;
233    lfs_file_close(&lfs, &file) => 0;
234    // read hi1 200
235    sprintf(path, "hi1"); size = 200;
236    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
237    lfs_file_size(&lfs, &file) => size;
238    lfs_file_read(&lfs, &file, rbuffer, size) => size;
239    memcmp(rbuffer, wbuffer, size) => 0;
240    lfs_file_close(&lfs, &file) => 0;
241    // read hi2 200
242    sprintf(path, "hi2"); size = 200;
243    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
244    lfs_file_size(&lfs, &file) => size;
245    lfs_file_read(&lfs, &file, rbuffer, size) => size;
246    memcmp(rbuffer, wbuffer, size) => 0;
247    lfs_file_close(&lfs, &file) => 0;
248    // read hi3 200
249    sprintf(path, "hi3"); size = 200;
250    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
251    lfs_file_size(&lfs, &file) => size;
252    lfs_file_read(&lfs, &file, rbuffer, size) => size;
253    memcmp(rbuffer, wbuffer, size) => 0;
254    lfs_file_close(&lfs, &file) => 0;
255
256    lfs_unmount(&lfs) => 0;
257'''
258
259[[case]] # entry push spill test
260code = '''
261    uint8_t wbuffer[1024];
262    uint8_t rbuffer[1024];
263
264    lfs_format(&lfs, &cfg) => 0;
265    lfs_mount(&lfs, &cfg) => 0;
266
267    // write hi0 200
268    sprintf(path, "hi0"); size = 200;
269    lfs_file_open(&lfs, &file, path,
270            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
271    memset(wbuffer, 'c', size);
272    lfs_file_write(&lfs, &file, wbuffer, size) => size;
273    lfs_file_size(&lfs, &file) => size;
274    lfs_file_close(&lfs, &file) => 0;
275    // write hi1 20
276    sprintf(path, "hi1"); size = 20;
277    lfs_file_open(&lfs, &file, path,
278            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
279    memset(wbuffer, 'c', size);
280    lfs_file_write(&lfs, &file, wbuffer, size) => size;
281    lfs_file_size(&lfs, &file) => size;
282    lfs_file_close(&lfs, &file) => 0;
283    // write hi2 200
284    sprintf(path, "hi2"); size = 200;
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 hi3 200
292    sprintf(path, "hi3"); size = 200;
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
300    // read hi1 20
301    sprintf(path, "hi1"); size = 20;
302    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
303    lfs_file_size(&lfs, &file) => size;
304    lfs_file_read(&lfs, &file, rbuffer, size) => size;
305    memcmp(rbuffer, wbuffer, size) => 0;
306    lfs_file_close(&lfs, &file) => 0;
307    // write hi1 200
308    sprintf(path, "hi1"); 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 hi0 200
317    sprintf(path, "hi0"); size = 200;
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    // read hi1 200
324    sprintf(path, "hi1"); size = 200;
325    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
326    lfs_file_size(&lfs, &file) => size;
327    lfs_file_read(&lfs, &file, rbuffer, size) => size;
328    memcmp(rbuffer, wbuffer, size) => 0;
329    lfs_file_close(&lfs, &file) => 0;
330    // read hi2 200
331    sprintf(path, "hi2"); size = 200;
332    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
333    lfs_file_size(&lfs, &file) => size;
334    lfs_file_read(&lfs, &file, rbuffer, size) => size;
335    memcmp(rbuffer, wbuffer, size) => 0;
336    lfs_file_close(&lfs, &file) => 0;
337    // read hi3 200
338    sprintf(path, "hi3"); size = 200;
339    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
340    lfs_file_size(&lfs, &file) => size;
341    lfs_file_read(&lfs, &file, rbuffer, size) => size;
342    memcmp(rbuffer, wbuffer, size) => 0;
343    lfs_file_close(&lfs, &file) => 0;
344
345    lfs_unmount(&lfs) => 0;
346'''
347
348[[case]] # entry push spill two test
349code = '''
350    uint8_t wbuffer[1024];
351    uint8_t rbuffer[1024];
352
353    lfs_format(&lfs, &cfg) => 0;
354    lfs_mount(&lfs, &cfg) => 0;
355
356    // write hi0 200
357    sprintf(path, "hi0"); size = 200;
358    lfs_file_open(&lfs, &file, path,
359            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
360    memset(wbuffer, 'c', size);
361    lfs_file_write(&lfs, &file, wbuffer, size) => size;
362    lfs_file_size(&lfs, &file) => size;
363    lfs_file_close(&lfs, &file) => 0;
364    // write hi1 20
365    sprintf(path, "hi1"); size = 20;
366    lfs_file_open(&lfs, &file, path,
367            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
368    memset(wbuffer, 'c', size);
369    lfs_file_write(&lfs, &file, wbuffer, size) => size;
370    lfs_file_size(&lfs, &file) => size;
371    lfs_file_close(&lfs, &file) => 0;
372    // write hi2 200
373    sprintf(path, "hi2"); size = 200;
374    lfs_file_open(&lfs, &file, path,
375            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
376    memset(wbuffer, 'c', size);
377    lfs_file_write(&lfs, &file, wbuffer, size) => size;
378    lfs_file_size(&lfs, &file) => size;
379    lfs_file_close(&lfs, &file) => 0;
380    // write hi3 200
381    sprintf(path, "hi3"); size = 200;
382    lfs_file_open(&lfs, &file, path,
383            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
384    memset(wbuffer, 'c', size);
385    lfs_file_write(&lfs, &file, wbuffer, size) => size;
386    lfs_file_size(&lfs, &file) => size;
387    lfs_file_close(&lfs, &file) => 0;
388    // write hi4 200
389    sprintf(path, "hi4"); size = 200;
390    lfs_file_open(&lfs, &file, path,
391            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
392    memset(wbuffer, 'c', size);
393    lfs_file_write(&lfs, &file, wbuffer, size) => size;
394    lfs_file_size(&lfs, &file) => size;
395    lfs_file_close(&lfs, &file) => 0;
396
397    // read hi1 20
398    sprintf(path, "hi1"); size = 20;
399    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
400    lfs_file_size(&lfs, &file) => size;
401    lfs_file_read(&lfs, &file, rbuffer, size) => size;
402    memcmp(rbuffer, wbuffer, size) => 0;
403    lfs_file_close(&lfs, &file) => 0;
404    // write hi1 200
405    sprintf(path, "hi1"); size = 200;
406    lfs_file_open(&lfs, &file, path,
407            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
408    memset(wbuffer, 'c', size);
409    lfs_file_write(&lfs, &file, wbuffer, size) => size;
410    lfs_file_size(&lfs, &file) => size;
411    lfs_file_close(&lfs, &file) => 0;
412
413    // read hi0 200
414    sprintf(path, "hi0"); size = 200;
415    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
416    lfs_file_size(&lfs, &file) => size;
417    lfs_file_read(&lfs, &file, rbuffer, size) => size;
418    memcmp(rbuffer, wbuffer, size) => 0;
419    lfs_file_close(&lfs, &file) => 0;
420    // read hi1 200
421    sprintf(path, "hi1"); size = 200;
422    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
423    lfs_file_size(&lfs, &file) => size;
424    lfs_file_read(&lfs, &file, rbuffer, size) => size;
425    memcmp(rbuffer, wbuffer, size) => 0;
426    lfs_file_close(&lfs, &file) => 0;
427    // read hi2 200
428    sprintf(path, "hi2"); size = 200;
429    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
430    lfs_file_size(&lfs, &file) => size;
431    lfs_file_read(&lfs, &file, rbuffer, size) => size;
432    memcmp(rbuffer, wbuffer, size) => 0;
433    lfs_file_close(&lfs, &file) => 0;
434    // read hi3 200
435    sprintf(path, "hi3"); size = 200;
436    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
437    lfs_file_size(&lfs, &file) => size;
438    lfs_file_read(&lfs, &file, rbuffer, size) => size;
439    memcmp(rbuffer, wbuffer, size) => 0;
440    lfs_file_close(&lfs, &file) => 0;
441    // read hi4 200
442    sprintf(path, "hi4"); size = 200;
443    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
444    lfs_file_size(&lfs, &file) => size;
445    lfs_file_read(&lfs, &file, rbuffer, size) => size;
446    memcmp(rbuffer, wbuffer, size) => 0;
447    lfs_file_close(&lfs, &file) => 0;
448
449    lfs_unmount(&lfs) => 0;
450'''
451
452[[case]] # entry drop test
453code = '''
454    uint8_t wbuffer[1024];
455    uint8_t rbuffer[1024];
456
457    lfs_format(&lfs, &cfg) => 0;
458    lfs_mount(&lfs, &cfg) => 0;
459
460    // write hi0 200
461    sprintf(path, "hi0"); size = 200;
462    lfs_file_open(&lfs, &file, path,
463            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
464    memset(wbuffer, 'c', size);
465    lfs_file_write(&lfs, &file, wbuffer, size) => size;
466    lfs_file_size(&lfs, &file) => size;
467    lfs_file_close(&lfs, &file) => 0;
468    // write hi1 200
469    sprintf(path, "hi1"); size = 200;
470    lfs_file_open(&lfs, &file, path,
471            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
472    memset(wbuffer, 'c', size);
473    lfs_file_write(&lfs, &file, wbuffer, size) => size;
474    lfs_file_size(&lfs, &file) => size;
475    lfs_file_close(&lfs, &file) => 0;
476    // write hi2 200
477    sprintf(path, "hi2"); size = 200;
478    lfs_file_open(&lfs, &file, path,
479            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
480    memset(wbuffer, 'c', size);
481    lfs_file_write(&lfs, &file, wbuffer, size) => size;
482    lfs_file_size(&lfs, &file) => size;
483    lfs_file_close(&lfs, &file) => 0;
484    // write hi3 200
485    sprintf(path, "hi3"); size = 200;
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
493    lfs_remove(&lfs, "hi1") => 0;
494    lfs_stat(&lfs, "hi1", &info) => LFS_ERR_NOENT;
495    // read hi0 200
496    sprintf(path, "hi0"); size = 200;
497    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
498    lfs_file_size(&lfs, &file) => size;
499    lfs_file_read(&lfs, &file, rbuffer, size) => size;
500    memcmp(rbuffer, wbuffer, size) => 0;
501    lfs_file_close(&lfs, &file) => 0;
502    // read hi2 200
503    sprintf(path, "hi2"); size = 200;
504    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
505    lfs_file_size(&lfs, &file) => size;
506    lfs_file_read(&lfs, &file, rbuffer, size) => size;
507    memcmp(rbuffer, wbuffer, size) => 0;
508    lfs_file_close(&lfs, &file) => 0;
509    // read hi3 200
510    sprintf(path, "hi3"); size = 200;
511    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
512    lfs_file_size(&lfs, &file) => size;
513    lfs_file_read(&lfs, &file, rbuffer, size) => size;
514    memcmp(rbuffer, wbuffer, size) => 0;
515    lfs_file_close(&lfs, &file) => 0;
516
517    lfs_remove(&lfs, "hi2") => 0;
518    lfs_stat(&lfs, "hi2", &info) => LFS_ERR_NOENT;
519    // read hi0 200
520    sprintf(path, "hi0"); size = 200;
521    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
522    lfs_file_size(&lfs, &file) => size;
523    lfs_file_read(&lfs, &file, rbuffer, size) => size;
524    memcmp(rbuffer, wbuffer, size) => 0;
525    lfs_file_close(&lfs, &file) => 0;
526    // read hi3 200
527    sprintf(path, "hi3"); size = 200;
528    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
529    lfs_file_size(&lfs, &file) => size;
530    lfs_file_read(&lfs, &file, rbuffer, size) => size;
531    memcmp(rbuffer, wbuffer, size) => 0;
532    lfs_file_close(&lfs, &file) => 0;
533
534    lfs_remove(&lfs, "hi3") => 0;
535    lfs_stat(&lfs, "hi3", &info) => LFS_ERR_NOENT;
536    // read hi0 200
537    sprintf(path, "hi0"); size = 200;
538    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
539    lfs_file_size(&lfs, &file) => size;
540    lfs_file_read(&lfs, &file, rbuffer, size) => size;
541    memcmp(rbuffer, wbuffer, size) => 0;
542    lfs_file_close(&lfs, &file) => 0;
543
544    lfs_remove(&lfs, "hi0") => 0;
545    lfs_stat(&lfs, "hi0", &info) => LFS_ERR_NOENT;
546
547    lfs_unmount(&lfs) => 0;
548'''
549
550[[case]] # create too big
551code = '''
552    lfs_format(&lfs, &cfg) => 0;
553
554    lfs_mount(&lfs, &cfg) => 0;
555    memset(path, 'm', 200);
556    path[200] = '\0';
557
558    size = 400;
559    lfs_file_open(&lfs, &file, path,
560            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
561    uint8_t wbuffer[1024];
562    memset(wbuffer, 'c', size);
563    lfs_file_write(&lfs, &file, wbuffer, size) => size;
564    lfs_file_close(&lfs, &file) => 0;
565
566    size = 400;
567    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
568    uint8_t rbuffer[1024];
569    lfs_file_read(&lfs, &file, rbuffer, size) => size;
570    memcmp(rbuffer, wbuffer, size) => 0;
571    lfs_file_close(&lfs, &file) => 0;
572    lfs_unmount(&lfs) => 0;
573'''
574
575[[case]] # resize too big
576code = '''
577    lfs_format(&lfs, &cfg) => 0;
578
579    lfs_mount(&lfs, &cfg) => 0;
580    memset(path, 'm', 200);
581    path[200] = '\0';
582
583    size = 40;
584    lfs_file_open(&lfs, &file, path,
585            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
586    uint8_t wbuffer[1024];
587    memset(wbuffer, 'c', size);
588    lfs_file_write(&lfs, &file, wbuffer, size) => size;
589    lfs_file_close(&lfs, &file) => 0;
590
591    size = 40;
592    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
593    uint8_t rbuffer[1024];
594    lfs_file_read(&lfs, &file, rbuffer, size) => size;
595    memcmp(rbuffer, wbuffer, size) => 0;
596    lfs_file_close(&lfs, &file) => 0;
597
598    size = 400;
599    lfs_file_open(&lfs, &file, path,
600            LFS_O_WRONLY | LFS_O_CREAT | LFS_O_TRUNC) => 0;
601    memset(wbuffer, 'c', size);
602    lfs_file_write(&lfs, &file, wbuffer, size) => size;
603    lfs_file_close(&lfs, &file) => 0;
604
605    size = 400;
606    lfs_file_open(&lfs, &file, path, LFS_O_RDONLY) => 0;
607    lfs_file_read(&lfs, &file, rbuffer, size) => size;
608    memcmp(rbuffer, wbuffer, size) => 0;
609    lfs_file_close(&lfs, &file) => 0;
610    lfs_unmount(&lfs) => 0;
611'''
612