Skip to content

testing/cmocka: start test programs with posix_spawn - #4190

Open
anjiahao1 wants to merge 1 commit into
apache:masterfrom
anjiahao1:20261130_cmocka-posix-spawn
Open

anjiahao1 wants to merge 1 commit into
apache:masterfrom
anjiahao1:20261130_cmocka-posix-spawn

Conversation

@anjiahao1

Copy link
Copy Markdown
Contributor

Summary

Start each cmocka test program with posix_spawn().

exec_builtin() replaces the calling task with the test program, so the
runner can only wait for the pid it happens to return, and the
environment and argument list are fixed by the builtin interface.
Start each test with posix_spawn() instead and wait for the pid it
provides: the test runs as a separate task, the runner keeps its own
context, and the environment can be passed. Add the LIBC_EXECFUNCS
dependency that the spawn call needs.

Impact

  • Is new feature added? NO - test runner fix.
  • Impact on user: NO
  • Impact on build: YES - TESTING_CMOCKA now requires LIBC_EXECFUNCS.
  • Impact on hardware: NO
  • Impact on documentation: NO
  • Impact on security: NO
  • Impact on compatibility: NO

Testing

Build host: Linux x86_64, gcc 13.3.

tools/configure.sh -a <apps> sim:nsh
# enable CONFIG_TESTING_CMOCKA, CONFIG_TESTING_CMOCKA_PROG,
# CONFIG_LIBC_REGEX (with ALLOW_MIT_COMPONENTS) and CONFIG_LIBC_EXECFUNCS
make -j$(nproc)

The build completes; the log shows both the runner and the library
compiled:

CC: .../testing/cmocka/cmocka_main.c
CC: cmocka/src/cmocka.c
LD: nuttx

The cmocka sources are downloaded by the existing Makefile rule.

PR verification

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation.
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

GUIDINGLI
GUIDINGLI previously approved these changes Nov 30, 2026
@GUIDINGLI

Copy link
Copy Markdown
Contributor

@anjiahao1

CI fail

d76a018 Merge 9fc7770 into 9a2c689
9fc7770 testing/cmocka: start test programs with posix_spawn
../nuttx/tools/checkpatch.sh -c -u -m -g 9a2c689..HEAD
Used config files:
1: .codespellrc
/home/runner/work/nuttx-apps/nuttx-apps/apps/testing/cmocka/cmocka_main.c:159: infomation ==> information
Some checks failed. For contributing guidelines, see:
https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.

exec_builtin() replaces the calling task with the test program, so the
only thing the runner can do afterwards is wait for the pid it
returned, and the environment and argument list are fixed by the
builtin interface.  Start each test with posix_spawn() instead and wait
for the pid it provides; the test runs as a separate task and the
runner keeps its own context.  Keep the exec_builtin() path when
CONFIG_LIBC_EXECFUNCS is not selected, so the configurations that do
not provide posix_spawn() still build and run the suite.

Signed-off-by: anjiahao <anjiahao@xiaomi.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.

3 participants