summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJochen Sprickerhof <git@jochen.sprickerhof.de>2022-12-23 20:55:37 +0100
committerJochen Sprickerhof <git@jochen.sprickerhof.de>2022-12-23 23:06:21 +0100
commitaf4f1eb0cd386e7d6aa06a097998f4bbcbf9bb43 (patch)
tree7150222e616d945b5f27a1af635eb2fbab3b29fa /tests
parent8899775ccfce4b0b9373b3e3bd00220cca349f93 (diff)
downloaddebvm-af4f1eb0cd386e7d6aa06a097998f4bbcbf9bb43.tar.gz
Move tests to tests/create-and-run.sh (Closes: #4)
Diffstat (limited to 'tests')
-rwxr-xr-xtests/create-and-run.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh
new file mode 100755
index 0000000..dfd4022
--- /dev/null
+++ b/tests/create-and-run.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# shellcheck disable=SC2086
+
+set -ex
+
+cleanup() {
+ rm -f ssh_id ssh_id.pub test.ext2
+}
+
+trap cleanup EXIT INT TERM QUIT
+
+ssh-keygen -f ssh_id -N ''
+debvm-create -k ssh_id.pub -o test.ext2 "$@"
+
+timeout 240s debvm-run -s 2222 -i test.ext2 &
+timeout=5
+sshopt="-o StrictHostKeyChecking=no $(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