Repository navigation
tests: Add novaGround testing, hardware simulation, and the support for bench testing - #17
Draft
Awesome-Ace22 wants to merge 18 commits into
Draft
Awesome-Ace22 wants to merge 18 commits into
Awesome-Ace22 wants to merge 18 commits into
Conversation
…e related interfaces
…ate related components
…update related components
…ta saving validation
#16) This pull request introduces a major refactor to support simulated hardware for development and CI, adds comprehensive documentation for the simulation mode, and improves the architecture and testability of the codebase. The most significant changes are the introduction of the `novaMock` build (the real application running on simulated hardware), a clear separation between hardware interfaces and implementations, and improved test coverage with scenario-driven simulation. Additionally, the PR updates build scripts, documentation, and controller interfaces to enable these features. **Simulation and Build System Enhancements:** - Added a new `novaMock` executable that runs the real application logic on simulated hardware, using a scenario-driven simulator for DAQ, relays, servos, and GPIO, making it possible to build and test on non-Pi systems and in CI. The build system (`meson.build`) now conditionally builds `novaMock` and its integration test if dependencies are available. [[1]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L15-R133) [[2]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L90-R189) [[3]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L122-L143) [[4]](diffhunk://#diff-1da7a27709d11ac16eef3de8e46ed10672b7b1d63a790ffbcbd23a94b19efdcbL127-R143) - Updated the build process to separate core, simulated, and real hardware code, and only require hardware-specific libraries when building for real hardware. [[1]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L15-R133) [[2]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L90-R189) **Documentation Improvements:** - Added a new `docs/simulation.md` describing how the simulated hardware works, how to use scenario files to drive tests, and how to run tests in CI or on a laptop. Updated `docs/setup.md` to clarify the purpose and capabilities of `novaMock`. [[1]](diffhunk://#diff-e3501cd20d40eb121af21a267e97e556d196388980cca1559af350fa957c131cR1-R74) [[2]](diffhunk://#diff-4ca53116333428d7d34e6d2a9a64069655c8c37d5d36b856320ac1a0c4cb9b23L89-R89) **Controller and Interface Refactoring:** - Refactored controller classes (`GpioController`, `RelayController`) to depend on abstract interfaces (`DigitalIo`, `RelayBank`) instead of hardware-specific implementations, improving modularity and enabling simulation. [[1]](diffhunk://#diff-6a7261f77069ec7be4b56cc46a2241c11cf5040a218ddd5fff0961519b89c290L7-R11) [[2]](diffhunk://#diff-6a7261f77069ec7be4b56cc46a2241c11cf5040a218ddd5fff0961519b89c290L30-R39) [[3]](diffhunk://#diff-667fe70f66ffdb7b045df42e085eb3458c684ad8055d65edb994d754d76cd3adL6-R17) [[4]](diffhunk://#diff-8fee36982e6354b6d3e6fc59537c3350327c4c079874b21d76f1ba2ef2c240ccL7-R7) [[5]](diffhunk://#diff-bad323bc8e99a2dc677000108e7d7448d9d1926280bd472d2490c25fd7617778L9-R21) **Sampling and Loop Improvements:** - Replaced previous sampling loops with new, interruptible loops that support cooperative cancellation via `std::stop_token`, improving shutdown behavior and testability. Added new `sampler.cpp` with single-sample and loop functions for DAQ and GPIO, supporting both real and simulated hardware. [[1]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942R9-R25) [[2]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942L62-R83) [[3]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942L84-L97) [[4]](diffhunk://#diff-c6ca818f433b97cf971263d08271e737ddf6e709b666b26a2d14c99f14afd402R5-L18) [[5]](diffhunk://#diff-6e26440c0e67464783c82dbccc2774e79c72e0a01bb1b3eabdb923a985923761R1-R100) **Testing and CI Integration:** - Added an integration test (`novamock_smoke`) that runs the full application on simulated hardware, verifies telemetry and data logging, and runs automatically in CI if dependencies are present. [[1]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L15-R133) [[2]](diffhunk://#diff-1da7a27709d11ac16eef3de8e46ed10672b7b1d63a790ffbcbd23a94b19efdcbL127-R143) These changes collectively enable robust simulation, testing, and development workflows without requiring physical hardware. - Simulation and build system: - Added `novaMock` target and scenario-driven simulated hardware; updated `meson.build` and CI to support simulation and integration testing. [[1]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L15-R133) [[2]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L90-R189) [[3]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L122-L143) [[4]](diffhunk://#diff-1da7a27709d11ac16eef3de8e46ed10672b7b1d63a790ffbcbd23a94b19efdcbL127-R143) - Documentation: - Added `docs/simulation.md` and updated `docs/setup.md` to explain simulation and usage. [[1]](diffhunk://#diff-e3501cd20d40eb121af21a267e97e556d196388980cca1559af350fa957c131cR1-R74) [[2]](diffhunk://#diff-4ca53116333428d7d34e6d2a9a64069655c8c37d5d36b856320ac1a0c4cb9b23L89-R89) - Controller refactor: - Changed controllers to use abstract interfaces (`DigitalIo`, `RelayBank`) for better modularity and simulation support. [[1]](diffhunk://#diff-6a7261f77069ec7be4b56cc46a2241c11cf5040a218ddd5fff0961519b89c290L7-R11) [[2]](diffhunk://#diff-6a7261f77069ec7be4b56cc46a2241c11cf5040a218ddd5fff0961519b89c290L30-R39) [[3]](diffhunk://#diff-667fe70f66ffdb7b045df42e085eb3458c684ad8055d65edb994d754d76cd3adL6-R17) [[4]](diffhunk://#diff-8fee36982e6354b6d3e6fc59537c3350327c4c079874b21d76f1ba2ef2c240ccL7-R7) [[5]](diffhunk://#diff-bad323bc8e99a2dc677000108e7d7448d9d1926280bd472d2490c25fd7617778L9-R21) - Sampling/loop improvements: - Introduced interruptible, stop-token based sampling loops and refactored sampling logic for testability and simulation. [[1]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942R9-R25) [[2]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942L62-R83) [[3]](diffhunk://#diff-78a0ea2dacbb59812e5d3478ae1ae30b459dddb4811dda33ca498352ea126942L84-L97) [[4]](diffhunk://#diff-c6ca818f433b97cf971263d08271e737ddf6e709b666b26a2d14c99f14afd402R5-L18) [[5]](diffhunk://#diff-6e26440c0e67464783c82dbccc2774e79c72e0a01bb1b3eabdb923a985923761R1-R100) - Testing: - Added scenario-driven integration test for `novaMock` and improved test coverage in CI. [[1]](diffhunk://#diff-30d8f6be6320feeacf686be94f48c70869b52630e01ea625f0f15adc0d57c3e4L15-R133) [[2]](diffhunk://#diff-1da7a27709d11ac16eef3de8e46ed10672b7b1d63a790ffbcbd23a94b19efdcbL127-R143)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
This pull request introduces significant improvements to the build system, testing, and simulation support for the project. It adds a new hardware-free build mode for CI and development, improves documentation for simulated hardware, and enhances testability and script portability. The most important changes are grouped below.
Build system and simulation improvements:
Added a new Meson build option
hardwareto allow building only hardware-independent code and tests, enabling CI and laptop builds without requiring Pi-specific libraries. The build now produces anovaMockexecutable that runs the full application on simulated hardware, with scenario files controlling simulated sensors and faults. (meson_options.txt,meson.build,docs/simulation.md,docs/setup.md) [1] [2] [3] [4] [5] [6]Refactored the build system to split core, simulated, and real hardware code, and to only link hardware-dependent libraries when needed. The
novaMockexecutable and its smoke test are now only built and run if dependencies are available. (meson.build) [1] [2] [3]Continuous Integration and testing:
Enhanced CI workflow to add shell linting (
shellcheck), contract testing for scripts, BATS tests for scripts, and a newcore-testsjob that builds and tests hardware-free code on multiple architectures and with sanitizers. (.github/workflows/pr-checks.yml)Improved script testability by allowing all paths in
nova-pi.shandrun.shto be redirected to a scratch root via theNOVA_PI_ROOTenvironment variable. This enables safe testing without touching the real Pi. (nova-pi.sh,run.sh) [1] [2] [3] [4]Codebase cleanup and modernization:
Updated the GPIO controller to use the new
DigitalIointerface instead of the oldGPIO_Manager, improving abstraction and compatibility with simulated hardware. (src/controllers/gpio_controller.cpp,src/controllers/gpio_controller.hpp) [1] [2] [3]Improved the main control loops to support cooperative cancellation via
std::stop_token, and replaced busy-waiting with interruptible sleeps, making the code more robust and responsive to shutdown requests. (src/controllers/loops.cpp) [1] [2] [3]Other improvements:
.gitattributes)Closes UTATRocketry/Nova-Collected#4
How was this tested?
Hardware impact
hardware-risklabel; a lead must approve!, link the matching PRs:Checklist
dev(ormainfor a release/hotfix, or with a reason given above).envfiles or build output committed