casaroli opened a new pull request, #3974:
URL: https://github.com/apache/nuttx-apps/pull/3974

   depends-on: apache/nuttx/pull/21466
   
   ## Summary
   
   No test in nuttx-apps covers a write past EOF on a FAT file. This PR adds 
the program `fatgap` in `testing/fs/fatgap` (`CONFIG_TESTING_FATGAP`).
   
   The test makes a RAM disk for FAT12, FAT16 and FAT32 (512 KiB, about 2 MiB, 
about 34 MiB). It fills each RAM disk with 0xa5 before the format, so a cluster 
that the file system does not zero does not read as zero by accident. It skips 
a FAT type when the memory for its RAM disk is not available and removes each 
RAM disk at the end. The arguments select the FAT types, for example `fatgap 
12`.
   
   The 14 cases write past EOF with the old size at 1 or 2 clusters (6 cases: 
gap of 1 byte, gap of 100 bytes, write at the next cluster, gap over several 
clusters, long write), one byte below or above 2 clusters (4 cases), in the 
middle of a cluster (2 cases) and with an empty file (2 cases). Each case runs 
in 3 modes: a new handle writes, the same handle writes with the last sector 
dirty in its buffer, and a second handle has the last sector in its buffer. 
Each case checks the old data, the gap, the new data and the size on a new 
handle and after a remount, and the number of free clusters. The program prints 
PASS or FAIL for each case and exits with a failure status if a case fails.
   
   ## Impact
   
   New test only. The option is `default n` and depends on `FS_FAT`, 
`FSUTILS_MKFATFS` and `BOARDCTL_MKRD`. No defconfig sets it, so CI does not 
build or run the test. No change to the other tests. 
`Documentation/applications/testing` has no page for it in this PR.
   
   ## Testing
   
   qemu-armv8a:nsh with HVF, 1 CPU, make, with `FS_FAT` and `TESTING_FATGAP`, 
apps on 63e9db801:
   
   | nuttx | `fatgap` (pass / fail) | exit status | ostest |
   |---|---|---|---|
   | master 6b9b216ff30 | 72 / 54 | 1 | status 0 |
   | apache/nuttx#21466 | 126 / 0 | 0 | status 0 |
   
   On master the 6 cases at 1 or 2 clusters fail in all 3 modes on all 3 FAT 
types, with `old data: byte 2048 is 0x00` or similar. The 8 neighbour cases 
pass. With apache/nuttx#21466 all pass.
   
   To check the gap checks: with `fat_zero_cluster()` changed locally to return 
at once on apache/nuttx#21466, all 126 fail.
   
   `time fatgap` on qemu-armv8a:nsh reports 0.0971 s. A second run in the same 
boot (`fatgap 12`) passes 42 / 0. `free` shows the same used memory before and 
after the runs.
   
   Other runs on apache/nuttx#21466, FAT32 skipped for lack of memory where 
shown:
   
   | Configuration | Build | `fatgap` (pass / fail) | ostest |
   |---|---|---|---|
   | qemu-armv8a:nsh, CMake, HVF | CMake | 126 / 0 | not run |
   | qemu-armv8a:knsh (kernel), HVF, FAT32 skipped | make | 84 / 0 | status 0 |
   | mps2-an500:knsh (protected), TCG, FAT32 skipped | make | 84 / 0 | not run |
   | rv-virt:citest with `TESTING_LTP` off, TCG, FAT32 skipped | make | 84 / 0 
| not run |
   
   Builds with `-Wno-cpp -Werror`, no warning: qemu-armv8a:nsh, 
qemu-armv8a:knsh, mps2-an500:knsh.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   
   Not run: real storage, sector sizes other than 512, sim, x86_64.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to