2020-08-29 06:21:31 +10:00
#!/bin/sh
2020-08-29 06:21:31 +10:00
#
# Copyright (c) 2020 Peter Johanson; Cody McGinnis
#
# SPDX-License-Identifier: MIT
#
2020-08-29 06:21:31 +10:00
if [ -z " $1 " ] ; then
echo "Usage: ./run-test.sh <path to testcase>"
exit 1
elif [ " $1 " = "all" ] ; then
2020-08-29 06:21:31 +10:00
echo "" > ./build/tests/pass-fail.log
2020-08-29 06:21:31 +10:00
find tests -name native_posix.keymap -exec dirname \{ \} \; | xargs -l -P 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
testcase = " $1 "
echo " Running $testcase : "
2020-08-29 06:21:31 +10:00
west build -d build/$testcase -b native_posix -- -DZMK_CONFIG= $testcase > /dev/null 2>& 1
if [ $? -gt 0 ] ; then
echo " FAIL: $testcase did not build " >> ./build/tests/pass-fail.log
else
2020-08-29 06:21:31 +10:00
./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
2020-08-29 06:21:31 +10:00
diff -au $testcase /keycode_events.snapshot build/$testcase /keycode_events.log
if [ $? -gt 0 ] ; then
2020-08-29 06:28:49 +10:00
if [ -f $testcase /pending ] ; then
echo " PEND: $testcase " >> ./build/tests/pass-fail.log
exit 0
else
echo " FAIL: $testcase " >> ./build/tests/pass-fail.log
exit 1
fi
2020-08-29 06:21:31 +10:00
else
echo " PASS: $testcase " >> ./build/tests/pass-fail.log
2020-08-29 06:28:49 +10:00
exit 0
2020-08-29 06:21:31 +10:00
fi
fi