Skip to content

testing/nuts: NuttX Unit Test Selection (NUTS) application. - #3278

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
linguini1:nest-cmocka
Dec 28, 2025
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
linguini1:nest-cmocka

Conversation

@linguini1

@linguini1 linguini1 commented Dec 24, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Introduces a collection of unit tests for NuttX, built on top of the cmocka framework. Tests are organized into suites/groups which can be individually included/excluded from the build using Kconfig. Output is easily legible and separated with headers including the test group name.

Docs provided in this PR: apache/nuttx#17697

Impact

Beginning of a more convenient NuttX testing method, with easily readable
console output for pass/fail results and extendable test collections.

Testing

Run on sim to obtain pass/fail results for the initial test cases:

nsh> nuts
[==========] struct circbuf_s: Running 4 test(s).
[ RUN      ] init_local
[       OK ] init_local
[ RUN      ] init_malloc
[       OK ] init_malloc
[ RUN      ] empty_local
[       OK ] empty_local
[ RUN      ] empty_malloc
[       OK ] empty_malloc
[==========] struct circbuf_s: 4 test(s) run.
[  PASSED  ] 4 test(s).
[==========] list_node: Running 5 test(s).
[ RUN      ] empty_after_init
[       OK ] empty_after_init
[ RUN      ] zerolen_after_init
[       OK ] zerolen_after_init
[ RUN      ] notail_after_init
[       OK ] notail_after_init
[ RUN      ] nohead_after_init
[       OK ] nohead_after_init
[ RUN      ] static_null_init
[       OK ] static_null_init
[==========] list_node: 5 test(s) run.
[  PASSED  ] 5 test(s).
[==========] /dev/console: Running 5 test(s).
[ RUN      ] open_rdonly
[       OK ] open_rdonly
[ RUN      ] open_rdwr
[       OK ] open_rdwr
[ RUN      ] open_wronly
[       OK ] open_wronly
[ RUN      ] readzero
[       OK ] readzero
[ RUN      ] writezero
[       OK ] writezero
[==========] /dev/console: 5 test(s) run.
[  PASSED  ] 5 test(s).
[==========] /dev/null: Running 8 test(s).
[ RUN      ] open_rdonly
[       OK ] open_rdonly
[ RUN      ] open_rdwr
[       OK ] open_rdwr
[ RUN      ] open_wronly
[       OK ] open_wronly
[ RUN      ] readzero
[       OK ] readzero
[ RUN      ] readlarge
[       OK ] readlarge
[ RUN      ] writezero
[       OK ] writezero
[ RUN      ] writelarge
[       OK ] writelarge
[ RUN      ] wrrd
[       OK ] wrrd
[==========] /dev/null: 8 test(s) run.
[  PASSED  ] 8 test(s).
[==========] /dev/zero: Running 8 test(s).
[ RUN      ] open_rdonly
[       OK ] open_rdonly
[ RUN      ] open_rdwr
[       OK ] open_rdwr
[ RUN      ] open_wronly
[       OK ] open_wronly
[ RUN      ] readzero
[       OK ] readzero
[ RUN      ] readlarge
[  ERROR   ] --- 64 != 0
[   LINE   ] --- devices/devzero.c:143: error: Failure!
[  FAILED  ] readlarge
[ RUN      ] writezero
[       OK ] writezero
[ RUN      ] writelarge
[       OK ] writelarge
[ RUN      ] wrrd
[       OK ] wrrd
[==========] /dev/zero: 8 test(s) run.
[  PASSED  ] 7 test(s).
[  FAILED  ] /dev/zero: 1 test(s), listed below:
[  FAILED  ] readlarge

 1 FAILED TEST(S)

@linguini1

Copy link
Copy Markdown
Contributor Author

I don't like having all the conditional inclusion of test files in the Makefile/CMakeLists.txt. Does anyone know of a better way? The only other one I can think of is surrounding the contents of the C files with an #ifdef CONFIG_TESTING_NUTS_GROUP_TEST conditional, but that is messy.

Comment thread testing/nuts/devices/devurandom.c Resolved
Comment thread testing/nuts/devices/devurandom.c Resolved
Comment thread testing/nuts/dstructs/cbuf.c Resolved
Comment thread testing/nuts/dstructs/cbuf.c Resolved
Comment thread testing/nuts/dstructs/cbuf.c Resolved
Comment thread testing/nuts/dstructs/cbuf.c Resolved
Comment thread testing/nuts/dstructs/cbuf.c Resolved
@acassis

acassis commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

@linguini1 impressive work! Kudos!!!

michallenc
michallenc previously approved these changes Dec 27, 2025
Introduces a collection of unit tests for NuttX, built on top of the
cmocka framework. Tests are organized into suites/groups which can be
individually included/excluded from the build using Kconfig. Output is
easily legible and separated with headers including the test group name.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
@xiaoxiang781216
xiaoxiang781216 merged commit 3931094 into apache:master Dec 28, 2025
40 checks passed
@linguini1
linguini1 deleted the nest-cmocka branch December 28, 2025 02:46
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.

4 participants