#!/bin/bash # host_shots.sh [seconds] - serves the "SHOT_CMD=host" requests of guest_test.sh: whenever the guest # creates .png.want, takes a screenshot of the VM's display (the same VNC socket `linuxvm.sh shot` uses) and copies # it into the guest as .png, and clicks the screen's centre for every .click (focus for a test window). Runs until the seconds (default 900) are over or the guest's test run has finished # (the guest creates /done). HERE=$(cd "$(dirname "$0")" && pwd) vm=$1 out=$2 limit=${3:-900} tmp=$(mktemp -d) end=$((SECONDS + limit)) while [ $SECONDS -lt $end ]; do wanted=$("$HERE/linuxvm.sh" ssh "$vm" "find $out -maxdepth 1 \\( -name '*.want' -o -name '*.click' \\) 2>/dev/null; [ -e $out/done ] && echo DONE" /dev/null) echo "$wanted" | grep -q '^DONE$' && break # a window the test opened needs the focus (GNOME holds back new windows of background processes): click it for click in $(echo "$wanted" | grep '\.click$'); do "$HERE/linuxvm.sh" pointer "$vm" 960 540 >/dev/null && "$HERE/linuxvm.sh" click "$vm" >/dev/null "$HERE/linuxvm.sh" ssh "$vm" "rm -f $click"