Files
zmk/app/run-test.sh
Pete Johanson 6690d535e6 refactor(core): Adjust our approach for upstream Zephyr boards (#3145)
refactor(core): Adjust our approach for upstream Zephyr boards

Move to using proper HWMv2 board extensions
https://docs.zephyrproject.org/4.1.0/hardware/porting/board_porting.html#board-extensions

for extending upstream Zephyr boards for use with ZMK. With this change,
using upstream Zephyr board IDs directly, e.g. `seeeduino_xiao` will be
stock versions as found upstream. To use a board variant that is tuned
for ZMK use, use the `zmk` variant, e.g. `seeeduino_xiao//zmk` which is
shorthand for `seeeduino_xiao/samd21g18a/zmk`.

refactor(boards): Move to ZMK specific variants for the nRFMicro board

For consistency, adjust the nRFMicro board definition to offer a
"vanilla" Zephyr board, and then ZMK variants, e.g.
`nrfmicro/nrf52840/zmk`.

refactor(boards): Move to ZMK specific variant for the bluemicro840 board

For consistency, adjust the bluemicro840 board definition to offer a
"vanilla" Zephyr board, and then ZMK variant, e.g. `bluemicro840//zmk`.

refactor(boards): Make tofu65 to ZMK variant by default

Make the standard Tofu65 board ID be `tofu65/rp2040/zmk` or
`tofu65//zmk` by shorthand.

refactor(boards): Move BDN9 to ZMK variant by default

Make the standard BDN9 board ID be `bdn9/stm32f072xb/zmk` or
`bdn9//zmk` by shorthand.

refactor(boards): Move Puchi BLE to ZMK variant by default

Make the standard Puchi BLE board ID be `puchi_ble/nrf52840/zmk` or
`puchi_ble//zmk` by shorthand.

refactor(boards): Move Adv360 Pro to ZMK variant by default

Make the standard Adv360 Pro board ID be `adv360pro_left/nrf52840/zmk` or
`adv360pro_left//zmk` by shorthand and for right as well.

refactor(boards): Move nRF52840 M2 to ZMK variant by default

Make the standard nRF52840 M2 board ID be `nrf52840_m2/nrf52840/zmk` or
`nrf52840_m2//zmk` by shorthand.

refactor(boards): Move Pillbug to ZMK variant by default

Make the standard Pillbug board ID be `pillbug/nrf52840/zmk` or
`pillbug//zmk` by shorthand.

refactor(boards): Move s40nc to ZMK variant by default

Make the standard s40nc board ID be `s40nc/nrf52840/zmk` or
`s40nc//zmk` by shorthand.

refactor(boards): Move nice!60 to ZMK variant by default

Make the standard nice!60 board ID be `nice60/nrf52840/zmk` or
`nice60//zmk` by shorthand.

refactor(boards): Move planck to ZMK variant by default

Make the standard planck board ID be `planck/stm32f303xc/zmk` or
`planck//zmk` by shorthand.

refactor(boards): Move preonic to ZMK variant by default

Make the standard preonic board ID be `preonic/stm32f303xc/zmk` or
`preonic//zmk` by shorthand.

refactor(boards): Move ferris to ZMK variant by default

Make the standard ferris board ID be `ferris/stm32f072xb/zmk` or
`ferris//zmk` by shorthand.

refactor(boards): Move Proton-C to ZMK variant by default

Make the standard Proton-C board ID be `proton_c/stm32f303xc/zmk` or
`proton_c//zmk` by shorthand.

refactor(boards): Move Corneish Zen to ZMK variant by default

Make the standard Corneish Zen board ID be `corneish_zen_left/nrf52840/zmk` or
`corneish_zen_left//zmk` by shorthand and for right as well.

refactor(boards): Move nice!nano to ZMK variant by default

Make the standard nice!nano board ID be `nice_nano/nrf52840/zmk` or
`nice_nano//zmk` by shorthand.

refactor(boards): Move mikoto to ZMK variant by default

Make the standard mikoto board ID be `mikoto/nrf52840/zmk` or
`mikoto//zmk` by shorthand.

refactor(boards): Move Polarity Works boards to ZMK variants

Make the standard Polarity Works board IDs be `zmk` variants.

doc: Update docs/blog post to reference ZMK variants

* Update Zephyr 4.1 blog post to mention ZMK variants
* Add note to hardware support page about variants

docs: Fix up shield board overlays for new board IDs

Adjust our documentation to properly use the correct qualified board
overlay file names that match our new board conventions.
2026-02-12 01:53:54 -05:00

86 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
##
# Optional environment variables, paths can be absolute or relative to $(pwd):
# ZMK_SRC_DIR: Path to zmk/app (default is ./)
# ZMK_BUILD_DIR: Path to build directory (default is $ZMK_SRC_DIR/build)
# ZMK_EXTRA_MODULES: Path to at most one module (in addition to any in west.yml)
# ZMK_TESTS_AUTO_ACCEPT: Replace snapshot files with new key events
# J: Number of parallel jobs (default is 4)
if [ -z "$1" ]; then
echo "Usage: ./run-test.sh <path to testcase>"
exit 1
fi
path="$1"
if [ $path = "all" ]; then
path="${ZMK_SRC_DIR-.}/tests"
fi
ZMK_BUILD_DIR=${ZMK_BUILD_DIR:-${ZMK_SRC_DIR:-.}/build}
mkdir -p ${ZMK_BUILD_DIR}/tests
testcases=$(find $path -name native_sim.keymap -exec dirname \{\} \;)
num_cases=$(echo "$testcases" | wc -l)
if [ $num_cases -gt 1 ] || [ "$testcases" != "$path" ]; then
echo "" >${ZMK_BUILD_DIR}/tests/pass-fail.log
echo "$testcases" | xargs -L 1 -P ${J:-4} ${0}
err=$?
sort -k2 ${ZMK_BUILD_DIR}/tests/pass-fail.log
exit $err
fi
testcase=$(realpath $path | sed -n -e "s|.*/tests/||p")
echo "Running $testcase:"
build_cmd="west build ${ZMK_SRC_DIR:+-s $ZMK_SRC_DIR} -d ${ZMK_BUILD_DIR}/tests/$testcase \
-b native_sim//zmk_test_mock -p -- -DCONFIG_ASSERT=y -DZMK_CONFIG="$(realpath $path)" \
${ZMK_EXTRA_MODULES:+-DZMK_EXTRA_MODULES="$(realpath ${ZMK_EXTRA_MODULES})"}"
# Add extra cmake arguments from file if it exists
if [ -f "$path/extra-cmake-args" ]; then
extra_args=$(cat "$path/extra-cmake-args" | tr '\n' ' ')
build_cmd="$build_cmd $extra_args"
fi
build_log_tmp="${ZMK_BUILD_DIR}/tmp/$testcase/build.log"
build_log="${ZMK_BUILD_DIR}/tests/$testcase/build.log"
mkdir -p $(dirname $build_log_tmp)
$build_cmd >"$build_log_tmp" 2>&1
build_exit_code=$?
mv "$build_log_tmp" "$build_log"
rmdir -p $(dirname $build_log_tmp) 2>/dev/null || true
if [ $build_exit_code -gt 0 ]; then
echo "FAILED: $testcase did not build (see ${build_log})" | tee -a ${ZMK_BUILD_DIR}/tests/pass-fail.log
exit 1
fi
${ZMK_BUILD_DIR}/tests/$testcase/zephyr/zmk.exe |
sed -e "s/.*> //" |
tee ${ZMK_BUILD_DIR}/tests/$testcase/keycode_events_full.log |
sed -n -f $path/events.patterns >${ZMK_BUILD_DIR}/tests/$testcase/keycode_events.log
diff -auZ $path/keycode_events.snapshot ${ZMK_BUILD_DIR}/tests/$testcase/keycode_events.log
if [ $? -gt 0 ]; then
if [ -f $path/pending ]; then
echo "PENDING: $testcase" | tee -a ${ZMK_BUILD_DIR}/tests/pass-fail.log
exit 0
fi
if [ -n "${ZMK_TESTS_AUTO_ACCEPT}" ]; then
echo "Auto-accepting failure for $testcase"
cp ${ZMK_BUILD_DIR}/tests/$testcase/keycode_events.log $path/keycode_events.snapshot
else
echo "FAILED: $testcase" | tee -a ${ZMK_BUILD_DIR}/tests/pass-fail.log
exit 1
fi
fi
echo "PASS: $testcase" | tee -a ${ZMK_BUILD_DIR}/tests/pass-fail.log
exit 0