From c1f7239c2df3ebd61b4c55b1b643400a80df3452 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 25 Oct 2019 12:03:44 +0000 Subject: [PATCH] ci: add click and persistence tests --- ci/test.yml | 17 ++++++++++++++ core/Makefile | 3 +++ core/tests/run_tests_click_emu.sh | 38 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100755 core/tests/run_tests_click_emu.sh diff --git a/ci/test.yml b/ci/test.yml index 98fd1655d..16d98af10 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -89,6 +89,15 @@ core unix fido2 test: - cd core - pipenv run make test_emu_fido2 +core unix click test: + stage: test + <<: *only_changes_core + dependencies: + - core unix frozen debug build + script: + - cd core + - pipenv run make test_emu_click + core unix upgrade test: stage: test <<: *only_changes_core @@ -100,6 +109,14 @@ core unix upgrade test: - tests/download_emulators.sh - pipenv run pytest tests/upgrade_tests +core unix persistence test: + stage: test + <<: *only_changes_core + dependencies: + - core unix frozen debug build + script: + - pipenv run pytest tests/persistence_tests + core mypy test: stage: test <<: *only_changes_core diff --git a/core/Makefile b/core/Makefile index 71c9c8f11..00c536384 100644 --- a/core/Makefile +++ b/core/Makefile @@ -76,6 +76,9 @@ test_emu_u2f: ## run selected u2f device tests from u2f-tests-hid test_emu_fido2: ## run fido2 device tests cd tests ; ./run_tests_device_emu_fido2.sh $(TESTOPTS) +test_emu_click: ## run click tests + cd tests ; ./run_tests_click_emu.sh $(TESTOPTS) + pylint: ## run pylint on application sources and tests pylint -E $(shell find src tests -name *.py) diff --git a/core/tests/run_tests_click_emu.sh b/core/tests/run_tests_click_emu.sh new file mode 100755 index 000000000..5a2d2294a --- /dev/null +++ b/core/tests/run_tests_click_emu.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +: "${RUN_TEST_EMU:=1}" + +CORE_DIR="$(SHELL_SESSION_FILE='' && cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )" +MICROPYTHON="${MICROPYTHON:-$CORE_DIR/build/unix/micropython}" +TREZOR_SRC="${CORE_DIR}/src" + +DISABLE_FADE=1 +PYOPT="${PYOPT:-0}" +upy_pid="" + +# run emulator if RUN_TEST_EMU +if [[ $RUN_TEST_EMU > 0 ]]; then + source ../trezor_cmd.sh + + # remove flash and sdcard files before run to prevent inconsistent states + mv "${TREZOR_PROFILE_DIR}/trezor.flash" "${TREZOR_PROFILE_DIR}/trezor.flash.bkp" 2>/dev/null + mv "${TREZOR_PROFILE_DIR}/trezor.sdcard" "${TREZOR_PROFILE_DIR}/trezor.sdcard.bkp" 2>/dev/null + + cd "${TREZOR_SRC}" + echo "Starting emulator: $MICROPYTHON $ARGS ${MAIN}" + + TREZOR_TEST=1 \ + TREZOR_DISABLE_FADE=$DISABLE_FADE \ + $MICROPYTHON $ARGS "${MAIN}" &> "${TREZOR_LOGFILE}" & + upy_pid=$! + cd - + sleep 30 +fi + +# run tests +error=0 +if ! pytest ../../tests/click_tests "$@"; then + error=1 +fi +kill $upy_pid +exit $error