2020-08-29 06:21:31 +10:00
#!/bin/sh
2021-01-02 09:37:34 +11:00
2020-09-10 13:57:44 +10:00
# Copyright (c) 2020 The ZMK Contributors
2020-08-29 06:21:31 +10:00
# SPDX-License-Identifier: MIT
2021-01-02 09:37:34 +11:00
2020-08-29 06:21:31 +10:00
if [ -z " $1 " ] ; then
echo "Usage: ./run-test.sh <path to testcase>"
exit 1
2020-11-23 01:05:07 +11:00
fi
path = " $1 "
2020-11-24 07:55:04 +11:00
if [ $path = "all" ] ; then
path = "tests"
2020-11-23 01:05:07 +11:00
fi
2022-03-24 22:38:14 +11:00
testcases = $( find $path -name native_posix_64.keymap -exec dirname \{ \} \; )
2020-11-23 01:05:07 +11:00
num_cases = $( echo " $testcases " | wc -l)
2022-04-03 14:17:36 +10:00
if [ $num_cases -gt 1 ] || [ " $testcases " != " $path " ] ; then
2020-08-29 06:21:31 +10:00
echo "" > ./build/tests/pass-fail.log
2021-03-25 01:24:08 +11:00
echo " $testcases " | xargs -L 1 -P ${ J :- 4 } ./run-test.sh
2020-08-29 06:21:31 +10:00
err = $?
sort -k2 ./build/tests/pass-fail.log
exit $err
2020-08-29 06:21:31 +10:00
fi
2020-11-23 01:05:07 +11:00
testcase = " $path "
2020-08-29 06:21:31 +10:00
echo " Running $testcase : "
2022-03-24 22:38:14 +11:00
west build -d build/$testcase -b native_posix_64 -- -DZMK_CONFIG= " $( pwd ) / $testcase " > /dev/null 2>& 1
2020-08-29 06:21:31 +10:00
if [ $? -gt 0 ] ; then
2021-12-12 06:55:56 +11:00
echo " FAILED: $testcase did not build " | tee -a ./build/tests/pass-fail.log
2020-09-15 00:34:05 +10:00
exit 1
2021-12-12 06:55:56 +11:00
fi
./build/$testcase /zephyr/zmk.exe | sed -e "s/.*> //" | tee build/$testcase /keycode_events_full.log | sed -n -f $testcase /events.patterns > build/$testcase /keycode_events.log
diff -au $testcase /keycode_events.snapshot build/$testcase /keycode_events.log
if [ $? -gt 0 ] ; then
if [ -f $testcase /pending ] ; then
echo " PENDING: $testcase " | tee -a ./build/tests/pass-fail.log
2020-08-29 06:28:49 +10:00
exit 0
2020-08-29 06:21:31 +10:00
fi
2021-12-12 06:55:56 +11:00
echo " FAILED: $testcase " | tee -a ./build/tests/pass-fail.log
exit 1
2021-01-22 07:05:30 +11:00
fi
2021-12-12 06:55:56 +11:00
echo " PASS: $testcase " | tee -a ./build/tests/pass-fail.log
exit 0