From af4f1eb0cd386e7d6aa06a097998f4bbcbf9bb43 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 23 Dec 2022 20:55:37 +0100 Subject: Move tests to tests/create-and-run.sh (Closes: #4) --- tests/create-and-run.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tests/create-and-run.sh (limited to 'tests') 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 -- cgit v1.2.3 From c9a0ca87fc9b3bdb3350663be663835fcbf15190 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 23 Dec 2022 23:09:13 +0100 Subject: Use ext4 for test image extension --- tests/create-and-run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index dfd4022..4b5d986 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -5,15 +5,15 @@ set -ex cleanup() { - rm -f ssh_id ssh_id.pub test.ext2 + 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.ext2 "$@" +debvm-create -k ssh_id.pub -o test.ext4 "$@" -timeout 240s debvm-run -s 2222 -i test.ext2 & +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 ]) -- cgit v1.2.3 From dcf46b1c7602bb2ddd13e9bcf1fb66a8690f4864 Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Tue, 27 Dec 2022 16:20:54 +0100 Subject: test script: Use positional arguments Reported-by: Helmut Grohne --- .gitlab-ci.yml | 4 ++-- tests/create-and-run.sh | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3d91676..6427330 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,7 +28,7 @@ release_test: - apt-get update - apt-get dist-upgrade --yes - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client sleepenh qemu-kvm - - PATH=.:$PATH ./tests/create-and-run.sh -r "$RELEASE" + - PATH=.:$PATH ./tests/create-and-run.sh $(dpkg --print-architecture) "$RELEASE" arch_test: parallel: @@ -46,4 +46,4 @@ arch_test: - apt-get update - apt-get dist-upgrade --yes - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client sleepenh qemu-system binfmt-support arch-test qemu-user-static - - PATH=.:$PATH ./tests/create-and-run.sh -a "$ARCHITECTURE" + - PATH=.:$PATH ./tests/create-and-run.sh "$ARCHITECTURE" sid diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index 4b5d986..0e2a3ca 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -2,6 +2,11 @@ # 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() { @@ -11,7 +16,7 @@ cleanup() { trap cleanup EXIT INT TERM QUIT ssh-keygen -f ssh_id -N '' -debvm-create -k ssh_id.pub -o test.ext4 "$@" +debvm-create -k ssh_id.pub -o test.ext4 -a "$1" -r "$2" timeout 240s debvm-run -s 2222 -i test.ext4 & timeout=5 -- cgit v1.2.3 From c5e12d0fa598aaf3112b43e050d18e93d29903ee Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 28 Dec 2022 20:46:31 +0100 Subject: tests: do not attempt to update a known hosts file This makes testing work in situations where $HOME isn't writeable. --- tests/create-and-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index 0e2a3ca..0425e63 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -20,7 +20,7 @@ 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)" +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 -- cgit v1.2.3 From c00b63fc4c642bec5be44577771170dc8b2ac5e0 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Wed, 28 Dec 2022 21:33:03 +0100 Subject: test: wait for qemu to terminate --- tests/create-and-run.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index 0425e63..aafd41d 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -33,3 +33,4 @@ for i in $(seq 30); do fi done ssh $sshopt -i ssh_id -p 2222 root@localhost poweroff +wait -- cgit v1.2.3