diff options
author | Helmut Grohne <helmut@subdivi.de> | 2022-12-31 07:44:49 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2022-12-31 07:44:49 +0100 |
commit | a7e264672d431fc3a36b47c48ab016b20b03071b (patch) | |
tree | 8e6ad944ea49d89948902fdb2557eeb9890b3af6 /tests/create-and-run.sh | |
parent | c856e06999fdc2b992e07c1b82b4af08c834f78b (diff) | |
parent | 947506522176e2b966fa1dc6389fa366322dec12 (diff) | |
download | debvm-a7e264672d431fc3a36b47c48ab016b20b03071b.tar.gz |
Merge branch main into debian
Diffstat (limited to 'tests/create-and-run.sh')
-rwxr-xr-x | tests/create-and-run.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh new file mode 100755 index 0000000..aafd41d --- /dev/null +++ b/tests/create-and-run.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +# shellcheck disable=SC2086 + +if test "$#" -ne 2; then + echo "$(basename $0) takes two positional arguments. architecture and release" 1>&2 + exit 1 +fi + +set -ex + +cleanup() { + rm -f ssh_id ssh_id.pub test.ext4 +} + +trap cleanup EXIT INT TERM QUIT + +ssh-keygen -f ssh_id -N '' +debvm-create -k ssh_id.pub -o test.ext4 -a "$1" -r "$2" + +timeout 240s debvm-run -s 2222 -i test.ext4 & +timeout=5 +sshopt="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $(if test "$2" = jessie; then echo -o PubkeyAcceptedKeyTypes=+ssh-rsa; fi)" +ts=$(sleepenh 0 || [ $? -eq 1 ]) +for i in $(seq 30); do + rv=0 + ssh $sshopt -o ConnectTimeout="$timeout" -i ssh_id -p 2222 root@localhost echo success || rv=$? + test $rv -eq 0 && break + ts=$(sleepenh "$ts" "$timeout" || [ $? -eq 1 ]); + if test "$i" -eq 30; then + echo "timeout reached" >&2 + exit 1 + fi +done +ssh $sshopt -i ssh_id -p 2222 root@localhost poweroff +wait |