Skip to content

Add further bsp platform and safety lib Bazel tests - #626

Merged
christophruethingbmw merged 1 commit into
eclipse-openbsw:mainfrom
esrlabs:cr-1215936
Sep 23, 2026
Merged

christophruethingbmw merged 1 commit into
eclipse-openbsw:mainfrom
esrlabs:cr-1215936

Conversation

@DominikAFischer

@DominikAFischer DominikAFischer commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Add Bazel cc_test targets: bsp platform and safety libs

New cc_test targets with the build_variant:unit_test constraint:

  • platforms/s32k1xx/bsp/bspCore: bsp_core_test
  • platforms/s32k1xx/bsp/bspIo: bsp_io_test
  • platforms/s32k1xx/bsp/bspEepromDriver: bsp_eeprom_driver_test_s32k1
  • platforms/posix/bsp/bspEepromDriver: bsp_eeprom_driver_test
  • platforms/s32k1xx/bsp/bspUart: bsp_uart_test
  • executables/referenceApp/platforms/posix/safety/safeLifecycle: safe_lifecycle_test

Fix platforms/s32k1xx/bsp/bspIo

  • Collapsed bsp_io_headers and bsp_io_impl into a single bsp_io target to match the CMake bspIo library.
  • Removed bsp_io_mock because the CMake bspIoMock never builds and nothing depends on it.
  • Dropped bsp_adc and the redundant bsp_eeprom_driver and bsp_mcu deps that are not part of the CMake bspIo.
  • Updated bsp_io consumers to reference bsp_io.

Fix platforms/s32k1xx/bsp/bspAdc

  • Split bspAdc into bsp_adc_headers and bsp_adc so bsp_configuration_headers can depend on the ADC headers without a cycle.

NOTE: safe_lifecycle_test uses linkstatic = True

Bazel links cc_test targets dynamically by default, so all shared library symbols must resolve at link time. CMake links test executables statically, so unused translation units are never pulled from archives and their symbols are never referenced. safe_lifecycle_test uses linkstatic = True to replicate CMake's static linking behavior for two symbols that have no unit-test-compatible provider.

  • util::logger::SAFETY is declared via DECLARE_LOGGER_COMPONENT in safeUtils/SafetyLogger.h but defined only in the application layer, so no unit-test dep graph provides it. A clean fix is to add DEFINE_LOGGER_COMPONENT(SAFETY) inside safeLifecycle in SafetyManager.cpp or a dedicated SafetyLogger.cpp, following the same pattern as blob/Logger.cpp and can/CanLogger.cpp.

  • terminal_cleanup is called by platforms/posix/bsp/bspMcu and defined only in platforms/posix/bsp/bspStdio, which carries the full posix UART stack and is not suitable as a unit-test dep. A clean fix would be a unit-test-specific stub.

@DominikAFischer
DominikAFischer marked this pull request as draft September 18, 2026 06:22
@DominikAFischer
DominikAFischer force-pushed the cr-1215936 branch 3 times, most recently from 8a2046b to 8bae10f Compare September 18, 2026 15:49
New cc_test targets with build_variant:unit_test constraint:
- platforms/s32k1xx/bsp/bspCore: bsp_core_test
- platforms/s32k1xx/bsp/bspIo: bsp_io_test
- platforms/s32k1xx/bsp/bspEepromDriver: bsp_eeprom_driver_test_s32k1
- platforms/posix/bsp/bspEepromDriver: bsp_eeprom_driver_test
- platforms/s32k1xx/bsp/bspUart: bsp_uart_test
- executables/referenceApp/platforms/posix/safety/safeLifecycle: safe_lifecycle_test

Fix platforms/s32k1xx/bsp/bspIo:
- Collapse bsp_io_headers and bsp_io_impl into a single bsp_io target to match the CMake bspIo library.
- Remove bsp_io_mock because the CMake bspIoMock never builds and nothing depends on it.
- Drop bsp_adc and the redundant bsp_eeprom_driver and bsp_mcu deps that are not part of the CMake bspIo.
- Update bsp_io consumers to reference bsp_io.

Fix platforms/s32k1xx/bsp/bspAdc:
- Split bspAdc into bsp_adc_headers and bsp_adc so bsp_configuration_headers can depend on the adc headers without a cycle.

NOTE: safe_lifecycle_test uses linkstatic = True because symbols in its transitive
dep graph have no unit-test-compatible provider, so static linking pulls in only the
objects the include test references.

Change-Id: I3f91cad55ea5eec9f6106bed37b1a575806dc5a4
@DominikAFischer
DominikAFischer marked this pull request as ready for review September 22, 2026 11:19
@christophruethingbmw
christophruethingbmw merged commit 7b95a24 into eclipse-openbsw:main Sep 23, 2026
145 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