[examples, tests] Refactor examples and tests directory#11
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the tests/ and examples/ directories to eliminate duplication and improve maintainability. Previously, each board (STM32WB, PIC32CZ) had its own copy of test code, test infrastructure, and board config. The new structure separates shared test logic by peripheral type, introduces a board abstraction layer (board.h/board.c/Board_Init), and uses preprocessor flags and Makefile wildcards to select board-specific test variants at build time.
Changes:
- Board support is now centralized in
tests/boards/<board>/andexamples/blinky/boards/<board>/, with shared test code intests/<peripheral>/. Per-board test infrastructure (oldtests/stm32wb/,tests/pic32cz/,examples/stm32wb/,examples/pic32cz/) is removed. - All test and helper function names are renamed from
camelCase(e.g.,whalTest_Puts) tosnake_PascalCase(e.g.,whal_Test_Puts), and test case functions fromtest_x_ytoTest_X_Y. - The
wolfHAL.humbrella header is updated to include the newspiandtimerheaders.
Reviewed changes
Copilot reviewed 55 out of 59 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
wolfHAL/wolfHAL.h |
Adds spi/spi.h and timer/timer.h includes to the umbrella header |
tests/test.h |
Renames all internal symbols from whalTest_* to whal_Test_* |
tests/main.c |
New shared HW test entry point with preprocessor-gated test dispatch |
tests/Makefile |
New unified Makefile with board selection and per-peripheral source selection |
tests/README.md |
Documents new test structure and build instructions |
tests/boards/stm32wb55xx_nucleo/board.*, ivt.c, linker.ld, Makefile.inc |
Board support files for STM32WB (new location) |
tests/boards/pic32cz_curiosity_ultra/board.*, ivt.c, linker.ld, Makefile.inc |
Board support files for PIC32CZ (new location) |
tests/clock/, tests/gpio/, tests/flash/, tests/rng/, tests/timer/ |
Reorganized peripheral tests, split into generic and platform-specific files |
tests/core/main.c, Makefile |
Renames test_sim target to test_core, updates function names |
tests/core/test_bitops.c, test_dispatch.c |
Renamed test functions to new convention |
tests/stm32wb/, tests/pic32cz/ |
Old per-board test directories removed |
examples/blinky/ |
New canonical blinky example replacing old examples/stm32wb/ and examples/pic32cz/ |
examples/stm32wb/, examples/pic32cz/ |
Old example directories removed |
.github/workflows/ci.yml |
CI updated to build new blinky and unified test targets |
Comments suppressed due to low confidence (1)
tests/gpio/test_stm32wb_gpio.c:52
- The platform-specific test entry-point functions (
whal_Test_Gpio_Platform,whal_Test_Clock_Platform,whal_Test_Flash_Platform) do not callWHAL_TEST_SUITE_STARTbefore running their tests. Since they are called immediately after their generic counterparts intests/main.c, their test results will be printed without any section header, making the output harder to interpret. Each platform-specific entry point should callWHAL_TEST_SUITE_STARTwith an appropriate label (e.g.,"gpio (stm32wb)") to make output consistent and readable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b266b4d to
fb70398
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 56 out of 59 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (5)
tests/clock/test_stm32wb_clock.c:37
- The
whal_Test_Clock_Platform,whal_Test_Gpio_Platform, andwhal_Test_Flash_Platformfunctions callWHAL_TESTdirectly without first callingWHAL_TEST_SUITE_STARTto label their section in the output. In contrast, all generic test functions (e.g.,whal_Test_Clock,whal_Test_Gpio,whal_Test_Flash) properly wrap their tests withWHAL_TEST_SUITE_START/WHAL_TEST_SUITE_END. Without a suite start, platform-specific test results appear in the output with no header, making it hard to identify which module they belong to. Each platform-specific test function should callWHAL_TEST_SUITE_STARTwith an appropriate name (e.g.,"clock_platform","gpio_platform","flash_platform") before calling anyWHAL_TEST.
tests/clock/test_pic32cz_clock.c:61 - Same issue as
test_stm32wb_clock.c:whal_Test_Clock_Platformdoes not callWHAL_TEST_SUITE_STARTbefore running tests, so its results appear unlabeled in the output. Add aWHAL_TEST_SUITE_STARTwith a descriptive name.
tests/gpio/test_stm32wb_gpio.c:52 - Same issue:
whal_Test_Gpio_Platformdoes not callWHAL_TEST_SUITE_START/WHAL_TEST_SUITE_END. Its test results appear in the output without a section header. AddWHAL_TEST_SUITE_STARTwith a descriptive suite name before theWHAL_TESTcalls.
tests/gpio/test_pic32cz_gpio.c:53 - Same issue:
whal_Test_Gpio_Platformdoes not callWHAL_TEST_SUITE_START/WHAL_TEST_SUITE_END, so its test results appear unlabeled. Add a suite header for consistency with the generic test functions.
tests/boards/stm32wb55xx_nucleo/board.c:127 Board_Deinitin the STM32WB tests board initializesg_whalFlashinBoard_Init(line 64) but never callswhal_Flash_DeinitinBoard_Deinit. The same asymmetry exists in the PIC32CZBoard_Deinit. WhileBoard_Deinitis not currently called fromtests/main.c, this is a latent inconsistency that could cause issues ifBoard_Deinitis called in the future.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fb70398 to
84fd7ce
Compare
[examples, tests] Refactor examples and tests directory
No description provided.