From f773b5abebafe5f274c67390f6cd9b09d1c4d83a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Aug 2021 10:37:16 +0800 Subject: [PATCH] zynq: lock board for HITL tests --- artiq-zynq.nix | 58 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/artiq-zynq.nix b/artiq-zynq.nix index 7d1518f..3e97923 100644 --- a/artiq-zynq.nix +++ b/artiq-zynq.nix @@ -36,33 +36,51 @@ in buildPhase = '' - echo Power cycling board... - (echo b; sleep 5; echo B; sleep 5) | nc -N -w6 192.168.1.31 3131 - echo Power cycle done. - - export USER=hydra - export OPENOCD_ZYNQ=${artiq-zynq.zynq-rs}/openocd - export SZL=${szlEnv} - pushd ${} export NIX_SSHOPTS="-F /dev/null -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -i /opt/hydra_id_rsa" - bash ${}/remote_run.sh -h rpi-4 -o "$NIX_SSHOPTS" -d ${artiq-zynq.zc706-nist_qc2-jtag} - popd + LOCKCTL=$(mktemp -d) + mkfifo $LOCKCTL/lockctl - echo Waiting for the firmware to boot... - sleep 15 + cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \ + $NIX_SSHOPTS \ + rpi-4 \ + 'mkdir -p /tmp/board_lock && flock /tmp/board_lock/zc706-1 -c "echo Ok; cat"' \ + | ( + # End remote flock via FIFO + atexit_unlock() { + echo > $LOCKCTL/lockctl + } + trap atexit_unlock EXIT - echo Running test kernel... - artiq_run --device-db ${}/examples/device_db.py ${}/examples/mandelbrot.py + # Read "Ok" line when remote successfully locked + read LOCK_OK - echo Running ARTIQ unit tests... - ARTIQ_ROOT=${}/examples python -m unittest discover artiq.test.coredevice -v + echo Power cycling board... + (echo b; sleep 5; echo B; sleep 5) | nc -N -w6 192.168.1.31 3131 + echo Power cycle done. - touch $out + export USER=hydra + export OPENOCD_ZYNQ=${artiq-zynq.zynq-rs}/openocd + export SZL=${szlEnv} + pushd ${} + bash ${}/remote_run.sh -h rpi-4 -o "$NIX_SSHOPTS" -d ${artiq-zynq.zc706-nist_qc2-jtag} + popd - echo Completed + echo Waiting for the firmware to boot... + sleep 15 - (echo b; sleep 5) | nc -N -w6 192.168.1.31 3131 - echo Board powered off + echo Running test kernel... + artiq_run --device-db ${}/examples/device_db.py ${}/examples/mandelbrot.py + + echo Running ARTIQ unit tests... + ARTIQ_ROOT=${}/examples python -m unittest discover artiq.test.coredevice -v + + touch $out + + echo Completed + + (echo b; sleep 5) | nc -N -w6 192.168.1.31 3131 + echo Board powered off + ) ''; }); }