diff options
-rw-r--r-- | .gitlab-ci.yml | 66 | ||||
-rwxr-xr-x | debvm-create | 12 | ||||
-rwxr-xr-x | tests/create-and-run.sh | 35 |
3 files changed, 61 insertions, 52 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2ce36c..6427330 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,6 @@ image: debian:sid-slim shellcheck: - stage: test script: - apt-get update - apt-get dist-upgrade --yes @@ -9,71 +8,42 @@ shellcheck: - shellcheck debvm-* codespell: - stage: test script: - apt-get update - apt-get dist-upgrade --yes - apt-get --no-install-recommends --yes install codespell - codespell debvm-* -.test_script: - script: - - timeout 240s ./debvm-run -s 2222 & - - | - timeout=5 - sshopt="-o StrictHostKeyChecking=no $(if test "$RELEASE" = 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 - release_test: - extends: .test_script - stage: test parallel: matrix: - RELEASE: - - sid - - bookworm - - bullseye - - buster - - stretch - - jessie - before_script: + - sid + - bookworm + - bullseye + - buster + - stretch + - jessie + script: - apt-get update - apt-get dist-upgrade --yes - apt-get --no-install-recommends --yes install e2fsprogs genext2fs mmdebstrap openssh-client sleepenh qemu-kvm - - ssh-keygen -f ~/.ssh/id -N '' - - ./debvm-create -k ~/.ssh/id.pub -r "$RELEASE" + - PATH=.:$PATH ./tests/create-and-run.sh $(dpkg --print-architecture) "$RELEASE" arch_test: - extends: .test_script - stage: test parallel: matrix: - ARCHITECTURE: - - arm64 - - armhf - - i386 - - mips64el - - mipsel - - ppc64el - - s390x - before_script: - - | - if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc - fi + - arm64 + - armhf + - i386 + - mips64el + - mipsel + - ppc64el + - s390x + script: + - test -e /proc/sys/fs/binfmt_misc/status || mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc - 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 - - ssh-keygen -f ~/.ssh/id -N '' - - ./debvm-create -k ~/.ssh/id.pub -a $ARCHITECTURE + - PATH=.:$PATH ./tests/create-and-run.sh "$ARCHITECTURE" sid diff --git a/debvm-create b/debvm-create index 5ac62e7..2362beb 100755 --- a/debvm-create +++ b/debvm-create @@ -132,8 +132,6 @@ case "$SUITE" in ;; esac - - KERNEL_SUFFIX=-$ARCHITECTURE case "$ARCHITECTURE" in amd64|arm64) @@ -159,7 +157,13 @@ case "$ARCHITECTURE" in ;; esac -INCLUDE_PACKAGES="$INCLUDE_PACKAGES,linux-image$KERNEL_SUFFIX" +case ",$INCLUDE_PACKAGES," in + *,linux-image-*) + ;; + *) + INCLUDE_PACKAGES="$INCLUDE_PACKAGES,linux-image$KERNEL_SUFFIX" + ;; +esac if test -n "$SSHKEY"; then INCLUDE_PACKAGES="$INCLUDE_PACKAGES,openssh-server" @@ -248,4 +252,4 @@ if test "$IMAGESIZE" -lt "$SIZE"; then fi /sbin/tune2fs -L debvm -i 0 -O extents,uninit_bg,dir_index,has_journal "$IMAGE" # Must fsck after tune2fs: https://ext4.wiki.kernel.org/index.php/UpgradeToExt4 -/sbin/fsck.ext4 -fDp rootfs.ext2 +/sbin/fsck.ext4 -fDp "$IMAGE" 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 |