summaryrefslogtreecommitdiff
path: root/tests/create-and-run.sh
diff options
context:
space:
mode:
authorHelmut Grohne <helmutg@debian.org>2022-12-31 09:42:30 +0000
committerHelmut Grohne <helmutg@debian.org>2022-12-31 09:42:30 +0000
commit029a4c90e783517b7023f32b93fea7f698f81ce8 (patch)
treef72796e76465bc41ccee67b3164f2f9de0307ff1 /tests/create-and-run.sh
parent947506522176e2b966fa1dc6389fa366322dec12 (diff)
parent2f6269b1b7bea50797594113797416862552aae5 (diff)
downloaddebvm-029a4c90e783517b7023f32b93fea7f698f81ce8.tar.gz
Merge branch 'dist-ugrade' into 'main'
Dist ugrade Closes #3 See merge request helmutg/debvm!8
Diffstat (limited to 'tests/create-and-run.sh')
-rwxr-xr-xtests/create-and-run.sh39
1 files changed, 17 insertions, 22 deletions
diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh
index aafd41d..540e6c4 100755
--- a/tests/create-and-run.sh
+++ b/tests/create-and-run.sh
@@ -1,36 +1,31 @@
#!/bin/sh
-# shellcheck disable=SC2086
-
if test "$#" -ne 2; then
- echo "$(basename $0) takes two positional arguments. architecture and release" 1>&2
+ echo "$(basename "$0") takes two positional arguments: architecture and release" 1>&2
exit 1
fi
+ARCHITECTURE=$1
+RELEASE=$2
+SSH_KEYPATH=ssh_id
+IMAGE=test.ext4
+
+set -eux
-set -ex
+. "$(dirname "$0")/test_common.sh"
cleanup() {
- rm -f ssh_id ssh_id.pub test.ext4
+ rm -f "$SSH_KEYPATH" "$SSH_KEYPATH.pub" "$IMAGE"
}
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"
+ssh-keygen -f "$SSH_KEYPATH" -N ''
+debvm-create -k "$SSH_KEYPATH.pub" -o "$IMAGE" -a "$ARCHITECTURE" -r "$RELEASE"
-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
+SSH_PORT=2222
+timeout 240s debvm-run -s "$SSH_PORT" -i "$IMAGE" &
+set -- localhost
+test "$RELEASE" = jessie && set -- -o PubkeyAcceptedKeyTypes=+ssh-rsa "$@"
+wait_ssh "$@"
+run_ssh "$@" poweroff
wait