From 6cf48bf48596f2752ef2aa78a49e86cadc207523 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 16 Jan 2020 17:17:41 +0100 Subject: [PATCH] ci: use explicit trezor.log location --- ci/test.yml | 21 +++++++-------------- core/Makefile | 6 ++++-- core/tests/run_tests_device_emu_monero.sh | 6 +++++- docs/core/emulator/index.md | 9 +++++++-- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/ci/test.yml b/ci/test.yml index 38dc30d84..cd26accaa 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -46,16 +46,15 @@ core unix device ui test: script: - cd core - pipenv run make test_emu_ui - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} - cd ../ci - pipenv run python prepare_ui_artifacts.py artifacts: name: core-unix-device-ui-test paths: - - trezor.log - ci/ui_test_records/ - tests/ui_tests/reports/ - tests/junit.xml + - tests/trezor.log when: always expire_in: 1 week reports: @@ -71,14 +70,13 @@ core unix device test: script: - cd core - pipenv run make test_emu - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} - sync - sleep 1 - mv ./src/.coverage .coverage.test_emu artifacts: name: core-unix-device-test paths: - - trezor.log + - tests/trezor.log - tests/junit.xml - core/.coverage.* expire_in: 1 week @@ -97,11 +95,10 @@ core unix btconly device test: script: - cd core - pipenv run make test_emu - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} artifacts: name: core-unix-btconly-device-test paths: - - trezor.log + - tests/trezor.log - tests/junit.xml expire_in: 1 week when: always @@ -118,14 +115,13 @@ core unix monero test: script: - cd core - pipenv run make test_emu_monero - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} - sync - sleep 1 - mv ./src/.coverage .coverage.test_emu_monero artifacts: name: core-unix-monero-test paths: - - trezor.log + - tests/trezor.log - core/.coverage.* expire_in: 1 week when: always @@ -141,14 +137,13 @@ core unix u2f test: - make -C tests/fido_tests/u2f-tests-hid - cd core - pipenv run make test_emu_u2f - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} - sync - sleep 1 - mv ./src/.coverage .coverage.test_emu_u2f artifacts: name: core-unix-u2f-test paths: - - trezor.log + - tests/trezor.log - core/.coverage.* expire_in: 1 week when: always @@ -163,14 +158,13 @@ core unix fido2 test: script: - cd core - pipenv run make test_emu_fido2 - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} - sync - sleep 1 - mv ./src/.coverage .coverage.test_emu_fido2 artifacts: name: core-unix-fido2-test paths: - - trezor.log + - tests/trezor.log - tests/junit.xml - core/.coverage.* expire_in: 1 week @@ -186,11 +180,10 @@ core unix click test: script: - cd core - pipenv run make test_emu_click - - cp /var/tmp/trezor.log ${CI_PROJECT_DIR} artifacts: name: core-unix-click-test paths: - - trezor.log + - tests/trezor.log - tests/junit.xml reports: junit: tests/junit.xml diff --git a/core/Makefile b/core/Makefile index cb386a024..84b9cf7d6 100644 --- a/core/Makefile +++ b/core/Makefile @@ -38,11 +38,13 @@ FIRMWARE_MAXSIZE = 1703936 GITREV=$(shell git describe --always --dirty | tr '-' '_') CFLAGS += -DGITREV=$(GITREV) +TESTPATH = $(CURDIR)/../tests + EMU = $(CURDIR)/emu.py -EMU_TEST_ARGS = --disable-animation --headless --quiet --temporary-profile +EMU_LOG_FILE ?= $(TESTPATH)/trezor.log +EMU_TEST_ARGS = --disable-animation --headless --output=$(EMU_LOG_FILE) --temporary-profile EMU_TEST = $(EMU) $(EMU_TEST_ARGS) -c -TESTPATH = $(CURDIR)/../tests JUNIT_XML ?= $(TESTPATH)/junit.xml PYTEST = pytest --junitxml=$(JUNIT_XML) TREZOR_FIDO2_UDP_PORT = 21326 diff --git a/core/tests/run_tests_device_emu_monero.sh b/core/tests/run_tests_device_emu_monero.sh index 93999b424..fd22890f7 100755 --- a/core/tests/run_tests_device_emu_monero.sh +++ b/core/tests/run_tests_device_emu_monero.sh @@ -10,7 +10,11 @@ upy_pid="" # run emulator if RUN_TEST_EMU if [[ $RUN_TEST_EMU > 0 ]]; then - ../emu.py --disable-animation --temporary-profile --quiet --headless & + ../emu.py \ + --disable-animation \ + --temporary-profile \ + --headless \ + --output=../../tests/trezor.log & upy_pid=$! trezorctl -v wait-for-emulator fi diff --git a/docs/core/emulator/index.md b/docs/core/emulator/index.md index b709d9e3c..236fc9f8a 100644 --- a/docs/core/emulator/index.md +++ b/docs/core/emulator/index.md @@ -59,8 +59,7 @@ To use the "all all all" seed defined in [SLIP-14](https://github.com/satoshilab Internal Trezor's storage is emulated and stored in the `/var/tmp/trezor.flash` file on default. Deleting this file is similar to calling _wipe device_. You can also find -`/var/tmp/trezor.sdcard` for SD card and `/var/tmp/trezor.log`, which contains the -communication log, the same as is in the emulator's stdout. +`/var/tmp/trezor.sdcard` for SD card. You can specify a different location for the storage and log files via the `-p` / `--profile` option: @@ -81,6 +80,12 @@ You can also set a full profile path to `TREZOR_PROFILE_DIR` environment variabl Specifying `-t` / `--temporary-profile` will start the emulator in a clean temporary profile that will be erased when the emulator stops. This is useful, e.g., for tests. +### Logging + +By default, emulator output goes to stdout. When silenced with `--quiet`, it is +redirected to `${TREZOR_PROFILE_DIR}/trezor.log`. You can specify an alternate output +file with `--output`. + ### Running subcommands with the emulator In scripts, it is often necessary to start the emulator, run a commmand while it is