casaroli opened a new pull request, #4002: URL: https://github.com/apache/nuttx-apps/pull/4002
depends-on: apache/nuttx/pull/21613 ## Summary No test in nuttx-apps covers `open()` of a directory without O_DIRECTORY, or `open()` of a file with O_DIRECTORY. `testing/testsuites` has one case for the first, and it is disabled with `#if 0` (`fs_open_test.c`, "fatfs will fail"). This PR adds `testing/fs/diropen`, a test of the POSIX rules: - For a directory D with an entry E: `open(D, O_WRONLY)` and `open(D, O_RDWR)` fail with EISDIR. `open(D, O_RDONLY)` gives a descriptor: `fstat()` says it is a directory, `openat()` opens E relative to it, `fdopendir()` and `readdir()` find E. `open(D, O_RDONLY | O_DIRECTORY)` with `fdopendir()` and `readdir()` also finds E. - For a file F: `open(F, O_RDONLY | O_DIRECTORY)` and `opendir(F)` fail with ENOTDIR. - In a writable directory, the test makes D and the regular file D/a, and checks that D/a still opens for read and for append. The test runs the cases on the pseudo file system (`/dev` with `null`, `/` with `dev`, and a new directory made with `mkdir()`), on a tmpfs that it mounts when the kernel has one, and in each directory given as an argument, for example a hostfs, v9fs or rpmsgfs mount: `diropen /host`. It prints one PASS or FAIL line per case and returns EXIT_FAILURE when a case fails. It is a standalone program in `testing/fs`, as `fatgap`, not a `testing/testsuites` case: the cases must run on several file systems in one run, and the testsuites run their file system cases only in `CONFIG_TESTS_TESTSUITES_MOUNT_DIR`. The program also needs no cmocka, so it builds in kernel builds and on small boards. ## Impact Test only. New option `TESTING_DIROPEN`, default n, `depends on !DISABLE_MOUNTPOINT` (the test calls `mount()` for its tmpfs). No defconfig sets it, so CI builds and runs nothing new. ## Testing `diropen`, nuttx master vs apache/nuttx#21613, pass / fail: | Configuration | Argument | nuttx master | with apache/nuttx#21613 | ostest | |---|---|---|---|---| | sim:nsh (flat, macOS host), make | hostfs `/host` | 23 / 15 | 47 / 0 | status 0 / 0 | | qemu-armv8a:nsh (flat), make, HVF | v9fs `/system` | 21 / 17 | 47 / 0 | status 0 / 0 | | qemu-armv8a:knsh (kernel), make, HVF | v9fs `/system` | 21 / 17 | 47 / 0 | status 0 / 0 | | mps2-an500:knsh (protected), make, QEMU TCG | none | 15 / 11 | 35 / 0 | not run | | qemu-armv8a:rpserver + rpproxy over ivshmem, QEMU TCG on a Linux host | rpmsgfs `/srv` | 24 / 14 | 47 / 0 | not run | | qemu-armv8a:nsh, CMake | - | build only, 0 warnings | build only, 0 warnings | - | | qemu-armv8a:nsh, make, `DISABLE_MOUNTPOINT=y` (and `FS_PROCFS` off: the board mounts procfs) | - | - | `TESTING_DIROPEN` drops out, build OK, 0 warnings | - | On master the pseudo-fs directories fail with ENXIO, `/dev/null` opens with O_DIRECTORY, and the hostfs, v9fs and rpmsgfs directories fail as apache/nuttx#21613 describes. The tmpfs cases pass with both. The mps2-an500 and rpmsgfs rows ran on an earlier version of the two PRs with the same cases. `tools/checkpatch.sh -c -u -m -g` passes. Not run: FAT, littlefs, romfs and other file systems as the argument; real hardware. -- 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]
