Skip to content

Conversation

@leighgarbs
Copy link
Contributor

@leighgarbs leighgarbs commented Nov 19, 2025

Checklist (Please check before submitting)

Describe the contribution

Testing performed
I branched cFS and added a few commits demonstrating how this OSAL change enables strerror_r to be covered in unit tests. The cFS branch is add-strerror-r-stub.

The first commit initializes the build. The second commit sets sample_app to a version I've edited to build its unit tests against the UtAssert libc stub library and to have a trivial use of strerror_r. Building this commit fails with:

[ 96%] Building C object apps/sample_app/unit-test/CMakeFiles/coverage-sample_app-sample_app-object.dir/home/lgarbs/cFS/apps/sample_app/fsw/src/sample_app.c.o
/home/lgarbs/cFS/apps/sample_app/fsw/src/sample_app.c: In function 'SAMPLE_APP_Main':
/home/lgarbs/cFS/apps/sample_app/fsw/src/sample_app.c:52:5: error: implicit declaration of function 'strerror_r'; did you mean 'strerror'? [-Werror=implicit-function-declaration]
   52 |     strerror_r(0, error_str, 256);
      |     ^~~~~~~~~~
      |     strerror
cc1: all warnings being treated as errors
make[7]: *** [apps/sample_app/unit-test/CMakeFiles/coverage-sample_app-sample_app-object.dir/build.make:76: apps/sample_app/unit-test/CMakeFiles/coverage-sample_app-sample_app-object.dir/home/lgarbs/cFS/apps/sample_app/fsw/src/sample_app.c.o] Error 1
make[6]: *** [CMakeFiles/Makefile2:10121: apps/sample_app/unit-test/CMakeFiles/coverage-sample_app-sample_app-object.dir/all] Error 2
make[5]: *** [Makefile:146: all] Error 2
make[4]: *** [CMakeFiles/native_default_cpu1-install.dir/build.make:70: CMakeFiles/native_default_cpu1-install] Error 2
make[3]: *** [CMakeFiles/Makefile2:570: CMakeFiles/native_default_cpu1-install.dir/all] Error 2
make[2]: *** [CMakeFiles/Makefile2:260: CMakeFiles/mission-install.dir/rule] Error 2
make[1]: *** [Makefile:192: mission-install] Error 2
make: *** [Makefile:126: install] Error 2

The third commit sets OSAL to the commit on this PR, and should build.

The actual build steps are:

make SIMULATION=native ENABLE_UNIT_TESTS=true prep
make install

Expected behavior changes

  • API Change: Adds OCS_strerror_r and strerror_r to the API exposed to UtAssert unit tests that build against the libc stub library.
  • Behavior Change: UtAssert unit tests of content using the libc strerror_r function build, and strerror_r is stub-able.

System(s) tested on

  • Hardware: PC
  • OS: Ubuntu 22.04
  • Versions: the current development version of cFS, plus sample_app and OSAL version changes as described in the "Testing performed" section above

Contributor Info - All information REQUIRED for consideration of pull request
Leigh Garbs, NASA

@leighgarbs leighgarbs marked this pull request as ready for review November 20, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a UtAssert libc strerror_r stub

1 participant