From b530e7c1053f6ddcd9929ec1f71ba25a0d586eaf Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 18 Oct 2019 15:35:45 +0200 Subject: [PATCH] ci: add fido2 tests to ci --- ci/test.yml | 10 ++++++ core/Makefile | 3 ++ core/tests/run_tests_device_emu_fido2.sh | 39 ++++++++++++++++++++++++ tests/fido_tests/fido2 | 1 + 4 files changed, 53 insertions(+) create mode 100755 core/tests/run_tests_device_emu_fido2.sh create mode 120000 tests/fido_tests/fido2 diff --git a/ci/test.yml b/ci/test.yml index 913a01693..e764dc7bc 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -80,6 +80,15 @@ core unix u2f test: - cd core - pipenv run make test_emu_u2f +core unix fido2 test: + stage: test + <<: *only_changes_core + dependencies: + - core unix frozen regular build + script: + - cd core + - pipenv run make test_emu_fido2 + core unix upgrade test: stage: test <<: *only_changes_core @@ -94,6 +103,7 @@ core unix upgrade test: core mypy test: stage: test <<: *only_changes_core + dependencies: [] # no artifacts needed script: - cd core - (pipenv run make mypy | tee /tmp/mypy-result) || true diff --git a/core/Makefile b/core/Makefile index e89a5130d..71c9c8f11 100644 --- a/core/Makefile +++ b/core/Makefile @@ -73,6 +73,9 @@ test_emu_monero: ## run selected monero device tests from monero-agent test_emu_u2f: ## run selected u2f device tests from u2f-tests-hid cd tests ; ./run_tests_device_emu_u2f.sh $(TESTOPTS) +test_emu_fido2: ## run fido2 device tests + cd tests ; ./run_tests_device_emu_fido2.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_device_emu_fido2.sh b/core/tests/run_tests_device_emu_fido2.sh new file mode 100755 index 000000000..bad434d9b --- /dev/null +++ b/core/tests/run_tests_device_emu_fido2.sh @@ -0,0 +1,39 @@ +#!/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 + +cd ../../tests/fido_tests/fido2 +# run tests +error=0 +if ! pytest --random-order-seed=414020 --sim tests/standard/ --vendor trezor "$@"; then # hardcoded order seed, which succeeds + error=1 +fi +kill $upy_pid +exit $error diff --git a/tests/fido_tests/fido2 b/tests/fido_tests/fido2 new file mode 120000 index 000000000..47bb9a736 --- /dev/null +++ b/tests/fido_tests/fido2 @@ -0,0 +1 @@ +../../vendor/fido2-tests/ \ No newline at end of file