xipfs XIPFS File System Test
Exercises the XIPFS file system: the routine VFS paths, the write-once rules, both flavours of mapping, and then the two properties that are easy to get wrong and quiet when they are – release of execute-in-place pins, and power-loss atomicity of the metadata commit.
Usage:
xipfs_test [<section>]
With no argument every section runs. The power-loss sweeps take minutes while everything else takes seconds, hence the selector:
nsh> xipfs_test xip
XIPFS test suite on /mnt/xipfs (/dev/rpflash)
-- XIP mapping --
PASS create module image
PASS media is memory mapped
PASS strict XIP mmap succeeds
PASS mapping points into flash
PASS mapped bytes match file contents
PASS mapping does not cost RAM proportional to the file
PASS mapping takes a pin
PASS munmap
PASS munmap drops the pin
==== 9 passed, 0 failed ====
Sections
basicCreate, read back, stat, readdir, unlink, and that all of it survives a remount.
writeonceThat reopening a closed file for writing, appending, and seeking during a write are refused, and that a sequential write still works afterwards.
strictThat a mapping past the end of a file is refused and a valid one is not.
xipThat a mapping lands inside the media window rather than the heap, that the mapped bytes are the file’s, that it costs no RAM proportional to the file, and that it takes and releases a pin.
multimapThat N mappings of one file produce N pins on one extent and alias the same address.
crosstaskThat one task dying does not release another task’s pin, and that the last holder does.
teardownThat a task killed without calling
munmapstill has its pin released. This is the one that matters for a module that faults.dirsThat directories behave like a real tree: an empty one exists and survives a remount,
readdirreports each level,rmdirrefuses a directory that still holds something and succeeds once emptied, and a path through a missing directory or through a file fails rather than being created.defragThat compaction relocates extents, keeps their contents, survives a remount, distinguishes an open file from a pinned one, and never relocates a pinned extent.
powerloss,powertorn,unlink,defraglosFail the Nth flash operation, remount, and check the volume is consistent and every committed file byte-for-byte intact – sweeping N across create, unlink and compaction. The
tornvariant leaves the failing write partially programmed rather than cleanly refused, which is what a real power loss mid-program leaves behind. These needCONFIG_FS_XIPFS_FAULT_INJECT.
Configuration
CONFIG_TESTING_FS_XIPFSEnable the test. Requires
CONFIG_FS_XIPFS.CONFIG_TESTING_FS_XIPFS_MOUNTPTThe volume to test. The suite remounts it, so nothing else should be using it.
CONFIG_TESTING_FS_XIPFS_MTDThe MTD device backing that volume, needed for the remounts.
Note
The suite writes and erases the volume continuously, the power-loss sections most of all. Point it at a volume whose contents do not matter.