Skip to content

simlibs tests#145

Merged
jonyMarino merged 1 commit intomainfrom
IAMAI/simlibs_test_fix_and_enhacement
May 7, 2026
Merged

simlibs tests#145
jonyMarino merged 1 commit intomainfrom
IAMAI/simlibs_test_fix_and_enhacement

Conversation

@jonyMarino
Copy link
Copy Markdown
Contributor

Fixes: #

About

This pull request introduces several improvements to the build system, test coverage, and CI workflows for the project. The main changes include enabling and expanding unit tests for core_sim, adding new test cases, updating CMake configurations for better compatibility, and enhancing CI pipelines for both Windows and Linux environments.

Test coverage and new tests:

  • Enabled the test subdirectory in core_sim to be included when BUILD_TESTING is set, allowing unit tests to be built and run. (core_sim/CMakeLists.txt)
  • Added multiple new test files to the core_sim/test suite, including tests for control mapping, battery, gimbal, tilt, rotor/wheel settings, noise model utilities, and various message types. (core_sim/test/CMakeLists.txt) [1] [2]
  • Improved documentation and clarity of existing test cases for Actuator, Airspeed, and Barometer by adding structured comments that describe the Arrange-Act-Assert pattern and the purpose of each test. (core_sim/test/gtest_actuator.cpp, core_sim/test/gtest_airspeed.cpp, core_sim/test/gtest_barometer.cpp) [1] [2] [3] [4] [5]

Build system improvements:

  • Updated the CMake configuration to pass /EHsc to the Assimp external project when building with MSVC, ensuring proper exception handling and avoiding warnings treated as errors. (CMakeLists.txt)

CI/CD workflow enhancements:

  • Added a new GitHub Actions workflow (test_linux_simlibs_debug.yml) to build and test simlibs in debug mode on Linux, including installation of prerequisites and configuration for Clang 18 compatibility. (.github/workflows/test_linux_simlibs_debug.yml)
  • Enhanced the Windows CI workflow to trigger on both pushes and pull requests to main, increased the timeout, updated the checkout action, and added a step to run SimLibs debug tests. (.github/workflows/test_windows.yml) [1] [2]

These changes collectively improve the project's reliability, maintainability, and cross-platform support.

How Has This Been Tested?

Screenshots and videos (if appropriate):

* Fix simlibs test discovery and MSVC assimp build flags

* Add pipeline to execute tests on PRs and merge with main

* Add new tests for simlibs

* Remove unnecesary test script

* Update workflow to merge test into 1 action to test on windows

* Comment line by line the test for core_sim

* Comment line by line already existing tests

* feat(physics): implement P1 test coverage for UnrealPhysics, PhysicsWorld, and MatlabPhysics backends

- Expand UnrealPhysicsBody tests (gtest_unreal_physics.cpp):
  * Added InitializeUnrealPhysicsBody test: verify rotor wrench points collected
  * Added CalculateExternalWrench test: verify wrench aggregation and finiteness
  * Added WriteRobotData test: verify kinematics propagation to robot
  * Added SetCallbackSetExternalWrench test: verify callback invoked with valid wrench
  * Added SetWrenchesOnPhysicsBody test: verify model dispatch to body wrench calculation
  * Tests use TestUnrealPhysicsBody harness to expose protected members

- Enhance PhysicsWorld tests (gtest_physics_world.cpp):
  * Added SetWrenchesOnPhysicsBodies test: verify wrench dispatch to all physics bodies
  * This covers the critical P1 gap for physics backend dispatch logic

- Create MatlabPhysics test suite (gtest_matlab_physics.cpp):
  * Added constructor tests for MatlabPhysicsBody (default + from robot)
  * Added WriteRobotData test: verify kinematics propagation to robot
  * Added ReadRobotData test: verify robot state extraction for serialization
  * Added CalculateExternalWrench test: verify rotor wrench aggregation
  * Added MatlabPhysicsModel constructor and SetWrenchesOnPhysicsBody tests
  * Coverage focuses on unit-level behavior; integration tests with live Matlab marked as TODO

- Update CMakeLists.txt to include gtest_matlab_physics.cpp in physics_gtests target

Test results:
- All 312 tests pass (100%)
- Tests follow established pattern: Arrange/Act/Assert with line-specific inline comments
- Comments are test-aware and describe specific code actions (not generic boilerplate)

Test coverage improvements:
- UnrealPhysics: 2 → 8 test cases (functional coverage of InitializeUnrealPhysicsBody, CalculateExternalWrench, callbacks)
- PhysicsWorld: 4 → 5 test cases (explicit SetWrenchesOnPhysicsBodies dispatch test)
- MatlabPhysics: 0 → 8 test cases (basic unit coverage of core lifecycle methods)

* Refactor Ubuntu CI workflow to build and test SimLibs

* Change build and test commands to release version

---------
Co-authored-by: Jonathan <jony@iamaisim.com>
@jonyMarino jonyMarino merged commit 06ec866 into main May 7, 2026
3 checks passed
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.

2 participants