diff --git a/ci/hardware_tests/bootstrap.py b/ci/hardware_tests/bootstrap.py index c2fe2fa82..6baa2d564 100755 --- a/ci/hardware_tests/bootstrap.py +++ b/ci/hardware_tests/bootstrap.py @@ -1,4 +1,4 @@ -import configparser +import os import sys from device.t1 import TrezorOne @@ -6,14 +6,12 @@ from device.tt import TrezorT def main(model: str, file: str = None): - config = configparser.ConfigParser() - config.read_file(open("hardware.cfg")) t1 = TrezorOne( - config["t1"]["uhub_location"], - config["t1"]["arduino_serial"], - config["t1"]["port"], + os.environ["T1_UHUB_LOCATION"], + os.environ["T1_ARDUINO_SERIAL"], + os.environ["T1_UHUB_PORT"], ) - tt = TrezorT(config["tt"]["uhub_location"], config["tt"]["port"]) + tt = TrezorT(os.environ["TT_UHUB_LOCATION"], os.environ["TT_UHUB_PORT"]) if model == "t1": tt.power_off() diff --git a/ci/hardware_tests/hardware.cfg b/ci/hardware_tests/hardware.cfg index 0e503fbb9..9816a6fc7 100644 --- a/ci/hardware_tests/hardware.cfg +++ b/ci/hardware_tests/hardware.cfg @@ -1,13 +1,16 @@ -[t1] # location of the uhub, can be found out by running `uhubctl` -uhub_location = 3-1.4 +T1_UHUB_LOCATION="1-1.2" # to which port of the uhub the device is connected -port = 3 +T1_UHUB_PORT="2" + +# camera device +T1_CAMERA="/dev/video2" + # arduino that pushes T1 buttons -arduino_serial = /dev/ttyACM0 +T1_ARDUINO_SERIAL="/dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_8573332373935181A0C0-if00" -[tt] # location of the uhub, can be found out by running `uhubctl` -uhub_location = 3-3 +TT_UHUB_LOCATION="1-1.2" # to which port of the uhub the device is connected -port = 1 +TT_UHUB_PORT="3" + diff --git a/ci/hardware_tests/record_video.sh b/ci/hardware_tests/record_video.sh index 5c9bd2a33..7c2cfd489 100755 --- a/ci/hardware_tests/record_video.sh +++ b/ci/hardware_tests/record_video.sh @@ -1,20 +1,22 @@ #!/usr/bin/env bash -if [ $# -ne 2 ] +if [ $# -ne 3 ] then - echo "Usage: $0 commit_id [start|stop]" + echo "Usage: $0 video_dev commit_id [start|stop]" fi -OUTPUTFILE=video_$1_$(date +%s).mp4 -INPUTDEVICE=/dev/video0 +INPUTDEVICE=$1 +COMMIT=$2 +ACTION=$3 +OUTPUTFILE=video_${COMMIT}_$(date +%s).mp4 -if [ "$2" == "start" ]; then +if [ "$ACTION" == "start" ]; then echo "[software/video] Starting record to $OUTPUTFILE" 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 & + text='$COMMIT | %{localtime} | %{pts}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=15" $OUTPUTFILE & export VPID=$! -elif [ "$2" == "stop" ]; then +elif [ "$ACTION" == "stop" ]; then echo "[software/video] Stopping the recording of $OUTPUTFILE" pkill ffmpeg sync diff --git a/ci/hardware_tests/t1_hw_test.sh b/ci/hardware_tests/t1_hw_test.sh index f89212b0e..2205059ac 100755 --- a/ci/hardware_tests/t1_hw_test.sh +++ b/ci/hardware_tests/t1_hw_test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash function finish { - ./record_video.sh ${CI_COMMIT_SHORT_SHA} stop + ./record_video.sh ${T1_CAMERA} ${CI_COMMIT_SHORT_SHA} stop ls -l *.mp4 } trap finish EXIT @@ -9,8 +9,12 @@ trap finish EXIT set -e # exit on nonzero exitcode set -x # trace commands +# export variables defined in the file +set -a +source hardware.cfg +set +a -./record_video.sh ${CI_COMMIT_SHORT_SHA} start +./record_video.sh ${T1_CAMERA} ${CI_COMMIT_SHORT_SHA} start (cd ../.. && poetry install) poetry run python bootstrap.py t1 poetry run python bootstrap.py t1 ../../trezor-*.bin diff --git a/ci/test.yml b/ci/test.yml index ea89998ce..cbc9d9d6d 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -324,6 +324,9 @@ hardware core btconly device test: PYTEST_TIMEOUT: "1200" script: - cd ci/hardware_tests + - set -a + - source hardware.cfg + - set +a - nix-shell --run "cd ../.. && poetry install" - nix-shell --run "poetry run python bootstrap.py tt ../../trezor-*.bin" - nix-shell --run "poetry run pytest ../../tests/device_tests -m 'not sd_card' -k 'not 15_of_15 and not test_multisig_mismatch_inputs'"