From dedca1bb137f839bd9851ae759a695136135a297 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Fri, 4 Dec 2020 17:11:20 +0100 Subject: [PATCH] ci: ffmpeg tweaks in hardware tests Running ffmpeg in a subshell and killing it in exit trap handler should ensure video availability even when bootstrap or pytest fail. --- ci/hardware_tests/record_video.sh | 3 ++- ci/hardware_tests/t1_hw_test.sh | 20 ++++++++++++++++++++ ci/test.yml | 24 ++++-------------------- 3 files changed, 26 insertions(+), 21 deletions(-) create mode 100755 ci/hardware_tests/t1_hw_test.sh diff --git a/ci/hardware_tests/record_video.sh b/ci/hardware_tests/record_video.sh index 44b8c5cee..5c9bd2a33 100755 --- a/ci/hardware_tests/record_video.sh +++ b/ci/hardware_tests/record_video.sh @@ -9,7 +9,8 @@ INPUTDEVICE=/dev/video0 if [ "$2" == "start" ]; then echo "[software/video] Starting record to $OUTPUTFILE" - ffmpeg -loglevel panic -f oss -f video4linux2 -i $INPUTDEVICE \ + ffmpeg -loglevel warning -f oss -f video4linux2 -i $INPUTDEVICE \ + -flush_packets 1 \ -vf "drawtext=font=Dejavu Sans: \ text='$1 | %{localtime} | %{pts}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=15" $OUTPUTFILE & export VPID=$! diff --git a/ci/hardware_tests/t1_hw_test.sh b/ci/hardware_tests/t1_hw_test.sh new file mode 100755 index 000000000..621c88ffa --- /dev/null +++ b/ci/hardware_tests/t1_hw_test.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +function finish { + ./record_video.sh ${CI_COMMIT_SHORT_SHA} stop + ls -l *.mp4 +} +trap finish EXIT + +set -e # exit on nonzero exitcode +set -x # trace commands + + +./record_video.sh ${CI_COMMIT_SHORT_SHA} start +(cd ../.. && poetry install) +poetry run trezorctl -v list +export TREZOR_PATH=$(./get_trezor_path.sh 'Trezor 1') +echo $TREZOR_PATH +poetry run python bootstrap.py t1 +poetry run python bootstrap.py t1 ../../trezor-*.bin +poetry run pytest ../../tests/device_tests diff --git a/ci/test.yml b/ci/test.yml index aea54a444..8db0fbbce 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -345,19 +345,11 @@ hardware legacy regular device test: - legacy fw regular debug build script: - cd ci/hardware_tests - - nix-shell --run "./record_video.sh ${CI_COMMIT_SHORT_SHA} start" - - nix-shell --run "cd ../.. && poetry install" - - nix-shell --run "poetry run trezorctl list" - - export TREZOR_PATH=$(./get_trezor_path.sh 'Trezor 1') - - nix-shell --run "echo $TREZOR_PATH" - - nix-shell --run "poetry run python bootstrap.py t1" - - nix-shell --run "poetry run python bootstrap.py t1 ../../trezor-*.bin" - - nix-shell --run "poetry run pytest ../../tests/device_tests" - - nix-shell --run "./record_video.sh ${CI_COMMIT_SHORT_SHA} stop" + - nix-shell --run "./t1_hw_test.sh" artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - ci/hardware_tests/video*.mp4 + - ci/hardware_tests/*.mp4 expire_in: 2 days when: always @@ -377,19 +369,11 @@ hardware legacy btconly device test: - legacy fw btconly debug build script: - cd ci/hardware_tests - - nix-shell --run "./record_video.sh ${CI_COMMIT_SHORT_SHA} start" - - nix-shell --run "cd ../.. && poetry install" - - nix-shell --run "poetry run trezorctl list" - - export TREZOR_PATH=$(./get_trezor_path.sh 'Trezor 1') - - nix-shell --run "echo $TREZOR_PATH" - - nix-shell --run "poetry run python bootstrap.py t1" - - nix-shell --run "poetry run python bootstrap.py t1 ../../trezor-*.bin" - - nix-shell --run "poetry run pytest ../../tests/device_tests" - - nix-shell --run "./record_video.sh ${CI_COMMIT_SHORT_SHA} stop" + - nix-shell --run "./t1_hw_test.sh" artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" paths: - - ci/hardware_tests/video*.mp4 + - ci/hardware_tests/*.mp4 expire_in: 2 days when: always