Skip to content

testing/testsuites: Build the file_get case only in a flat build. - #4080

Open
casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:testsuites-fs-kernel-build-up
Open

casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:testsuites-fs-kernel-build-up

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

Summary

cmocka_fs_test (CONFIG_CM_FS_TEST) does not build in a protected or a kernel build. The case test_nuttx_fs_file_get01 calls file_get() and file_put() and reads struct file. These are kernel functions, not system calls, so a user program cannot use them.

  • Kernel build: stdio.h does not include nuttx/fs/fs.h for programs, so fs_file_get_test.c does not compile: "implicit declaration of function 'file_get'", "implicit declaration of function 'file_put'", "invalid use of undefined type 'struct file'".
  • Protected build: the user blob does not link: "undefined reference to file_get2'", "undefined reference to file_put'".

This PR builds the case and its entry in the test list only with CONFIG_BUILD_FLAT, as the suite already does with CONFIG_ARCH_SIM for other cases. The other 45 cases use only the POSIX interface and do not change.

Impact

Flat builds: no change, test_nuttx_fs_file_get01 still runs. Protected and kernel builds: cmocka_fs_test builds and runs without this one case. The change is in the C sources only, so the Make and the CMake builds both get it.

CI runs the fs cases one by one from apache/nuttx-ntfc-testing (fs/fs/test_fs_integration.py, which names test_nuttx_fs_file_get01). The configurations with CONFIG_CM_FS_TEST (rv-virt:citest, sim:citest) are flat builds, so the CI run does not change.

Testing

CONFIG_TESTS_TESTSUITES, CONFIG_CM_FS_TEST, CONFIG_TESTS_TESTSUITES_MOUNT_DIR="/tmp" (tmpfs), nuttx master e9eefaa0e9a:

Configuration apps master 72937e7 this PR
qemu-armv8a:nsh (flat, arm64, QEMU HVF) 46 of 46 pass 46 of 46 pass, file_get01 included
qemu-armv8a:knsh (kernel, arm64, QEMU HVF) does not compile (errors above) 45 of 45 pass
rv-virt:knsh64 (kernel, rv64) does not compile (errors above) builds
rv-virt:pnsh64 (protected, rv64) does not link (errors above) builds

On qemu-armv8a:knsh the run used CONFIG_TLS_LOG2_MAXSTACK=14, because the default stack of the suite (16384) is larger than the 8 KiB limit of that configuration and exec fails with EINVAL. The table uses the Make build. The CMake build of qemu-armv8a:nsh and rv-virt:pnsh64 with this PR passes too. ostest passes on qemu-armv8a:knsh and qemu-armv8a:nsh.

tools/checkpatch.sh -c -u -m -g passes.

test_nuttx_fs_file_get01 calls file_get() and file_put() and reads
struct file.  These are kernel functions, not system calls.  A program
of a protected or kernel build cannot call them, so cmocka_fs_test
does not build there:

- kernel build: stdio.h does not include nuttx/fs/fs.h, and the case
  does not compile (implicit declaration of file_get and file_put,
  invalid use of undefined type struct file).
- protected build: the user blob does not link (undefined reference
  to file_get2 and file_put).

Build the case and its entry in the test list only with
CONFIG_BUILD_FLAT.  A flat build still runs it.  The other fs cases
use only the POSIX interface and run in all build modes.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant