diff options
author | Helmut Grohne <helmutg@debian.org> | 2022-12-27 16:19:13 +0000 |
---|---|---|
committer | Helmut Grohne <helmutg@debian.org> | 2022-12-27 16:19:13 +0000 |
commit | 0f8a270a582c3b6bdd4bcb8b6e4eddfb48360866 (patch) | |
tree | f1d3bbac855beeaa75ada8ae9caa1832b8433a9d /tests | |
parent | b44e90f2139b97ac92bd69123679d04d16c9bd15 (diff) | |
parent | dcf46b1c7602bb2ddd13e9bcf1fb66a8690f4864 (diff) | |
download | debvm-0f8a270a582c3b6bdd4bcb8b6e4eddfb48360866.tar.gz |
Merge branch 'ci_ssh' into 'main'
Ci ssh
See merge request helmutg/debvm!10
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/create-and-run.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh new file mode 100755 index 0000000..0e2a3ca --- /dev/null +++ b/tests/create-and-run.sh @@ -0,0 +1,35 @@ +#!/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 $(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 |