Commit 38d67f76 authored by Marti Bolivar's avatar Marti Bolivar Committed by David Brown
Browse files

zephyr: add script for running mcuboot tests

It's onerous to work through the tests in docs/testplan-zephyr.md by
hand. Add a script which takes the thinking out of it.

Signed-off-by: default avatarMarti Bolivar <marti@opensourcefoundries.com>
parent c1f939d6
Loading
Loading
Loading
Loading
+4
Changes for docs/testplan-zephyr.md: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,10 @@ were written using the FRDM-K64F, but other boards should be similar.
At this time, however, the partitions are hardcoded in the Makefile
targets to flash.

Note that the script "run-tests.sh" in that directory is helpful for
automating the process, and provides simple "y or n" prompts for each
test case and expected result.

## Building and running.

The tests are build using the various `test-*` targets in
+x+196
Changes for samples/zephyr/run-tests.sh: 196 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/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
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ GOOD ECDSA --------------------'
make test-good-ecdsa
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ OVERWRITE ---------------------'
make test-overwrite
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello2 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ BAD RSA -----------------------'
make test-bad-rsa-upgrade
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ BAD ECDSA ---------------------'
make test-bad-ecdsa-upgrade
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ NO BOOTCHECK ------------------'
make test-no-bootcheck
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ WRONG RSA ---------------------'
make test-wrong-rsa
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '--------------------------------------------------------'
echo '------------------------ WRONG ECDSA -------------------'
make test-wrong-ecdsa
pyocd-flashtool -ce
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"
pyocd-tool reset
echo "Expected result: hello1 runs"
ok_yn

echo '========================================================'
echo '                    ALL TESTS PASSED'
echo '========================================================'