Skip to content

Conversation

@linguini1
Copy link
Contributor

@linguini1 linguini1 commented Dec 23, 2025

Summary

Depends on NuttX apps PR: apache/nuttx-apps#3270

The cmocka test framework is compiled as a library by default in (apache/nuttx-apps#3270), and does not include the cmocka application binary unless CONFIG_TESTING_CMOCKA_PROG=y. This commit updates the defconfigs which include cmocka to also compile the cmocka binary, which is the behaviour they were created with.

Impact

None, just preserves the behaviour of these two defconfigs.

Testing

Testing from apache/nuttx-apps#3270:

Compilation of the cmocka libary without the binary using sim:nsh as a basis:

$ make -j
Create version.h
LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
Register: dd
Register: nsh
Register: sh
Register: gcov
Register: hello
Register: dumpstack
Register: gpio
Register: ostest
CP:  /home/linguini/coding/nuttx-space/nuttx/include/nuttx/config.h
CP:  /home/linguini/coding/nuttx-space/nuttx/include/nuttx/fs/hostfs.h
LD:  nuttx
Pac SIM with dynamic libs..
'/usr/lib/libm.so.6' -> 'sim-pac/libs/libm.so.6'
'/usr/lib/libz.so.1' -> 'sim-pac/libs/libz.so.1'
'/usr/lib/libc.so.6' -> 'sim-pac/libs/libc.so.6'
'/usr/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/libs/ld-linux-x86-64.so.2'
'/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/ld-linux-x86-64.so.2'
SIM elf with dynamic libs archive in nuttx.tgz

Then, when disabling CONFIG_TESTING_CMOCKA_ASLIB, the compilation is:

$ make -j
Create version.h
LN: platform/board to /home/linguini/coding/nuttx-space/apps/platform/dummy
Register: cmocka
Register: hello
Register: nsh
Register: sh
Register: dd
Register: gcov
Register: gpio
Register: dumpstack
Register: ostest
CP:  /home/linguini/coding/nuttx-space/nuttx/include/nuttx/config.h
LD:  nuttx
Pac SIM with dynamic libs..
'/usr/lib/libm.so.6' -> 'sim-pac/libs/libm.so.6'
'/usr/lib/libz.so.1' -> 'sim-pac/libs/libz.so.1'
'/usr/lib/libc.so.6' -> 'sim-pac/libs/libc.so.6'
'/usr/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/libs/ld-linux-x86-64.so.2'
'/lib64/ld-linux-x86-64.so.2' -> 'sim-pac/ld-linux-x86-64.so.2'
SIM elf with dynamic libs archive in nuttx.tgz

and I can run the cmocka application on sim:

nsh> cmocka --help
an elegant unit testing framework for C with support for mock objects
Usage: cmocka [OPTION [ARG]] ...
 -?, --help       show this help statement
 -l, --list       display only the names of testcases and testsuite,
                  don't execute them
 -t, --test A     only run cases where case function name matches A pattern
 -p, --skip B     don't run cases where case function name matches B pattern
 -s, --suite C    only run suites where PROGNAME matches C pattern
 -f, --output-path use xml report instead of standard output
 -d, --shuffle-seed shuffling test sequence,between 0 and 99999,
                   when seed is 0,use time(NULL) as the seed for
                   the random number generator
Example: cmocka --suite mm|sched --test Test* --skip TestNuttxMm0[123]

nsh>
@acassis
Copy link
Contributor

acassis commented Dec 24, 2025

@linguini1 please normalize the config to fix this CI error:

modified:   boards/sim/sim/sim/configs/citest/defconfig
@linguini1
Copy link
Contributor Author

@linguini1 please normalize the config to fix this CI error:

modified:   boards/sim/sim/sim/configs/citest/defconfig

I think I might need to wait for the apps PR to be merged, since isn't the normalizer complaining that the config option doesn't exist in Kconfig?

@linguini1 linguini1 force-pushed the cmocka-as-lib branch 4 times, most recently from f1c449c to b71530c Compare December 31, 2025 19:24
The cmocka test framework is compiled as a library by default in
(apache/nuttx-apps#3270), and does not include the cmocka application
binary unless CONFIG_TESTING_CMOCKA_PROG=y. This commit updates the
defconfigs which include cmocka to also compile the cmocka binary, which
is the behaviour they were created with.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: risc-v Board: simulator Size: XS The size of the change in this PR is very small

2 participants