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.fdpicLoads FDPIC modules from the volume and checks the loader: function descriptors that the loader makes, a module bound entirely through
DT_JMPREL, callbacks from the firmware into a module (qsort(),scandir(),pthread_create(),pthread_once(),signal(),sigaction(),task_create(),task_spawn(),mq_notify()andtimer_create()withSIGEV_THREAD), a module without the FDPIC marker, aDT_NEEDEDlibrary and its pins, and C++ constructors and destructors in a library and a module. Only withCONFIG_FDPIC.rejectChecks that the FDPIC loader refuses a malformed module: an ELF class that is not 32-bit, an object that is not
ET_DYN, a module for another machine, RELA PLT relocations, aDT_NEEDEDlibrary that is absent, an import that the firmware does not export, and moreDT_NEEDEDentries thanCONFIG_LIBC_ELF_MAXDEPEND. Only withCONFIG_FDPIC.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,dirloss,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,
mkdirandrmdir, and compaction. Thetornvariant 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.
With CONFIG_FDPIC, the application build makes the test modules from
apps/examples/fdpicxip/modules and links them into xipfs_test. This
needs the arm-uclinuxfdpiceabi linker; see FDPIC Modules.
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.