Testing and Continuous Integration
The cFS project maintains a high standard of code quality through a robust testing framework and a comprehensive set of Continuous Integration (CI) workflows. This ensures stability, portability, and security across the codebase.
CI Workflows
The project's CI is managed via GitHub Actions. The workflows, defined in the .github/workflows/
directory, automatically build and test the software on every push and pull request.
Key CI workflows include:
build-cfs.yml
: The primary build-and-test workflow. It compiles and runs cFS and its unit tests on an Ubuntu Linux environment with modern build flags (OMIT_DEPRECATED=true
).build-cfs-deprecated.yml
: A parallel workflow that ensures backward compatibility by building the system with deprecated features enabled (OMIT_DEPRECATED=false
).build-cfs-rtems4.11.yml
&build-cfs-rtems5.yml
: These workflows demonstrate the portability of cFS by building and testing the framework for the RTEMS (Real-Time Executive for Multiprocessor Systems) operating system, a popular choice for embedded and real-time systems. This cross-compilation and testing is performed within a Docker container.build-documentation.yml
: This workflow automatically generates and deploys user documentation, ensuring that reference materials stay up-to-date with the code.
Unit and Functional Testing
The project includes both unit tests for individual modules and a functional test application for system-level checks.
Running Unit Tests
To build the unit tests, you must enable them during the prep
step:
make SIMULATION=native ENABLE_UNIT_TESTS=true prep
make
make install
You can then run all unit tests using the test
target:
make test
Code Coverage
To generate a code coverage report using lcov
, run the following command after executing the unit tests:
make lcov
This will generate an HTML report in the lcov/
directory, showing line and branch coverage for the codebase.
Functional Testing
The cfe_testcase
application is included in the build when ENABLE_UNIT_TESTS
is true. The CI workflows demonstrate how to start this application and run a suite of functional tests against a live cFS instance.
Static Analysis and Formatting
To maintain code quality and prevent common errors, the CI pipeline integrates several static analysis tools.
CodeQL
: GitHub's static analysis engine is used to scan for security vulnerabilities on every push and pull request. The configuration is tailored to focus on security-related queries and coding standards like MISRA.Cppcheck
: A static analysis tool for C/C++ that checks for a wide range of bugs, including memory leaks, null pointer dereferences, and undefined behavior.Format Check
: This workflow usesclang-format
to enforce a consistent coding style across the project. The style is defined in the.clang-format
file. Contributors are expected to format their code according to these rules before submitting a pull request.