diff --git a/.gitmodules b/.gitmodules index e69de29bb..ed69927d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests/arduino_core_tests"] + path = tests/arduino_core_tests + url = https://github.com/Infineon/arduino-core-tests.git diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..52ad2880b --- /dev/null +++ b/tests/README.md @@ -0,0 +1,53 @@ +# Arduino core test configuration + +Configuration for the shared +[`arduino-core-tests`](https://github.com/Infineon/arduino-core-tests) suite +(vendored at [`arduino_core_tests`](arduino_core_tests)) lives +in a single file, `tests/test_config.h`, exactly where that submodule's own +Makefile expects it (`../../tests/test_config.h`, relative to the submodule). + +One file, with a `#if defined(ARDUINO_)` block per board. +`arduino-cli` already defines `ARDUINO_{build.board}` for every compile, so +the right block is selected automatically. + +## Adding a board + +1. Add a `#if defined(ARDUINO_)` block to `tests/test_config.h`, using + the board's `build.board` value from `boards.txt` (e.g. `KIT_PSE84_AI`). +2. Define the pins required by the selected tests, using Arduino pin numbers + (e.g. `D0`), not MCU port/pin names. +3. Verify each Arduino pin against the board's variant overlay + (`variants//*.overlay`, `zephyr,user` / `digital-pin-gpios`) and + the board schematic or official pinout. +4. Document any required jumpers or external connections next to the block. + +For example, `test_digitalio_single` requires two physically connected GPIOs: + +```c +#if defined(ARDUINO_) +#define TEST_PIN_DIGITAL_IO_OUTPUT +#define TEST_PIN_DIGITAL_IO_INPUT +#endif +``` + +## Running a test + +```bash +make -C tests/arduino_core_tests FQBN= UNITY_PATH=Unity \ + TESTS=-DTEST_DIGITALIO_SINGLE test_digitalio_single compile +``` + +To flash and run on a single connected board, add `PORT=` and +`ENABLE_SYNC=0`: + +```bash +make -C tests/arduino_core_tests FQBN= UNITY_PATH=Unity PORT= \ + TESTS=-DTEST_DIGITALIO_SINGLE ENABLE_SYNC=0 test_digitalio_single +``` + +`ENABLE_SYNC` defaults to `1`: tests named `*_connected2_*` (e.g. +`test_wire_connected2_masterpingpong`) need two boards and wait for each +other's handshake over serial, so leave it enabled for those. Tests named +`*_single` (or loopback tests like `test_spi_connected1_loopback`) only use +one board; without `ENABLE_SYNC=0` they hang forever printing +`synchronising with host...`, since nothing ever answers the handshake. diff --git a/tests/arduino_core_tests b/tests/arduino_core_tests new file mode 160000 index 000000000..0f52c0291 --- /dev/null +++ b/tests/arduino_core_tests @@ -0,0 +1 @@ +Subproject commit 0f52c0291cc344206846c01cfbc8590fab0844f7 diff --git a/tests/test_config.h b/tests/test_config.h new file mode 100644 index 000000000..545a776b7 --- /dev/null +++ b/tests/test_config.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) Infineon Technologies AG + * + * SPDX-License-Identifier: Apache-2.0 + * + * Board-specific test pin definitions for tests/arduino_core_tests. + * + * Each board adds its own #if defined(ARDUINO_) block below (see + * tests/README.md). This file intentionally has no board blocks of its own: + * board-specific content belongs to the branch that owns that board. + */ +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +#endif // TEST_CONFIG_H