2017-11-15 09:22:03 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Test runner
|
|
|
|
#
|
|
|
|
# Copyright (c) 2017 Open Source Foundries Limited
|
|
|
|
|
|
|
|
#
|
|
|
|
# This script can be used to execute the Zephyr test plan detailed in
|
|
|
|
# docs/testplan-zephyr.md.
|
|
|
|
#
|
|
|
|
|
|
|
|
function ok_yn () {
|
|
|
|
while true ; do
|
|
|
|
read -p "Test result OK (y/n)? " -n 1 choice
|
|
|
|
echo
|
|
|
|
case "$choice" in
|
|
|
|
y|Y )
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
n|N )
|
|
|
|
echo "Test failed; exiting"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
echo Please enter y or n
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ GOOD RSA ----------------------'
|
|
|
|
make test-good-rsa
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Flashing bootloader"
|
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello2 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ GOOD ECDSA --------------------'
|
|
|
|
make test-good-ecdsa
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello2 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ OVERWRITE ---------------------'
|
|
|
|
make test-overwrite
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello2 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello2 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ BAD RSA -----------------------'
|
|
|
|
make test-bad-rsa-upgrade
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ BAD ECDSA ---------------------'
|
|
|
|
make test-bad-ecdsa-upgrade
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ NO BOOTCHECK ------------------'
|
|
|
|
make test-no-bootcheck
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ WRONG RSA ---------------------'
|
|
|
|
make test-wrong-rsa
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '--------------------------------------------------------'
|
|
|
|
echo '------------------------ WRONG ECDSA -------------------'
|
|
|
|
make test-wrong-ecdsa
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd erase --chip
|
2017-11-15 09:22:03 +08:00
|
|
|
make flash_boot
|
|
|
|
echo "Expected result: unable to find bootable image"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 1"
|
|
|
|
make flash_hello1
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Flashing hello 2"
|
|
|
|
make flash_hello2
|
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
echo "Resetting"
|
2019-02-19 07:20:00 +08:00
|
|
|
pyocd commander -c reset
|
2017-11-15 09:22:03 +08:00
|
|
|
echo "Expected result: hello1 runs"
|
|
|
|
ok_yn
|
|
|
|
|
|
|
|
echo '========================================================'
|
|
|
|
echo ' ALL TESTS PASSED'
|
|
|
|
echo '========================================================'
|