Skip to content

Conversation

@linguini1
Copy link
Contributor

@linguini1 linguini1 commented Dec 23, 2025

Summary

This commit introduces a Kconfig switch to include the cmocka binary built from cmocka_main.c. The default behaviour is now changed so that cmocka is built as a library only, which would be the desired behaviour for users creating their own cmocka projects.

Impact

Cmocka is now only built as a library, so the cmocka binary is no longer
included by default.

PR (apache/nuttx#17653) to the NuttX kernel preserves the compilation of the cmocka binary for the two existing defconfigs which use the cmocka application.

Testing

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>

@linguini1
Copy link
Contributor Author

Build is failing because sim:citest needs the change in apache/nuttx#17653

This commit introduces a Kconfig switch to include the cmocka binary
built from cmocka_main.c. The default behaviour is now changed so that
cmocka is built as a library only, which would be the desired behaviour
for users creating their own cmocka projects.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
@linguini1
Copy link
Contributor Author

Any ideas why the CI test is failing? It seems that the cmocka binary is present, just an assertion is failing.

@acassis
Copy link
Contributor

acassis commented Dec 26, 2025

@linguini1 it is saying that boards/risc-v/qemu-rv/rv-virt/configs/citest/logs/ is not tracked, not sure if it needs to be.

Maybe @simbit18 or @lupyuen has some idea, they know more about the citest

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