diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/autopkgtest-qemu-efi.sh | 46 | ||||
-rwxr-xr-x | tests/create-and-run.sh | 2 | ||||
-rwxr-xr-x | tests/efi-create-and-run.sh | 46 | ||||
-rwxr-xr-x | tests/shell_interaction.expect | 2 |
4 files changed, 94 insertions, 2 deletions
diff --git a/tests/autopkgtest-qemu-efi.sh b/tests/autopkgtest-qemu-efi.sh new file mode 100755 index 0000000..bc761d5 --- /dev/null +++ b/tests/autopkgtest-qemu-efi.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +set -eux + +IMAGE=test.img +RELEASE="${1:-}" + +cleanup() { + rm -f "$IMAGE" +} +trap cleanup EXIT +cleanup_abort() { + cleanup + echo aborted >&2 + exit 2 +} +trap cleanup_abort HUP INT TERM QUIT + +INSTALL_LOCATION=$(command -v debefivm-create) +if test "${INSTALL_LOCATION#/usr/}" = "$INSTALL_LOCATION"; then + USERADDHOOK="${INSTALL_LOCATION%/*}/../useraddhook" +else + USERADDHOOK=/usr/share/mmdebstrap/hooks/useradd +fi + +set -- -- +if test -z "$RELEASE"; then + # We no longer need usrmerge in trixie and later and it does not work + # with copy-host-apt-sources-and-preferences in the default order. + set -- \ + --skip=usrmerge \ + "$@" \ + --hook-dir=/usr/share/mmdebstrap/hooks/copy-host-apt-sources-and-preferences \ + --hook-dir=/usr/share/mmdebstrap/hooks/file-mirror-automount \ + "" +fi + +debefivm-create \ + -o "$IMAGE" \ + -r "$RELEASE" \ + "$@" \ + --include=linux-image-generic,libpam-systemd,passwd,python3 \ + --hook-dir="$USERADDHOOK" \ + --customize-hook=/usr/share/autopkgtest/setup-commands/setup-testbed + +autopkgtest hello -- qemu --boot=efi --show-boot "$IMAGE" diff --git a/tests/create-and-run.sh b/tests/create-and-run.sh index 1d0a56d..fab04bc 100755 --- a/tests/create-and-run.sh +++ b/tests/create-and-run.sh @@ -69,4 +69,4 @@ debvm-waitssh -t 540 "$SSH_PORT" run_ssh "$@" poweroff wait -"$(dirname "$0")/shell_interaction.expect" -- -i "$IMAGE" +"$(dirname "$0")/shell_interaction.expect" -- debvm-run -i "$IMAGE" diff --git a/tests/efi-create-and-run.sh b/tests/efi-create-and-run.sh new file mode 100755 index 0000000..2b70662 --- /dev/null +++ b/tests/efi-create-and-run.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +if test "$#" -ne 2; then + 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.img + +set -eux + +. "$(dirname "$0")/test_common.sh" + +cleanup() { + rm -f "$SSH_KEYPATH" "$SSH_KEYPATH.pub" "$IMAGE" +} + +trap cleanup EXIT INT TERM QUIT + +ssh-keygen -f "$SSH_KEYPATH" -N '' +set -- -- +if test -z "$RELEASE"; then + # The ordering of maybe-merged-usr and + # copy-host-apt-sources-and-preferences is unfortunately the wrong way + # round. Therefore, we make debvm-create skip it and pass it ourselves. + # The final empty string is the mirror specification. + set -- \ + --skip=usrmerge \ + "$@" \ + --hook-dir=/usr/share/mmdebstrap/hooks/copy-host-apt-sources-and-preferences \ + --hook-dir=/usr/share/mmdebstrap/hooks/file-mirror-automount \ + --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr \ + "" +fi +debefivm-create -k "$SSH_KEYPATH.pub" -o "$IMAGE" -r "$RELEASE" -a "$ARCHITECTURE" "$@" + +SSH_PORT=2222 +timeout 600s debefivm-run -s "$SSH_PORT" -i "$IMAGE" & +set -- localhost +debvm-waitssh -t 540 "$SSH_PORT" +run_ssh "$@" poweroff +wait + +"$(dirname "$0")/shell_interaction.expect" -- debefivm-run -i "$IMAGE" diff --git a/tests/shell_interaction.expect b/tests/shell_interaction.expect index 325e476..72f8676 100755 --- a/tests/shell_interaction.expect +++ b/tests/shell_interaction.expect @@ -1,7 +1,7 @@ #!/usr/bin/expect set args [lrange $argv 0 end] set timeout 300 -spawn debvm-run {*}$args +spawn {*}$args expect "root@testvm:~#" set timeout 10 send "echo 6coF0JBW\$((2+3))\r" |