Skip to content

eBPF-based security platform

testing: move contrib into the test tree and tools

Daniel Borkmann7690a678abcf
diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml
index 963a56f1..07a6e2bd 100644
--- a/.github/workflows/deb.yml
+++ b/.github/workflows/deb.yml
@@ -201,14 +201,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: artifacts/bpf-next-kernel-debs
- key: test-vm-kernel-${{ steps.target-kernel-week.outputs.week }}-${{ hashFiles('contrib/build-kernel-package.sh', 'contrib/test-vm-arch.sh', 'testing/Makefile', 'kernel/*.patch') }}
+ key: test-vm-kernel-${{ steps.target-kernel-week.outputs.week }}-${{ hashFiles('testing/vm/build-kernel.sh', 'testing/vm/arch.sh', 'testing/Makefile', 'kernel/*.patch') }}
- name: Restore the target VM image
id: target-vm-image
uses: actions/cache/restore@v4
with:
path: build/test-vm/cache
- key: test-vm-images-${{ hashFiles('contrib/test-vm-runtime-packages', 'contrib/prepare-test-vm-runtime.sh', 'contrib/build-test-vm-bundle.sh', 'contrib/test-vm-arch.sh') }}
+ key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}
- name: Restore the target build dependencies
id: target-deps
diff --git a/.github/workflows/target-tests.yml b/.github/workflows/target-tests.yml
index f495555a..dd72a4e0 100644
--- a/.github/workflows/target-tests.yml
+++ b/.github/workflows/target-tests.yml
@@ -32,7 +32,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: artifacts/bpf-next-kernel-debs
- key: test-vm-kernel-${{ steps.week.outputs.week }}-${{ hashFiles('contrib/build-kernel-package.sh', 'contrib/test-vm-arch.sh', 'testing/Makefile', 'kernel/*.patch') }}
+ key: test-vm-kernel-${{ steps.week.outputs.week }}-${{ hashFiles('testing/vm/build-kernel.sh', 'testing/vm/arch.sh', 'testing/Makefile', 'kernel/*.patch') }}
- name: Restore the static target dependencies
id: target-deps
@@ -46,7 +46,7 @@ jobs:
uses: actions/cache/restore@v4
with:
path: build/test-vm/cache
- key: test-vm-images-${{ hashFiles('contrib/test-vm-runtime-packages', 'contrib/prepare-test-vm-runtime.sh', 'contrib/build-test-vm-bundle.sh', 'contrib/test-vm-arch.sh') }}
+ key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}
- name: Prepare the runner as the VM host
run: .github/scripts/target-tests.sh setup
diff --git a/Documentation/architecture.rst b/Documentation/architecture.rst
index bb20c0f9..8726258a 100644
--- a/Documentation/architecture.rst
+++ b/Documentation/architecture.rst
@@ -795,12 +795,12 @@ rejects incompatible kernels; missing features fail the build or pre-flight.
tools/gen-initrd/ dracut module, initrd generator,
installer
tools/gen-vmlinux-h/ vmlinux.h generator
+ tools/bpf-deps/ vendored libbpf refresh
upatches/ shipped packages with their Beefiles
vendor/libbpf/ vendored libbpf and UAPI headers
systemd/ target units and timers
packaging/ tar, deb and rpm packaging
- contrib/ swtpm, test VM, kernel configs
- testing/ TAP tests, host and target VM
+ testing/ TAP tests, test VM, swtpm
Documentation/ this tree
``shirudo help --list-cmds`` prints the supported command set.
diff --git a/Documentation/config-images.rst b/Documentation/config-images.rst
index bb8d0777..fe5c789f 100644
--- a/Documentation/config-images.rst
+++ b/Documentation/config-images.rst
@@ -511,7 +511,7 @@ public fixture set and cache every config bundle under
export SHIRUDO_TEST_RESULTS=/root/test-results/verity
sh testing/run-target-tests.sh
-``contrib/verity-vm-config-fixtures.sh --keys-dir <operator-keys>
+``testing/vm/image-fixtures.sh --keys-dir <operator-keys>
--output <new-directory>`` builds the signed config and revocation fixtures;
only its ``public/`` directory belongs on the target. The standard host
bundle also packages the runtime and static test helpers. The
diff --git a/Documentation/index.rst b/Documentation/index.rst
index e149c979..39526c6a 100644
--- a/Documentation/index.rst
+++ b/Documentation/index.rst
@@ -134,6 +134,6 @@ Contributing
the kernel's ``tools/include`` internals; refreshed by ``make
bpf-deps``, see its ``README.md``.
-``contrib/``
- ``swtpm.sh`` for a software TPM, the test VM scripts, and the
- kernel configurations they use.
+``testing/``
+ The tests, the test VM that runs the target ones, and ``swtpm.sh``
+ for a software TPM.
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index e30f15a3..61992282 100644
--- a/Documentation/requirements.rst
+++ b/Documentation/requirements.rst
@@ -30,7 +30,7 @@ establish that every optional upatch attach point is available.
The table below is what shirudo itself needs; without any of it,
``shirudo init`` does not complete. The test VM kernel uses the slim
-configuration embedded in ``contrib/build-kernel-package.sh``. It also
+configuration embedded in ``testing/vm/build-kernel.sh``. It also
builds the networking modules used by the VM test setup: veth, bridge,
802.1Q, and the netfilter flow table. It also enables IPv6 for the kernel-obs
fixture.
@@ -106,7 +106,7 @@ fixture.
* - ``CONFIG_TCG_TPM`` plus a TPM driver (``CONFIG_TCG_TIS``,
``CONFIG_TCG_CRB``, or the platform's virtual TPM)
- The measurement register and the attestation key. A TPM 2.0 is
- mandatory; there is no unmeasured mode. ``contrib/swtpm.sh``
+ mandatory; there is no unmeasured mode. ``testing/swtpm.sh``
provides a software TPM for machines without one.
* - ``CONFIG_EXT4_FS_SECURITY`` (when ``/var/lib/shirudo`` is on ext4)
- Allows ``init`` to store the ``security.bpf.shirudo`` label used by
diff --git a/Makefile b/Makefile
index 3641cc6c..efe54aee 100644
--- a/Makefile
+++ b/Makefile
@@ -99,7 +99,7 @@ shirudo-build:
# config.mk is regenerated by Makefile.config from the host's pkg-config
# state. Caches results until `make distclean`.
bpf-deps:
- $(Q)KERNEL_SRC="$(KERNEL_SRC)" contrib/bpf-deps.sh
+ $(Q)KERNEL_SRC="$(KERNEL_SRC)" tools/bpf-deps/bpf-deps.sh
config: config.mk
diff --git a/contrib/verity-vm-install.sh b/contrib/verity-vm-install.sh
deleted file mode 100755
index c65d4112..00000000
--- a/contrib/verity-vm-install.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-
-set -euo pipefail
-
-source_dir=$(cd "$(dirname "$0")/.." && pwd)
-templates="$source_dir/contrib/verity-vm"
-state=${SHIRUDO_VERITY_VM_STATE:-$HOME/.linux-kernel-vscode/shirudo-verity}
-kernel=
-keys_dir=
-probes=()
-while [ $# -gt 0 ]; do
- case "$1" in
- --kernel) kernel=${2:?}; shift 2 ;;
- --keys-dir) keys_dir=${2:?}; shift 2 ;;
- --probe) probes+=("${2:?}"); shift 2 ;;
- *) printf 'usage: %s --kernel <built-kernel-tree> --keys-dir <operator-keys> [--probe <trusted-ELF>]\n' "$0" >&2; exit 2 ;;
- esac
-done
-[ -n "$kernel" ] && [ -n "$keys_dir" ] || exit 2
-[ -f "$kernel/arch/x86/boot/bzImage" ] && [ -f "$kernel/include/config/kernel.release" ] || exit 1
-[ -x "$source_dir/shirudo-target" ] && [ -x "$source_dir/tools/shirudo-build/shirudo-build" ] || exit 1
-vm="$source_dir/contrib/verity-vm.sh"
-"$vm" ssh 'test ! -e /run/shirudo/bpffs/lsm_link && test -w /var/lib/shirudo'
-mkdir -p "$state/fixtures"
-work=$(mktemp -d "$state/fixtures/build.XXXXXX")
-install -m 0755 "$source_dir/shirudo-target" "$work/shirudo-target"
-release=$(cat "$kernel/include/config/kernel.release")
-
-for name in config-a config-b config-bad; do
- mkdir -p "$work/$name/etc/shirudo" "$work/$name/keys/trusted" "$work/$name/keys/revoked"
- sed "s/@tenant@/$name/g" "$templates/config.conf.in" \
- >"$work/$name/etc/shirudo/shirudo.conf"
- if [ "$name" = config-bad ]; then
- printf 'invalid certificate\n' >"$work/$name/keys/revoked/0000000000000000000000000000000000000000000000000000000000000000.der"
- fi
- "$source_dir/tools/gen-image/shirudo-gen-image" --source "$work/$name" \
- --output "$work/$name" --keys-dir "$keys_dir" --size 8 \
- --builder "$source_dir/tools/shirudo-build/shirudo-build"
-done
-sed 's/@config_image@/config-a/g' "$templates/runtime.conf.in" \
- >"$work/runtime.conf"
-extra=()
-for probe in "${probes[@]}"; do
- extra+=(--extra-binary "$probe")
-done
-"$source_dir/tools/gen-image/shirudo-gen-runtime" --binary "$work/shirudo-target" \
- --bootstrap-conf "$work/runtime.conf" --cert "$keys_dir/cert.der" \
- --config-cert "$keys_dir/cert.der" --output "$work/runtime" \
- --keys-dir "$keys_dir" --builder "$source_dir/tools/shirudo-build/shirudo-build" \
- --unit-output "$work/runtime-service.conf" "${extra[@]}" >"$work/runtime-root"
-runtime_command=$(sed -n 's/^ExecStart=\(.*\) init$/\1/p' "$work/runtime-service.conf")
-[ -n "$runtime_command" ]
-command_escaped=$(printf '%s' "$runtime_command" | sed 's/[\&|]/\\&/g')
-sed "s|@runtime_command@|$command_escaped|g" "$templates/shirudo-runtime.in" \
- >"$work/shirudo-runtime"
-sed "s/@root_hash@/$(cat "$work/runtime-root")/g" \
- "$templates/bootstrap.conf.in" >"$work/bootstrap.conf"
-
-make -C "$kernel" -j"$(nproc)" LLVM=1 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH="$work/modules" modules_install
-
-tar -C "$work/modules" -cf - "lib/modules/$release" | "$vm" ssh tar -xf - -C /
-"$vm" push "$kernel/arch/x86/boot/bzImage" /boot/vmlinuz-shirudo-verity
-"$vm" push "$work/shirudo-target" /usr/local/bin/shirudo
-"$vm" push "$work/shirudo-runtime" /usr/local/bin/shirudo-runtime
-"$vm" ssh 'mkdir -p /var/lib/shirudo/images /etc/shirudo /usr/lib/dracut/modules.d/90shirudo /etc/systemd/system/shirudo.service.d /root/test-results/verity'
-for name in config-a config-b config-bad runtime; do
- for suffix in img verity roothash p7s; do
- "$vm" push "$work/$name.$suffix" "/var/lib/shirudo/images/$name.$suffix"
- done
-done
-"$vm" push "$work/bootstrap.conf" /etc/shirudo/shirudo.conf
-"$vm" push "$work/runtime-service.conf" /etc/systemd/system/shirudo.service.d/verity.conf
-"$vm" push "$source_dir/tools/gen-initrd/module-setup.sh" /usr/lib/dracut/modules.d/90shirudo/module-setup.sh
-"$vm" push "$source_dir/tools/gen-initrd/shirudo-gen-initrd" /usr/local/bin/shirudo-gen-initrd
-"$vm" push "$keys_dir/cert.der" /var/lib/shirudo/keys/cert.der
-sed 's|@bindir@|/usr/local/bin|g' "$source_dir/systemd/shirudo-initrd.service.in" >"$work/shirudo-initrd.service"
-"$vm" push "$work/shirudo-initrd.service" /usr/lib/systemd/system/shirudo-initrd.service
-
-"$vm" push "$templates/kernel.cmdline" /etc/kernel/cmdline
-"$vm" ssh bash -s -- "$release" <"$templates/install-guest.sh"
-"$vm" pull /boot/shirudo-verity.efi "$state/shirudo-verity.efi"
-"$vm" pull /boot/initrd-shirudo-verity.img "$state/initrd-verity.img"
-image_file=$(mktemp "$state/esp.img.XXXXXX")
-trap 'rm -f "$image_file"' EXIT
-truncate -s 256M "$image_file"
-sfdisk "$image_file" <"$templates/esp.sfdisk" >/dev/null
-mformat -i "$image_file@@1048576" -F -v SHIRUDOV ::
-mmd -i "$image_file@@1048576" ::/EFI ::/EFI/BOOT
-mcopy -i "$image_file@@1048576" "$state/shirudo-verity.efi" ::/EFI/BOOT/BOOTX64.EFI
-if [ ! -e "$state/esp.legacy.img" ]; then
- cp --reflink=auto --sparse=always "$state/esp.img" "$state/esp.legacy.img"
-fi
-mv "$image_file" "$state/esp.img"
-trap - EXIT
-touch "$state/verity-ready"
-printf 'Fixtures: %s\nPrototype UKI ready. Stop the installation VM, then start the prototype VM.\n' "$work"
diff --git a/contrib/verity-vm.sh b/contrib/verity-vm.sh
deleted file mode 100755
index 2973cac4..00000000
--- a/contrib/verity-vm.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-
-set -euo pipefail
-
-state=${SHIRUDO_VERITY_VM_STATE:-$HOME/.linux-kernel-vscode/shirudo-verity}
-key=${SHIRUDO_VERITY_VM_SSH_KEY:-$HOME/.ssh/linux-kernel-vscode-rsa}
-port=${SHIRUDO_VERITY_VM_PORT:-5557}
-gdb_port=${SHIRUDO_VERITY_VM_GDB_PORT:-1236}
-command=${1:-help}
-shift || true
-ssh_args=(-p "$port" -i "$key" -o IdentitiesOnly=yes -o BatchMode=yes
- -o ConnectTimeout=5 -o StrictHostKeyChecking=accept-new
- -o UserKnownHostsFile="$state/known_hosts")
-
-case "$command" in
-ssh)
- exec ssh "${ssh_args[@]}" [email protected] "$@"
- ;;
-push)
- [ $# -eq 2 ] || exit 2
- exec scp -O -P "$port" -i "$key" -o IdentitiesOnly=yes \
- -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="$state/known_hosts" \
- "$1" "[email protected]:$2"
- ;;
-pull)
- [ $# -eq 2 ] || exit 2
- exec scp -O -P "$port" -i "$key" -o IdentitiesOnly=yes \
- -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="$state/known_hosts" \
- "[email protected]:$1" "$2"
- ;;
-stop)
- exec ssh -n "${ssh_args[@]}" [email protected] poweroff
- ;;
-start|start-install)
- [ -f "$state/debian-x86_64.img" ] || { echo "missing cloned rootfs in $state" >&2; exit 1; }
- ;;
-*)
- printf 'usage: %s start-install|start|stop|ssh|push|pull [arguments]\n' "$0"
- exit 2
- ;;
-esac
-
-exec 9>"$state/vm.lock"
-flock -n 9 || { echo 'prototype VM is already running' >&2; exit 1; }
-mkdir -p "$state/tpm"
-rm -f "$state/tpm.sock"
-swtpm socket --tpm2 --tpmstate dir="$state/tpm" \
- --ctrl type=unixio,path="$state/tpm.sock" \
- --flags not-need-init,startup-clear &
-tpm_pid=$!
-trap 'kill "$tpm_pid" 2>/dev/null || true; wait "$tpm_pid" 2>/dev/null || true' EXIT
-for ((attempt = 0; attempt < 50; attempt++)); do
- [[ -S "$state/tpm.sock" ]] && break
- kill -0 "$tpm_pid"
- sleep 0.1
-done
-[[ -S "$state/tpm.sock" ]]
-
-if [[ "$command" == start-install ]]; then
- boot=(-kernel "$state/vmlinuz-bootstrap" -initrd "$state/initrd-bootstrap.img"
- -append 'console=ttyS0,115200 root=/dev/vda rw nokaslr lsm=bpf bpf.keyring_unsealed=1 rd.systemd.mask=shirudo-initrd.service systemd.mask=shirudo.service')
-else
- [ -f "$state/verity-ready" ] || { echo 'install and verify the prototype UKI first' >&2; exit 1; }
- boot=(-drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE_4M.fd
- -drive if=pflash,format=raw,file="$state/OVMF_VARS_4M.fd"
- -drive if=virtio,format=raw,readonly=on,file="$state/esp.img")
-fi
-qemu-system-x86_64 -enable-kvm -cpu host -machine q35 -name shirudo-verity \
- -smp 4 -m 4G -display none -monitor none -serial stdio \
- -gdb tcp:127.0.0.1:"$gdb_port" \
- -qmp unix:"$state/qmp.sock",server=on,wait=off \
- -netdev user,id=net0,hostfwd=tcp:127.0.0.1:"$port"-:22 \
- -device virtio-net-pci,netdev=net0 \
- -drive file="$state/debian-x86_64.img",format=raw,if=virtio \
- -chardev socket,id=chrtpm,path="$state/tpm.sock" \
- -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 \
- "${boot[@]}" "$@"
diff --git a/contrib/verity-vm/README.md b/contrib/verity-vm/README.md
deleted file mode 100644
index 5c0e0005..00000000
--- a/contrib/verity-vm/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# VM image fixtures
-
-The configs, service units and guest scripts used by the image tests live
-here. The calling scripts copy these files and substitute the values named
-between `@` characters in `.in` templates.
-
-`seed-root.sh` installs the boot files in the initrd and `seed-images.sh`
-installs the runtime and signed config fixtures. `install-guest.sh` finishes the manual VM setup.
-The runtime service template used by the operator is kept separately in
-`tools/gen-image/runtime-service.conf.in`.
diff --git a/contrib/verity-vm/esp.sfdisk b/contrib/verity-vm/esp.sfdisk
deleted file mode 100644
index 101f8580..00000000
--- a/contrib/verity-vm/esp.sfdisk
+++ /dev/null
@@ -1,2 +0,0 @@
-label: gpt
-start=2048, type=U
diff --git a/contrib/verity-vm/install-guest.sh b/contrib/verity-vm/install-guest.sh
deleted file mode 100644
index fb03027e..00000000
--- a/contrib/verity-vm/install-guest.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-
-set -euo pipefail
-chmod 0755 /usr/local/bin/shirudo /usr/local/bin/shirudo-runtime \
- /usr/local/bin/shirudo-gen-initrd \
- /usr/lib/dracut/modules.d/90shirudo/module-setup.sh
-mkdir -p /root/prototype-backup
-if [ -d /var/lib/shirudo/upatches ] && [ ! -e /root/prototype-backup/upatches ]; then
- mv /var/lib/shirudo/upatches /root/prototype-backup/upatches
-fi
-mkdir -p /var/lib/shirudo/upatches
-/usr/local/bin/shirudo-gen-initrd --kver "$1" --output /boot/initrd-shirudo-verity.img \
- --binary /usr/local/bin/shirudo --binary-path /usr/local/bin/shirudo \
- --cert /var/lib/shirudo/keys/cert.der --bootstrap-conf /etc/shirudo/shirudo.conf \
- --unit /usr/lib/systemd/system/shirudo-initrd.service \
- -- --no-hostonly --no-hostonly-cmdline --add-drivers 'efivarfs dm_mod dm_verity loop ext4' \
- --modules 'base systemd systemd-initrd dracut-systemd rootfs-block fs-lib udev-rules terminfo shirudo' \
- >/root/test-results/verity/initrd-build.log 2>&1
-ukify build --linux /boot/vmlinuz-shirudo-verity --initrd /boot/initrd-shirudo-verity.img \
- --cmdline @/etc/kernel/cmdline --os-release @/etc/os-release \
- --output /boot/shirudo-verity.efi >/root/test-results/verity/uki-build.log 2>&1
diff --git a/contrib/verity-vm/kernel.cmdline b/contrib/verity-vm/kernel.cmdline
deleted file mode 100644
index ea9fb2ba..00000000
--- a/contrib/verity-vm/kernel.cmdline
+++ /dev/null
@@ -1 +0,0 @@
-console=ttyS0,115200 root=/dev/vda rw nokaslr lsm=bpf bpf.keyring_unsealed=1 dm_verity.keyring_unsealed=1
diff --git a/testing/Makefile b/testing/Makefile
index 7d4dbf92..0132ad59 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -14,9 +14,9 @@ endif
export Q V
root-path = $(if $(filter /%,$(1)),$(1),$(ROOT)/$(1))
-# $(call test-vm-arch,NAME): the value contrib/test-vm-arch.sh gives NAME.
+# $(call test-vm-arch,NAME): the value testing/vm/arch.sh gives NAME.
test-vm-arch = $(shell TEST_VM_ARCH='$(TEST_VM_ARCH)'; \
- . $(ROOT)/contrib/test-vm-arch.sh && printf '%s' "$$$(1)")
+ . $(ROOT)/testing/vm/arch.sh && printf '%s' "$$$(1)")
.DEFAULT_GOAL := help
.PHONY: help clean test-helpers test-op fuzz test bundle test-vm-bundle kernel \
@@ -119,10 +119,11 @@ TEST_VM_BUNDLE_SOURCES := $(sort $(wildcard \
$(ROOT)/vendor/libbpf/include/uapi/linux/*.h \
$(ROOT)/vendor/libbpf/include/asm/*.h \
$(ROOT)/testing/helper/*.c $(ROOT)/testing/helper/*.h $(ROOT)/testing/helper/*.py \
- $(ROOT)/testing/tamperproof/*.c $(ROOT)/contrib/verity-*.sh \
+ $(ROOT)/testing/tamperproof/*.c \
+ $(ROOT)/testing/vm/bundle-images.sh $(ROOT)/testing/vm/image-fixtures.sh \
$(ROOT)/tools/gen-image/shirudo-gen-* $(ROOT)/tools/gen-image/*.sh \
$(ROOT)/tools/gen-image/*.in \
- $(ROOT)/contrib/verity-vm/* \
+ $(ROOT)/testing/vm/files/* \
$(ROOT)/testing/upatch/kernel-obs/exec/*.c $(ROOT)/completion/* $(ROOT)/systemd/*.in \
$(ROOT)/systemd/*.timer $(ROOT)/testing/fixtures/*.c $(ROOT)/testing/fixtures/*.lua \
$(ROOT)/testing/fixtures/*.conf $(ROOT)/testing/fixtures/*.sh \
@@ -140,9 +141,9 @@ TEST_VM_BUNDLE_INPUTS := $(sort \
$(ROOT)/testing/Makefile $(ROOT)/packaging/Makefile \
$(ROOT)/vendor/libbpf/Makefile $(ROOT)/vendor/libbpf/COMMIT \
$(ROOT)/Documentation/Makefile $(ROOT)/upatches/kernel-obs/Makefile \
- $(ROOT)/contrib/build-test-vm-bundle.sh $(ROOT)/contrib/test-vm-guest.sh \
- $(ROOT)/contrib/test-vm-arch.sh \
- $(ROOT)/contrib/prepare-test-vm-runtime.sh $(ROOT)/contrib/test-vm-runtime-packages \
+ $(ROOT)/testing/vm/build-bundle.sh $(ROOT)/testing/vm/guest.sh \
+ $(ROOT)/testing/vm/arch.sh \
+ $(ROOT)/testing/vm/prepare-runtime.sh $(ROOT)/testing/vm/runtime-packages \
$(TEST_VM_BUNDLE_SOURCES) $(TEST_VM_BUNDLE_ARTIFACTS) \
$(if $(strip $(TEST_VM_PACKAGE_CERT)),$(TEST_VM_PACKAGE_CERT)))
@@ -163,7 +164,7 @@ $(TEST_VM_BUNDLE_STAMP): $(TEST_VM_BUNDLE_INPUTS)
TEST_VM_BUNDLE_STAMP="$(abspath $(TEST_VM_BUNDLE_STAMP))" \
TEST_VM_BUNDLE_INPUTS="$(abspath $(TEST_VM_BUNDLE_INPUTS))" \
BPF_VMLINUX_BTF="$(abspath $(VM_KERNEL_ARTIFACT_DIR)/vmlinux.btf)" \
- $(ROOT)/contrib/build-test-vm-bundle.sh
+ $(ROOT)/testing/vm/build-bundle.sh
kernel: $(KERNEL_BUILD_STAMP)
@@ -172,9 +173,9 @@ bpf-next:
KERNEL_PATCHES='$(KERNEL_PATCHES)' \
KERNEL_CONFIG='$(KERNEL_CONFIG)' \
KERNEL_BUILD_JOBS='$(KERNEL_BUILD_JOBS)' \
- $(ROOT)/contrib/build-kernel-package.sh
+ $(ROOT)/testing/vm/build-kernel.sh
-$(KERNEL_BUILD_STAMP): $(ROOT)/contrib/build-kernel-package.sh $(KERNEL_PATCH_FILES)
+$(KERNEL_BUILD_STAMP): $(ROOT)/testing/vm/build-kernel.sh $(KERNEL_PATCH_FILES)
$(Q)KERNEL_TAG='$(KERNEL_TAG_NORMALIZED)' \
KERNEL_COMMIT='$(KERNEL_COMMIT)' \
KERNEL_PATCHES='$(KERNEL_PATCHES)' \
@@ -184,7 +185,7 @@ $(KERNEL_BUILD_STAMP): $(ROOT)/contrib/build-kernel-package.sh $(KERNEL_PATCH_FI
PACKAGE_FORMAT='$(PACKAGE_FORMAT)' \
KERNEL_BUILD_JOBS='$(KERNEL_BUILD_JOBS)' \
OUTPUT_DIR="$(abspath $(KERNEL_BUILD_ARTIFACT_DIR))" \
- $(ROOT)/contrib/build-kernel-package.sh
+ $(ROOT)/testing/vm/build-kernel.sh
# A VM selection owns its kernel artifact independently of the generic
# KERNEL_TAG selection used by `make -C testing kernel`.
@@ -216,14 +217,14 @@ vm: $(VM_KERNEL_DEP) test-vm-bundle
TEST_VM_BPM_OCI_INDEX_CERT="$(TEST_VM_BPM_OCI_INDEX_CERT)" \
TEST_VM_MODE="$(TEST_VM_MODE)" TEST_VM_INITRD="$(TEST_VM_INITRD)" \
TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \
- $(ROOT)/contrib/test-vm.sh
+ $(ROOT)/testing/vm/run.sh
vm-console:
$(Q)VM_NAME="$(VM_NAME)" \
- TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/contrib/test-vm.sh --console
+ TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --console
vm-ssh:
$(Q)VM_NAME="$(VM_NAME)" \
- TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/contrib/test-vm.sh --ssh
+ TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --ssh
define run-target-vm
VM_MODE=test TEST_VM_SUITE="$(1)" VM_VERBOSE="$(TEST_VM_VERBOSE)" VM_NAME="$(2)" VM_TENANT="$(VM_TENANT)" \
@@ -241,7 +242,7 @@ VM_MODE=test TEST_VM_SUITE="$(1)" VM_VERBOSE="$(TEST_VM_VERBOSE)" VM_NAME="$(2)"
TEST_VM_BPM_OCI_INDEX_CERT="$(TEST_VM_BPM_OCI_INDEX_CERT)" \
TEST_VM_MODE="$(TEST_VM_MODE)" \
TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \
- $(ROOT)/contrib/test-vm.sh
+ $(ROOT)/testing/vm/run.sh
endef
test-tgt-register: $(VM_KERNEL_DEP) test-vm-bundle
@@ -265,15 +266,15 @@ test-tgt-obs: $(VM_KERNEL_DEP) test-vm-bundle
TEST_VM_BPM_OCI_INDEX_CERT="$(TEST_VM_BPM_OCI_INDEX_CERT)" \
TEST_VM_MODE="$(TEST_VM_MODE)" TEST_VM_INITRD="$(TEST_VM_INITRD)" \
TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \
- $(ROOT)/contrib/test-vm.sh
+ $(ROOT)/testing/vm/run.sh
vm-stop:
$(Q)VM_NAME="$(VM_NAME)" \
- TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/contrib/test-vm.sh --stop
+ TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --stop
vm-clean:
$(Q)VM_NAME="$(VM_NAME)" \
- TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/contrib/test-vm.sh --clean
+ TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --clean
test-vm-clean: vm-clean
diff --git a/contrib/swtpm.sh b/testing/swtpm.sh
similarity index 89%
rename from contrib/swtpm.sh
rename to testing/swtpm.sh
index a7011543..6ec8f2ea 100755
--- a/contrib/swtpm.sh
+++ b/testing/swtpm.sh
@@ -2,17 +2,17 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
#
-# contrib/swtpm.sh -- spin up a software TPM 2.0 (swtpm) on loopback for
+# testing/swtpm.sh -- spin up a software TPM 2.0 (swtpm) on loopback for
# shirudo dev and CI. Same recipe as Documentation/getting-started.rst
# "TPM in development", packaged so a single command brings the emulator
# up, prints the SHIRUDO_TPM_TCTI line to export, and tears it down.
#
# Usage:
-# contrib/swtpm.sh start # bring it up, print SHIRUDO_TPM_TCTI=...
-# contrib/swtpm.sh stop # stop the emulator (state kept)
-# contrib/swtpm.sh status # is it running? on which port?
-# contrib/swtpm.sh clean # stop + wipe the state dir (TPM reset)
-# contrib/swtpm.sh env # print the export line for the running one
+# testing/swtpm.sh start # bring it up, print SHIRUDO_TPM_TCTI=...
+# testing/swtpm.sh stop # stop the emulator (state kept)
+# testing/swtpm.sh status # is it running? on which port?
+# testing/swtpm.sh clean # stop + wipe the state dir (TPM reset)
+# testing/swtpm.sh env # print the export line for the running one
#
# Env overrides (all optional):
# SHIRUDO_SWTPM_STATE state dir (default /tmp/shirudo-swtpm)
@@ -98,8 +98,8 @@ do_start() {
say ""
say " export SHIRUDO_TPM_TCTI='$TCTI'"
say ""
- say "Stop with: contrib/swtpm.sh stop"
- say "Reset NV: contrib/swtpm.sh clean"
+ say "Stop with: testing/swtpm.sh stop"
+ say "Reset NV: testing/swtpm.sh clean"
}
do_stop() {
@@ -138,7 +138,7 @@ do_status() {
}
do_env() {
- is_running || die "swtpm not running (start it first: contrib/swtpm.sh start)"
+ is_running || die "swtpm not running (start it first: testing/swtpm.sh start)"
printf "export SHIRUDO_TPM_TCTI='%s'\n" "$TCTI"
}
diff --git a/testing/t0015-test-vm-cli.sh b/testing/t0015-test-vm-cli.sh
index 4a41b347..d9535cbd 100755
--- a/testing/t0015-test-vm-cli.sh
+++ b/testing/t0015-test-vm-cli.sh
@@ -5,7 +5,7 @@
cd "$(dirname "$0")"
. ./test-lib.sh
-RUNNER=../contrib/test-vm.sh
+RUNNER=vm/run.sh
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
@@ -158,7 +158,7 @@ test_expect_success 'an ISO writer stands in for cloud-localds' '
'
test_expect_success 'the host package manager is detected from os-release' '
- sed "s|/etc/os-release|$WORK/os-release|g" ../contrib/test-vm-arch.sh \
+ sed "s|/etc/os-release|$WORK/os-release|g" vm/arch.sh \
>"$WORK/arch-os.sh" &&
host_pkg() {
printf "%s\n" "$@" >"$WORK/os-release" &&
@@ -171,7 +171,7 @@ test_expect_success 'the host package manager is detected from os-release' '
test "$(host_pkg ID=debian)" = apt &&
(
TEST_VM_HOST_PKG=dnf &&
- . ../contrib/test-vm-arch.sh &&
+ . vm/arch.sh &&
test "$TEST_VM_HOST_PKG_FORMAT" = rpm &&
test "$(test_vm_install_cmd a b)" = "sudo dnf install -y a b"
)
@@ -187,14 +187,14 @@ test_expect_success 'the bundle and runtime scripts print hints for the host pac
done &&
! PATH="$WORK/bundle-bin" TEST_VM_HOST_PKG=dnf \
TEST_VM_WORK_DIR="$WORK/bundle-dnf" /bin/bash \
- ../contrib/build-test-vm-bundle.sh >"$WORK/bundle-dnf.out" 2>&1 &&
+ vm/build-bundle.sh >"$WORK/bundle-dnf.out" 2>&1 &&
grep -q "virt-customize (install with: sudo dnf install -y guestfs-tools)" \
"$WORK/bundle-dnf.out" &&
printf rootfs >"$WORK/hint-rootfs" &&
! PATH="$WORK/bundle-bin" TEST_VM_HOST_PKG=dnf /bin/bash \
- ../contrib/prepare-test-vm-runtime.sh --rootfs "$WORK/hint-rootfs" \
+ vm/prepare-runtime.sh --rootfs "$WORK/hint-rootfs" \
--cache-dir "$WORK/hint-cache" \
- --package-file ../contrib/test-vm-runtime-packages \
+ --package-file vm/runtime-packages \
--runtime-key hint --key-output "$WORK/hint-key" \
>"$WORK/runtime-dnf.out" 2>&1 &&
grep -q "virt-customize is required; install it with: sudo dnf install -y guestfs-tools" \
@@ -212,7 +212,7 @@ test_expect_success 'the bundle wants a DHCP client for the appliance on a Debia
done &&
! PATH="$WORK/dhcp-bin" TEST_VM_HOST_PKG=apt \
TEST_VM_WORK_DIR="$WORK/bundle-dhcp" /bin/bash \
- ../contrib/build-test-vm-bundle.sh >"$WORK/bundle-dhcp.out" 2>&1 &&
+ vm/build-bundle.sh >"$WORK/bundle-dhcp.out" 2>&1 &&
grep -q "missing host command: dhclient (install with: sudo apt-get install -y --no-install-recommends isc-dhcp-client)" \
"$WORK/bundle-dhcp.out"
'
@@ -233,9 +233,9 @@ test_expect_success 'the runtime image is built with the direct libguestfs backe
rm -rf "$WORK/gf-cache" &&
env "$@" PATH="$WORK/gf-bin:$PATH" GF_OUT="$WORK/gf-out" \
TMPDIR="$WORK" LIBGUESTFS_CACHEDIR="$WORK/gf-cache" \
- ../contrib/prepare-test-vm-runtime.sh \
+ vm/prepare-runtime.sh \
--rootfs "$WORK/gf-rootfs" --cache-dir "$WORK/gf-cache/img" \
- --package-file ../contrib/test-vm-runtime-packages \
+ --package-file vm/runtime-packages \
--runtime-key gf --key-output "$WORK/gf-cache/key" \
>/dev/null 2>&1 &&
cat "$WORK/gf-out"
@@ -248,7 +248,7 @@ test_expect_success 'the runtime image is built with the direct libguestfs backe
test "$(guestfs_env TEST_VM_QEMU="$WORK/gf-bin/none")" = "direct unset"
'
-# Stand-ins for the tools prepare-test-vm-runtime.sh calls; every command it
+# Stand-ins for the tools vm/prepare-runtime.sh calls; every command it
# runs is recorded, so the tests below read what it would have done.
mkdir -p "$WORK/dns-bin" "$WORK/dns-cache"
printf "%s\n" "#!/bin/sh" \
@@ -266,7 +266,7 @@ printf "%s\n" "search example.com" "nameserver 127.0.0.53" \
"nameserver fe80::1%eth0" "nameserver 192.0.2.53" \
>"$WORK/dns-resolv.conf"
-# Run prepare-test-vm-runtime.sh against stand-ins for the tools it needs:
+# Run vm/prepare-runtime.sh against stand-ins for the tools it needs:
# run_dns RESOLV_CONF [VAR=value...].
run_dns() {
resolv=$1
@@ -278,9 +278,9 @@ run_dns() {
GF_ARGS="$WORK/dns-args" GF_NS="$WORK/dns-ns" \
LIBGUESTFS_CACHEDIR="$WORK/dns-cache" \
TEST_VM_RESOLV_CONF="$resolv" \
- ../contrib/prepare-test-vm-runtime.sh \
+ vm/prepare-runtime.sh \
--rootfs "$WORK/dns-rootfs" --cache-dir "$WORK/dns-cache/img" \
- --package-file ../contrib/test-vm-runtime-packages \
+ --package-file vm/runtime-packages \
--runtime-key dns-test --key-output "$WORK/dns-cache/key" \
>"$WORK/dns-run.out" 2>&1
}
@@ -327,9 +327,9 @@ test_expect_success 'a failed runtime image shows what apt could not fetch' '
chmod +x "$WORK/aptfail-bin/virt-customize" &&
! env PATH="$WORK/aptfail-bin:$WORK/dns-bin:$PATH" TMPDIR="$WORK" \
LIBGUESTFS_CACHEDIR="$WORK/aptfail-cache" \
- ../contrib/prepare-test-vm-runtime.sh \
+ vm/prepare-runtime.sh \
--rootfs "$WORK/dns-rootfs" --cache-dir "$WORK/aptfail-cache/img" \
- --package-file ../contrib/test-vm-runtime-packages \
+ --package-file vm/runtime-packages \
--runtime-key aptfail --key-output "$WORK/aptfail-cache/key" \
>"$WORK/aptfail.out" 2>&1 &&
grep -q "apt could not fetch" "$WORK/aptfail.out" &&
@@ -373,57 +373,57 @@ test_expect_success 'test-vm selects the root partition without an initramfs' '
'
test_expect_success 'test-vm guest uses prebuilt target fixtures' '
- grep -q "SHIRUDO_TEST_FIXTURES_DIR" ../contrib/test-vm-guest.sh &&
- grep -q "run-target-tests.sh" ../contrib/test-vm-guest.sh &&
- ! grep -q "SHIRUDO_BUILD_BIN=" ../contrib/test-vm-guest.sh &&
- grep -q "prepared Ubuntu runtime image" ../contrib/test-vm-guest.sh &&
- ! grep -q "apt-get install" ../contrib/test-vm-guest.sh &&
+ grep -q "SHIRUDO_TEST_FIXTURES_DIR" vm/guest.sh &&
+ grep -q "run-target-tests.sh" vm/guest.sh &&
+ ! grep -q "SHIRUDO_BUILD_BIN=" vm/guest.sh &&
+ grep -q "prepared Ubuntu runtime image" vm/guest.sh &&
+ ! grep -q "apt-get install" vm/guest.sh &&
test -x run-target-tests.sh &&
test -x t1200-target-fixtures.sh &&
- ! grep -q "libluajit-5.1-dev" ../contrib/test-vm-guest.sh
+ ! grep -q "libluajit-5.1-dev" vm/guest.sh
'
test_expect_success 'the Ubuntu image and packages are those of the host architecture' '
(
TEST_VM_ARCH=x86_64 &&
- . ../contrib/test-vm-arch.sh &&
+ . vm/arch.sh &&
test "$TEST_VM_ARCH_DEB" = amd64 &&
test "$TEST_VM_ARCH_MIRROR" = https://archive.ubuntu.com/ubuntu
) &&
(
TEST_VM_ARCH=aarch64 &&
- . ../contrib/test-vm-arch.sh &&
+ . vm/arch.sh &&
test "$TEST_VM_ARCH_DEB" = arm64 &&
test "$TEST_VM_ARCH_MIRROR" = https://ports.ubuntu.com/ubuntu-ports
) &&
- ! grep -q "amd64" ../contrib/test-vm.sh ../contrib/build-test-vm-bundle.sh &&
- ! grep -q "x86_64\|archive.ubuntu.com" ../contrib/build-test-vm-bundle.sh
+ ! grep -q "amd64" vm/run.sh vm/build-bundle.sh &&
+ ! grep -q "x86_64\|archive.ubuntu.com" vm/build-bundle.sh
'
test_expect_success 'test-vm imports the host-built payload' '
grep -q "TEST_VM_BUNDLE_DIR" ../testing/Makefile &&
grep -q "test-vm-bundle" ../testing/Makefile &&
- grep -q "build-test-vm-bundle.sh" ../testing/Makefile &&
- grep -q "prepare-test-vm-runtime.sh" ../testing/Makefile &&
- grep -q "virt-customize" ../contrib/build-test-vm-bundle.sh &&
- grep -q "mount_tag=shirudo-bundle" ../contrib/test-vm.sh &&
+ grep -q "vm/build-bundle.sh" ../testing/Makefile &&
+ grep -q "vm/prepare-runtime.sh" ../testing/Makefile &&
+ grep -q "virt-customize" vm/build-bundle.sh &&
+ grep -q "mount_tag=shirudo-bundle" vm/run.sh &&
grep -q "importing host-built Shirudo payload" \
- ../contrib/test-vm-guest.sh &&
- grep -q "mountpoint -q /run/shirudo/runtime" ../contrib/test-vm-guest.sh &&
- ! grep -q "vmlinux.h" ../contrib/test-vm-guest.sh &&
- ! grep -q "shirudo-build" ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
+ grep -q "mountpoint -q /run/shirudo/runtime" vm/guest.sh &&
+ ! grep -q "vmlinux.h" vm/guest.sh &&
+ ! grep -q "shirudo-build" vm/guest.sh &&
! grep -Fq "make \"\${BPF_MAKE_ARGS[@]}\" check" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -Fq "LIBBPF_VENDOR := vendor/libbpf" ../Makefile.shirudo &&
grep -Fq "\$(LIBBPF_A)" ../Makefile.shirudo &&
grep -Fq "VMLINUX_GEN := tools/gen-vmlinux-h/gen-vmlinux-h" \
../Makefile.shirudo &&
- ! grep -q "shirudo-bpf-deps" ../contrib/build-kernel-package.sh
+ ! grep -q "shirudo-bpf-deps" vm/build-kernel.sh
'
test_expect_success 'test-vm bundle stamp controls incremental rebuilds' '
grep -q "TEST_VM_BUNDLE_STAMP" ../testing/Makefile &&
grep -q "TEST_VM_BUNDLE_INPUTS" ../testing/Makefile &&
- grep -q "bundle_is_current" ../contrib/build-test-vm-bundle.sh &&
+ grep -q "bundle_is_current" vm/build-bundle.sh &&
grep -q "flock 9" ../testing/Makefile &&
grep -q "bundle_dir.lock" ../testing/Makefile &&
! grep -Fq "rm -rf \"\$\$bundle_dir.lock\"" ../testing/Makefile &&
@@ -431,16 +431,16 @@ test_expect_success 'test-vm imports the host-built payload' '
'
test_expect_success 'test-vm summary records failed test names' '
- grep -q "print_test_summary" ../contrib/test-vm.sh &&
- grep -q "exit \"\$FINAL_STATUS\"" ../contrib/test-vm.sh &&
- grep -q "failed tests:" ../contrib/test-vm.sh &&
+ grep -q "print_test_summary" vm/run.sh &&
+ grep -q "exit \"\$FINAL_STATUS\"" vm/run.sh &&
+ grep -q "failed tests:" vm/run.sh &&
grep -q "VM_VERBOSE" ../testing/Makefile &&
- grep -q "summary_log" ../contrib/test-vm.sh &&
- grep -q "print_quiet_progress" ../contrib/test-vm.sh &&
- grep -q "stream_verbose_console" ../contrib/test-vm.sh &&
- grep -q "qemu.log\\\" 2>&1 &" ../contrib/test-vm.sh &&
- grep -q "SHIRUDO_TEST_FAILURES_FILE" ../contrib/test-vm-guest.sh &&
- grep -q "SHIRUDO_TEST_SUITE_FAILURES_FILE" ../contrib/test-vm-guest.sh &&
+ grep -q "summary_log" vm/run.sh &&
+ grep -q "print_quiet_progress" vm/run.sh &&
+ grep -q "stream_verbose_console" vm/run.sh &&
+ grep -q "qemu.log\\\" 2>&1 &" vm/run.sh &&
+ grep -q "SHIRUDO_TEST_FAILURES_FILE" vm/guest.sh &&
+ grep -q "SHIRUDO_TEST_SUITE_FAILURES_FILE" vm/guest.sh &&
grep -q "SHIRUDO_TEST_FAILURES_FILE" ../testing/test-lib.sh &&
grep -q "SHIRUDO_TEST_SUITE_FAILURES_FILE" ../testing/run-tests.sh
'
@@ -461,11 +461,11 @@ test_expect_success 'make -C testing vm and test-vm share named mode support' '
grep -q "^[[:space:]]*vm:" ../testing/Makefile &&
grep -q "VM_MODE=interactive" ../testing/Makefile &&
grep -q "VM_MODE=test" ../testing/Makefile &&
- grep -Fq "VMS_DIR=\"\${VM_ROOT}/vms\"" ../contrib/test-vm.sh &&
+ grep -Fq "VMS_DIR=\"\${VM_ROOT}/vms\"" vm/run.sh &&
grep -Fq "mktemp -d \"\${VMS_DIR}/\${VM_MODE}-XXXXXX\"" \
- ../contrib/test-vm.sh &&
- grep -q "VM_TENANT" ../contrib/test-vm.sh &&
- grep -q "while :; do sleep 3600; done" ../contrib/test-vm.sh
+ vm/run.sh &&
+ grep -q "VM_TENANT" vm/run.sh &&
+ grep -q "while :; do sleep 3600; done" vm/run.sh
'
test_expect_success 'make -C testing vm boots a release kernel at or above the floor' '
grep -q "VM_KERNEL_MIN := 7.4" ../testing/Makefile &&
@@ -502,7 +502,7 @@ test_expect_success 'the VM kernel image is named for the host architecture' '
'
test_expect_success 'the VM kernel is not built on an unsupported architecture' '
- ! TEST_VM_ARCH=riscv64 ../contrib/build-kernel-package.sh \
+ ! TEST_VM_ARCH=riscv64 vm/build-kernel.sh \
>"$WORK/riscv64-kernel.out" 2>&1 &&
grep -q "x86_64 and aarch64 hosts only, not riscv64" \
"$WORK/riscv64-kernel.out"
@@ -510,20 +510,18 @@ test_expect_success 'the VM kernel is not built on an unsupported architecture'
test_expect_success 'the kernel builder requires the NV writer parser and RSA support' '
for symbol in PKCS8_PRIVATE_KEY_PARSER CRYPTO_RSA; do
- grep -qx "CONFIG_$symbol=y" ../contrib/build-kernel-package.sh &&
- grep -qx "require_config CONFIG_$symbol y" ../contrib/build-kernel-package.sh ||
+ grep -qx "CONFIG_$symbol=y" vm/build-kernel.sh &&
+ grep -qx "require_config CONFIG_$symbol y" vm/build-kernel.sh ||
exit 1
done
'
test_expect_success 'all kernel and VM builds use the slim profile' '
! grep -Eq "^(kernel-small|vm-small|test-vm-small-bundle):" ../testing/Makefile &&
- ! grep -q "KERNEL_PROFILE" ../testing/Makefile ../contrib/build-kernel-package.sh &&
- ! test -e ../contrib/kernel-small.config &&
- ! test -e ../contrib/kernel-observability-configs.txt &&
- grep -q "kernel-slim.config" ../contrib/build-kernel-package.sh &&
- grep -q "config_profile=slim" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" ../contrib/build-kernel-package.sh &&
+ ! grep -q "KERNEL_PROFILE" ../testing/Makefile vm/build-kernel.sh &&
+ grep -q "kernel-slim.config" vm/build-kernel.sh &&
+ grep -q "config_profile=slim" vm/build-kernel.sh &&
+ grep -q "CONFIG_CC_OPTIMIZE_FOR_SIZE=y" vm/build-kernel.sh &&
grep -q "make -C testing vm KERNEL=7.4" ../testing/Makefile &&
make -n -C .. -f testing/Makefile vm VM_NAME=slim-cli-vm \
TEST_VM_ARCH=x86_64 TEST_VM_WORK_DIR="$WORK/slim-vm" \
@@ -535,29 +533,29 @@ test_expect_success 'all kernel and VM builds use the slim profile' '
'
test_expect_success 'VM reports guest and host memory usage' '
- grep -q "report_boot_memory" ../contrib/test-vm-guest.sh &&
- grep -q "guest_mem_total_kb" ../contrib/test-vm-guest.sh &&
- grep -q "guest_mem_available_kb" ../contrib/test-vm-guest.sh &&
- grep -q "guest_mem_used_percent" ../contrib/test-vm-guest.sh &&
- grep -q "capture_host_memory_report" ../contrib/test-vm.sh &&
- grep -q "qemu_vmrss_kb" ../contrib/test-vm.sh &&
- grep -q "qemu_pss_kb" ../contrib/test-vm.sh &&
- grep -q "print_memory_summary" ../contrib/test-vm.sh
+ grep -q "report_boot_memory" vm/guest.sh &&
+ grep -q "guest_mem_total_kb" vm/guest.sh &&
+ grep -q "guest_mem_available_kb" vm/guest.sh &&
+ grep -q "guest_mem_used_percent" vm/guest.sh &&
+ grep -q "capture_host_memory_report" vm/run.sh &&
+ grep -q "qemu_vmrss_kb" vm/run.sh &&
+ grep -q "qemu_pss_kb" vm/run.sh &&
+ grep -q "print_memory_summary" vm/run.sh
'
test_expect_success 'make -C testing kernel builds a tagged third-party Linux source' '
grep -q "^kernel: \$(KERNEL_BUILD_STAMP)" ../testing/Makefile &&
grep -q "KERNEL_TAG=\"\${KERNEL_TAG:-bpf-next}\"" \
- ../contrib/build-kernel-package.sh &&
+ vm/build-kernel.sh &&
grep -q "KERNEL_REPOSITORY=\"\${KERNEL_REPOSITORY:-https://git.kernel.org" \
- ../contrib/build-kernel-package.sh &&
- grep -q "git clone --depth 1 --branch" ../contrib/build-kernel-package.sh &&
+ vm/build-kernel.sh &&
+ grep -q "git clone --depth 1 --branch" vm/build-kernel.sh &&
grep -q "make -C testing kernel KERNEL_TAG=v7.4" ../testing/Makefile &&
- ! KERNEL_TAG=not-a-kernel-tag ../contrib/build-kernel-package.sh \
+ ! KERNEL_TAG=not-a-kernel-tag vm/build-kernel.sh \
>"$WORK/invalid-kernel-tag.out" 2>&1 &&
grep -q "KERNEL_TAG must be bpf-next or a Linux release tag" \
"$WORK/invalid-kernel-tag.out" &&
- ! KERNEL_TAG=v6.18 ../contrib/build-kernel-package.sh \
+ ! KERNEL_TAG=v6.18 vm/build-kernel.sh \
>"$WORK/old-kernel-tag.out" 2>&1 &&
grep -q "requires Linux v7.4 or newer" "$WORK/old-kernel-tag.out"
'
@@ -574,46 +572,46 @@ test_expect_success 'make -C testing vm and kernel select an exact release commi
grep -q "KERNEL_COMMIT is supported only for release VM kernels" \
"$WORK/commit-bpf-next.out" &&
! KERNEL_TAG=v7.4 KERNEL_COMMIT=not-a-sha \
- ../contrib/build-kernel-package.sh >"$WORK/invalid-kernel-commit.out" 2>&1 &&
+ vm/build-kernel.sh >"$WORK/invalid-kernel-commit.out" 2>&1 &&
grep -q "KERNEL_COMMIT must contain 7 to 40 hexadecimal characters" \
"$WORK/invalid-kernel-commit.out"
'
test_expect_success 'kernel VM artifacts provide networking modules' '
- grep -q "CONFIG_VETH=m" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_BRIDGE=m" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_VLAN_8021Q=m" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_NF_FLOW_TABLE=m" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_NF_FLOW_TABLE_INET=m" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_NF_FLOW_TABLE_PROCFS=y" ../contrib/build-kernel-package.sh &&
- grep -q "CONFIG_PROC_FS=y" ../contrib/build-kernel-package.sh &&
- grep -q "require_config CONFIG_VETH m" ../contrib/build-kernel-package.sh &&
- grep -q "dpkg-deb -x" ../contrib/build-kernel-package.sh &&
- grep -q "depmod -b" ../contrib/build-kernel-package.sh &&
+ grep -q "CONFIG_VETH=m" vm/build-kernel.sh &&
+ grep -q "CONFIG_BRIDGE=m" vm/build-kernel.sh &&
+ grep -q "CONFIG_VLAN_8021Q=m" vm/build-kernel.sh &&
+ grep -q "CONFIG_NF_FLOW_TABLE=m" vm/build-kernel.sh &&
+ grep -q "CONFIG_NF_FLOW_TABLE_INET=m" vm/build-kernel.sh &&
+ grep -q "CONFIG_NF_FLOW_TABLE_PROCFS=y" vm/build-kernel.sh &&
+ grep -q "CONFIG_PROC_FS=y" vm/build-kernel.sh &&
+ grep -q "require_config CONFIG_VETH m" vm/build-kernel.sh &&
+ grep -q "dpkg-deb -x" vm/build-kernel.sh &&
+ grep -q "depmod -b" vm/build-kernel.sh &&
grep -q "TEST_VM_KERNEL_ARTIFACT_DIR" ../testing/Makefile &&
- grep -q "mount_tag=shirudo-kernel" ../contrib/test-vm.sh &&
- grep -q "TEST_VM_KERNEL_MODULES" ../contrib/test-vm.sh &&
- grep -q "install_kernel_modules" ../contrib/test-vm-guest.sh &&
- grep -q "modprobe \"\$module\"" ../contrib/test-vm-guest.sh &&
- grep -q "nf_flow_table_procfs" ../contrib/test-vm-guest.sh
+ grep -q "mount_tag=shirudo-kernel" vm/run.sh &&
+ grep -q "TEST_VM_KERNEL_MODULES" vm/run.sh &&
+ grep -q "install_kernel_modules" vm/guest.sh &&
+ grep -q "modprobe \"\$module\"" vm/guest.sh &&
+ grep -q "nf_flow_table_procfs" vm/guest.sh
'
test_expect_success 'prepared VM runtime includes ripgrep' '
- grep -qx "ripgrep" ../contrib/test-vm-runtime-packages &&
- grep -q "package_digest" ../contrib/build-test-vm-bundle.sh
+ grep -qx "ripgrep" vm/runtime-packages &&
+ grep -q "package_digest" vm/build-bundle.sh
'
test_expect_success 'named VM console and SSH access helpers are wired up' '
grep -q "^vm-console:" ../testing/Makefile &&
grep -q "^vm-ssh:" ../testing/Makefile &&
- grep -q "contrib/test-vm.sh --console" ../testing/Makefile &&
- grep -q "contrib/test-vm.sh --ssh" ../testing/Makefile &&
- grep -q "VM_SSH_COMMAND" ../contrib/test-vm.sh &&
- grep -q "TEST_VM_SSH_PORT" ../contrib/test-vm.sh &&
- grep -q "hostfwd=tcp:127.0.0.1" ../contrib/test-vm.sh &&
- grep -q "socket,id=console" ../contrib/test-vm.sh &&
- grep -q "logfile=.*console.log" ../contrib/test-vm.sh &&
- grep -q "TEST_VM_SSH_PUBLIC_KEY" ../contrib/test-vm.sh &&
- grep -q "serial-getty@\${TEST_VM_ARCH_CONSOLE}.service" ../contrib/test-vm-guest.sh &&
- grep -q "TEST_VM_SSH_PUBLIC_KEY" ../contrib/test-vm-guest.sh
+ grep -q "testing/vm/run.sh --console" ../testing/Makefile &&
+ grep -q "testing/vm/run.sh --ssh" ../testing/Makefile &&
+ grep -q "VM_SSH_COMMAND" vm/run.sh &&
+ grep -q "TEST_VM_SSH_PORT" vm/run.sh &&
+ grep -q "hostfwd=tcp:127.0.0.1" vm/run.sh &&
+ grep -q "socket,id=console" vm/run.sh &&
+ grep -q "logfile=.*console.log" vm/run.sh &&
+ grep -q "TEST_VM_SSH_PUBLIC_KEY" vm/run.sh &&
+ grep -q "serial-getty@\${TEST_VM_ARCH_CONSOLE}.service" vm/guest.sh &&
+ grep -q "TEST_VM_SSH_PUBLIC_KEY" vm/guest.sh
'
test_expect_success 'VM console requires a named VM and SSH reports empty state' '
@@ -650,38 +648,38 @@ test_expect_success 'explicit VM_NAME overrides unnamed vm-ssh selection' '
test_expect_success 'VM bundle installs target units and interactive mode activates timers' '
grep -q "DESTDIR=\"\$TMP_DIR/root\" install-target" \
- ../contrib/build-test-vm-bundle.sh &&
+ vm/build-bundle.sh &&
grep -q "systemd/\\*.timer" ../testing/Makefile &&
- grep -q "shirudo-map-export.timer" ../contrib/test-vm-guest.sh &&
- grep -q "shirudo-keepalive.timer" ../contrib/test-vm-guest.sh &&
- grep -q "shirudo-bpm-repo-update.service" ../contrib/test-vm-guest.sh &&
- grep -q "shirudo-bpm-repo-update.timer" ../contrib/test-vm-guest.sh &&
- grep -q "shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh &&
- grep -q "shirudo-bpm-tree-sync.timer" ../contrib/test-vm-guest.sh &&
+ grep -q "shirudo-map-export.timer" vm/guest.sh &&
+ grep -q "shirudo-keepalive.timer" vm/guest.sh &&
+ grep -q "shirudo-bpm-repo-update.service" vm/guest.sh &&
+ grep -q "shirudo-bpm-repo-update.timer" vm/guest.sh &&
+ grep -q "shirudo-bpm-tree-sync.service" vm/guest.sh &&
+ grep -q "shirudo-bpm-tree-sync.timer" vm/guest.sh &&
grep -q "OnUnitActiveSec=60s" ../systemd/shirudo-bpm-tree-sync.timer &&
grep -q "Persistent=true" ../systemd/shirudo-bpm-tree-sync.timer &&
- grep -q "systemctl enable shirudo.service" ../contrib/test-vm-guest.sh &&
+ grep -q "systemctl enable shirudo.service" vm/guest.sh &&
grep -q "systemctl enable --now shirudo-map-export.timer" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -q "systemctl enable --now shirudo-keepalive.timer" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -q "systemctl enable --now shirudo-bpm-repo-update.timer" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -q "systemctl enable --now shirudo-bpm-tree-sync.timer" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -Fq "if [[ \"\$VM_MODE\" == interactive ]]" \
- ../contrib/test-vm-guest.sh
+ vm/guest.sh
'
test_expect_success 'VM stop and cleanup use the VM runner paths' '
grep -q "^vm-stop:" ../testing/Makefile &&
- grep -q "contrib/test-vm.sh --stop" ../testing/Makefile &&
+ grep -q "testing/vm/run.sh --stop" ../testing/Makefile &&
grep -q "^vm-clean:" ../testing/Makefile &&
- grep -q "contrib/test-vm.sh --clean" ../testing/Makefile &&
+ grep -q "testing/vm/run.sh --clean" ../testing/Makefile &&
grep -q "^test-vm-clean: vm-clean" ../testing/Makefile &&
grep -q "VM_NAME=\"\$(VM_NAME)\"" ../testing/Makefile &&
- grep -q "stop_pid_file" ../contrib/test-vm.sh &&
- grep -q "removed VM state and logs" ../contrib/test-vm.sh
+ grep -q "stop_pid_file" vm/run.sh &&
+ grep -q "removed VM state and logs" vm/run.sh
'
test_expect_success 'named vm-stop preserves the selected VM state' '
@@ -734,12 +732,12 @@ test_expect_success 'test-vm supports secure and explicit insecure map-export mo
grep -q "export TEST_VM_MAP_EXPORT_ENDPOINT" "$RUNNER" &&
grep -q "export TEST_VM_MAP_EXPORT_CA=/mnt/shirudo-otel/ca.pem" "$RUNNER" &&
grep -q "mount_tag=shirudo-otel" "$RUNNER" &&
- grep -q "10.0.2.2 otel.test" ../contrib/test-vm-guest.sh &&
- grep -q "map_export.otel_endpoint = \$endpoint" ../contrib/test-vm-guest.sh &&
- grep -q "map_export.otel_insecure = \$insecure" ../contrib/test-vm-guest.sh &&
+ grep -q "10.0.2.2 otel.test" vm/guest.sh &&
+ grep -q "map_export.otel_endpoint = \$endpoint" vm/guest.sh &&
+ grep -q "map_export.otel_insecure = \$insecure" vm/guest.sh &&
grep -q "OTEL_EXPORTER_OTLP_CERTIFICATE=/etc/shirudo/otel/ca.pem" \
- ../contrib/test-vm-guest.sh &&
- grep -q "map_export.tenant_id = \$tenant_id" ../contrib/test-vm-guest.sh
+ vm/guest.sh &&
+ grep -q "map_export.tenant_id = \$tenant_id" vm/guest.sh
'
test_expect_success 'test-vm rejects incomplete map-export bridge settings' '
@@ -788,8 +786,8 @@ test_expect_success 'test-vm passes an OCI CA into the guest trust store' '
grep -q "OCI_CA=\"\${TEST_VM_OCI_CA:-}\"" "$RUNNER" &&
grep -q "shirudo-oci" "$RUNNER" &&
grep -q "export TEST_VM_OCI_CA=/mnt/shirudo-oci/ca.crt" "$RUNNER" &&
- grep -q "shirudo-oci-ca.crt" ../contrib/test-vm-guest.sh &&
- grep -q "update-ca-certificates" ../contrib/test-vm-guest.sh
+ grep -q "shirudo-oci-ca.crt" vm/guest.sh &&
+ grep -q "update-ca-certificates" vm/guest.sh
'
test_expect_success 'test-vm validates a custom OCI CA file before boot' '
@@ -812,17 +810,17 @@ test_expect_success 'test-vm hands off an interactive BPM tree configuration' '
grep -q "export TEST_VM_BPM_TREE_INPUT=/mnt/shirudo-bpm-tree" "$RUNNER" &&
grep -q "mount.*shirudo-bpm-tree /mnt/shirudo-bpm-tree" "$RUNNER" &&
grep -q "credentials and private signing" "$RUNNER" &&
- grep -q "configure_bpm_tree" ../contrib/test-vm-guest.sh &&
- grep -Fq "[[ -z \"\$tree_input\" ]] && return 0" ../contrib/test-vm-guest.sh &&
- grep -q "local config_file=\"\${tree_input}/upatch-tree.conf\"" ../contrib/test-vm-guest.sh &&
- grep -q "temporary=\"\${target}.tmp.\$\$\"" ../contrib/test-vm-guest.sh &&
- grep -q "mv -f \"\$temporary\" \"\$target\"" ../contrib/test-vm-guest.sh &&
- grep -q "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh &&
- grep -q "systemctl enable --now shirudo-bpm-tree-sync.timer" ../contrib/test-vm-guest.sh &&
- test "$(grep -n "SHIRUDO_BIN.* init" ../contrib/test-vm-guest.sh | cut -d: -f1)" -lt \
- "$(grep -n "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh | cut -d: -f1)" &&
- test "$(grep -n "systemctl start shirudo-bpm-tree-sync.service" ../contrib/test-vm-guest.sh | cut -d: -f1)" -lt \
- "$(grep -n "systemctl enable --now shirudo-bpm-tree-sync.timer" ../contrib/test-vm-guest.sh | cut -d: -f1)"
+ grep -q "configure_bpm_tree" vm/guest.sh &&
+ grep -Fq "[[ -z \"\$tree_input\" ]] && return 0" vm/guest.sh &&
+ grep -q "local config_file=\"\${tree_input}/upatch-tree.conf\"" vm/guest.sh &&
+ grep -q "temporary=\"\${target}.tmp.\$\$\"" vm/guest.sh &&
+ grep -q "mv -f \"\$temporary\" \"\$target\"" vm/guest.sh &&
+ grep -q "systemctl start shirudo-bpm-tree-sync.service" vm/guest.sh &&
+ grep -q "systemctl enable --now shirudo-bpm-tree-sync.timer" vm/guest.sh &&
+ test "$(grep -n "SHIRUDO_BIN.* init" vm/guest.sh | cut -d: -f1)" -lt \
+ "$(grep -n "systemctl start shirudo-bpm-tree-sync.service" vm/guest.sh | cut -d: -f1)" &&
+ test "$(grep -n "systemctl start shirudo-bpm-tree-sync.service" vm/guest.sh | cut -d: -f1)" -lt \
+ "$(grep -n "systemctl enable --now shirudo-bpm-tree-sync.timer" vm/guest.sh | cut -d: -f1)"
'
test_expect_success 'test-vm validates BPM tree configuration mode and contents' '
@@ -871,11 +869,11 @@ test_expect_success 'test-vm bootstraps a BPM OCI repository from the host' '
grep -q "keys/\${BPM_OCI_SOURCE}.pem" "$RUNNER" &&
grep -q "repository.env" "$RUNNER" &&
grep -q "mount_tag=shirudo-bpm-oci" "$RUNNER" &&
- grep -q "registry\.test" ../contrib/test-vm-guest.sh &&
+ grep -q "registry\.test" vm/guest.sh &&
grep -q "install -m 0644.*staged_conf.*conf_file" \
- ../contrib/test-vm-guest.sh &&
+ vm/guest.sh &&
grep -q "install -m 0644.*staged_env.*repository_env" \
- ../contrib/test-vm-guest.sh
+ vm/guest.sh
'
test_expect_success 'test-vm validates BPM OCI repository handoff as a pair' '
diff --git a/testing/t0040-kernel-ami-config.sh b/testing/t0040-kernel-ami-config.sh
index 78e87f7b..f1d638eb 100644
--- a/testing/t0040-kernel-ami-config.sh
+++ b/testing/t0040-kernel-ami-config.sh
@@ -5,7 +5,7 @@
cd "$(dirname "$0")"
. ./test-lib.sh
-BUILDER=../contrib/build-kernel-package.sh
+BUILDER=vm/build-kernel.sh
check_builtin_options() {
for symbol in "$@"; do
diff --git a/contrib/test-vm-arch.sh b/testing/vm/arch.sh
similarity index 97%
rename from contrib/test-vm-arch.sh
rename to testing/vm/arch.sh
index c5b89cdc..56edc95d 100644
--- a/contrib/test-vm-arch.sh
+++ b/testing/vm/arch.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2026 Authors of shirudo
#
# Host architecture and package manager for the test VM tooling. Sourced
-# by the contrib scripts and evaluated by testing/Makefile, so POSIX sh.
+# by the test VM scripts and evaluated by testing/Makefile, so POSIX sh.
# TEST_VM_ARCH and TEST_VM_HOST_PKG override the detection. An
# architecture other than x86-64 and arm64 gets the x86-64 names, so that
# host-side targets still evaluate, and TEST_VM_ARCH_SUPPORTED=0, which
diff --git a/contrib/build-test-vm-bundle.sh b/testing/vm/build-bundle.sh
similarity index 98%
rename from contrib/build-test-vm-bundle.sh
rename to testing/vm/build-bundle.sh
index c7b290b1..3aeda861 100755
--- a/contrib/build-test-vm-bundle.sh
+++ b/testing/vm/build-bundle.sh
@@ -2,20 +2,20 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
#
-# Build the host-side payload imported by contrib/test-vm.sh. The bundle is
+# Build the host-side payload imported by testing/vm/run.sh. The bundle is
# shared by all VMs, while TPM state and the test workspace remain per-VM.
set -euo pipefail
-REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-# shellcheck source=contrib/test-vm-arch.sh
-. "${REPO_ROOT}/contrib/test-vm-arch.sh"
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+# shellcheck source=testing/vm/arch.sh
+. "${REPO_ROOT}/testing/vm/arch.sh"
BUNDLE_DIR="${TEST_VM_HOST_BUNDLE:-${REPO_ROOT}/build/test-vm/host-bundle}"
WORK_DIR="${TEST_VM_WORK_DIR:-${REPO_ROOT}/build/test-vm}"
RUNTIME_CACHE_DIR="${TEST_VM_RUNTIME_CACHE_DIR:-${WORK_DIR}/cache/runtime}"
LIBGUESTFS_KERNEL_CACHE="${WORK_DIR}/cache/libguestfs/ubuntu"
UBUNTU_CODENAME="${TEST_VM_UBUNTU_CODENAME:-resolute}"
-PACKAGE_FILE="$REPO_ROOT/contrib/test-vm-runtime-packages"
+PACKAGE_FILE="$REPO_ROOT/testing/vm/runtime-packages"
DEFAULT_ROOTFS_URL="https://cloud-images.ubuntu.com/releases/server/26.04/release/ubuntu-26.04-server-cloudimg-${TEST_VM_ARCH_DEB}.img"
ROOTFS_URL="${TEST_VM_ROOTFS_URL:-$DEFAULT_ROOTFS_URL}"
ROOTFS_SHA256="${TEST_VM_ROOTFS_SHA256:-}"
@@ -252,7 +252,7 @@ prepare_runtime_image()
RUNTIME_KEY="rootfs-${ROOTFS_DIGEST}-packages-${package_digest}-disk-${disk_size_key}-v${RUNTIME_PREP_VERSION}"
RUNTIME_IMAGE="$RUNTIME_CACHE_DIR/$RUNTIME_KEY.qcow2"
if [[ ! -s "$RUNTIME_IMAGE" ]]; then
- "$REPO_ROOT/contrib/prepare-test-vm-runtime.sh" \
+ "$REPO_ROOT/testing/vm/prepare-runtime.sh" \
--rootfs "$ROOTFS_CACHE" \
--cache-dir "$RUNTIME_CACHE_DIR" \
--package-file "$PACKAGE_FILE" \
@@ -767,7 +767,7 @@ fi
third.vouch package-cert.der > manifest
)
-"$REPO_ROOT/contrib/verity-vm-bundle.sh" "$TMP_DIR" "$FIXTURE_WORK" \
+"$REPO_ROOT/testing/vm/bundle-images.sh" "$TMP_DIR" "$FIXTURE_WORK" \
"$FIXTURE_WORK/trusted" "$FIXTURE_WORK/own"
printf '%s\n' "$TEST_VM_MODE" >"$TMP_DIR/test-mode"
diff --git a/contrib/build-kernel-package.sh b/testing/vm/build-kernel.sh
similarity index 99%
rename from contrib/build-kernel-package.sh
rename to testing/vm/build-kernel.sh
index a425d24d..986434d5 100755
--- a/contrib/build-kernel-package.sh
+++ b/testing/vm/build-kernel.sh
@@ -9,9 +9,9 @@ KERNEL_REPOSITORY="${KERNEL_REPOSITORY:-https://git.kernel.org/pub/scm/linux/ker
KERNEL_PATCHES="${KERNEL_PATCHES:-}"
KERNEL_CONFIG="${KERNEL_CONFIG:-}"
KERNEL_BUILD_JOBS="${KERNEL_BUILD_JOBS:-$(nproc)}"
-REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-# shellcheck source=contrib/test-vm-arch.sh
-. "${REPO_ROOT}/contrib/test-vm-arch.sh"
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+# shellcheck source=testing/vm/arch.sh
+. "${REPO_ROOT}/testing/vm/arch.sh"
KERNEL_SOURCE_DIR_INPUT="${KERNEL_SOURCE_DIR:-}"
if [[ "$KERNEL_TAG" =~ ^[0-9]+\.[0-9]+([.][0-9]+)?$ ]]; then
KERNEL_TAG="v${KERNEL_TAG}"
diff --git a/contrib/verity-vm-bundle.sh b/testing/vm/bundle-images.sh
similarity index 90%
rename from contrib/verity-vm-bundle.sh
rename to testing/vm/bundle-images.sh
index a7ecaa0b..39f0b710 100755
--- a/contrib/verity-vm-bundle.sh
+++ b/testing/vm/bundle-images.sh
@@ -3,14 +3,14 @@
# Copyright (c) 2026 Authors of shirudo
set -euo pipefail
-source_dir=$(cd "$(dirname "$0")/.." && pwd)
-templates="$source_dir/contrib/verity-vm"
+source_dir=$(cd "$(dirname "$0")/../.." && pwd)
+templates="$source_dir/testing/vm/files"
[ "$#" -eq 4 ] || exit 2
bundle=$1
work=$2
keys=$3
boot_keys=$4
-"$source_dir/contrib/verity-vm-config-fixtures.sh" --keys-dir "$keys" \
+"$source_dir/testing/vm/image-fixtures.sh" --keys-dir "$keys" \
--boot-keys-dir "$boot_keys" --output "$work/verity"
mkdir "$bundle/verity"
cp -a "$work/verity/public/." "$bundle/verity/"
diff --git a/contrib/verity-vm/bootstrap.conf.in b/testing/vm/files/bootstrap.conf.in
similarity index 100%
rename from contrib/verity-vm/bootstrap.conf.in
rename to testing/vm/files/bootstrap.conf.in
diff --git a/contrib/verity-vm/config.conf.in b/testing/vm/files/config.conf.in
similarity index 100%
rename from contrib/verity-vm/config.conf.in
rename to testing/vm/files/config.conf.in
diff --git a/contrib/verity-vm/jsonl-bad.conf b/testing/vm/files/jsonl-bad.conf
similarity index 100%
rename from contrib/verity-vm/jsonl-bad.conf
rename to testing/vm/files/jsonl-bad.conf
diff --git a/contrib/verity-vm/jsonl.conf b/testing/vm/files/jsonl.conf
similarity index 100%
rename from contrib/verity-vm/jsonl.conf
rename to testing/vm/files/jsonl.conf
diff --git a/contrib/verity-vm/node.labels b/testing/vm/files/node.labels
similarity index 100%
rename from contrib/verity-vm/node.labels
rename to testing/vm/files/node.labels
diff --git a/contrib/verity-vm/otel.conf b/testing/vm/files/otel.conf
similarity index 100%
rename from contrib/verity-vm/otel.conf
rename to testing/vm/files/otel.conf
diff --git a/contrib/verity-vm/runtime.conf.in b/testing/vm/files/runtime.conf.in
similarity index 100%
rename from contrib/verity-vm/runtime.conf.in
rename to testing/vm/files/runtime.conf.in
diff --git a/contrib/verity-vm/seed-images.sh b/testing/vm/files/seed-images.sh
similarity index 100%
rename from contrib/verity-vm/seed-images.sh
rename to testing/vm/files/seed-images.sh
diff --git a/contrib/verity-vm/seed-root.sh b/testing/vm/files/seed-root.sh
similarity index 100%
rename from contrib/verity-vm/seed-root.sh
rename to testing/vm/files/seed-root.sh
diff --git a/contrib/verity-vm/shirudo-runtime.in b/testing/vm/files/shirudo-runtime.in
similarity index 100%
rename from contrib/verity-vm/shirudo-runtime.in
rename to testing/vm/files/shirudo-runtime.in
diff --git a/contrib/verity-vm/shirudo-test-seed-images.conf b/testing/vm/files/shirudo-test-seed-images.conf
similarity index 100%
rename from contrib/verity-vm/shirudo-test-seed-images.conf
rename to testing/vm/files/shirudo-test-seed-images.conf
diff --git a/contrib/verity-vm/shirudo-test-seed.service b/testing/vm/files/shirudo-test-seed.service
similarity index 100%
rename from contrib/verity-vm/shirudo-test-seed.service
rename to testing/vm/files/shirudo-test-seed.service
diff --git a/contrib/verity-vm/upatch-tree.conf.in b/testing/vm/files/upatch-tree.conf.in
similarity index 100%
rename from contrib/verity-vm/upatch-tree.conf.in
rename to testing/vm/files/upatch-tree.conf.in
diff --git a/contrib/test-vm-guest.sh b/testing/vm/guest.sh
similarity index 99%
rename from contrib/test-vm-guest.sh
rename to testing/vm/guest.sh
index 67019cc1..3ebcd419 100755
--- a/contrib/test-vm-guest.sh
+++ b/testing/vm/guest.sh
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
#
-# Guest-side half of contrib/test-vm.sh. The host checkout is mounted
+# Guest-side half of testing/vm/run.sh. The host checkout is mounted
# read-only at /mnt/shirudo-src; all build writes stay in this VM.
set -euo pipefail
@@ -12,8 +12,8 @@ export HOME=/root
export LOGNAME=root
export USER=root
LOWER=/mnt/shirudo-src
-# shellcheck source=contrib/test-vm-arch.sh
-. "$LOWER/contrib/test-vm-arch.sh"
+# shellcheck source=testing/vm/arch.sh
+. "$LOWER/testing/vm/arch.sh"
BUNDLE=/mnt/shirudo-bundle
UPPER=/var/tmp/shirudo-upper
OVERLAY_WORK=/var/tmp/shirudo-overlay-work
diff --git a/contrib/verity-vm-config-fixtures.sh b/testing/vm/image-fixtures.sh
similarity index 98%
rename from contrib/verity-vm-config-fixtures.sh
rename to testing/vm/image-fixtures.sh
index 1388f251..c7f35942 100755
--- a/contrib/verity-vm-config-fixtures.sh
+++ b/testing/vm/image-fixtures.sh
@@ -5,8 +5,8 @@
set -euo pipefail
umask 077
-source_dir=$(cd "$(dirname "$0")/.." && pwd)
-templates="$source_dir/contrib/verity-vm"
+source_dir=$(cd "$(dirname "$0")/../.." && pwd)
+templates="$source_dir/testing/vm/files"
keys_dir=
boot_keys_dir=
output=
diff --git a/contrib/prepare-test-vm-runtime.sh b/testing/vm/prepare-runtime.sh
similarity index 98%
rename from contrib/prepare-test-vm-runtime.sh
rename to testing/vm/prepare-runtime.sh
index 1945f16f..6185e5de 100755
--- a/contrib/prepare-test-vm-runtime.sh
+++ b/testing/vm/prepare-runtime.sh
@@ -6,8 +6,8 @@
set -euo pipefail
-# shellcheck source=contrib/test-vm-arch.sh
-. "$(dirname "${BASH_SOURCE[0]}")/test-vm-arch.sh"
+# shellcheck source=testing/vm/arch.sh
+. "$(dirname "${BASH_SOURCE[0]}")/arch.sh"
ROOTFS=
CACHE_DIR=
diff --git a/contrib/test-vm.sh b/testing/vm/run.sh
similarity index 99%
rename from contrib/test-vm.sh
rename to testing/vm/run.sh
index 5d150144..d4648036 100755
--- a/contrib/test-vm.sh
+++ b/testing/vm/run.sh
@@ -32,9 +32,9 @@ else
COLOR_RESET=""
fi
-REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-# shellcheck source=contrib/test-vm-arch.sh
-. "${REPO_ROOT}/contrib/test-vm-arch.sh"
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+# shellcheck source=testing/vm/arch.sh
+. "${REPO_ROOT}/testing/vm/arch.sh"
# TEST_VM_QEMU names another emulator, such as RHEL's /usr/libexec/qemu-kvm.
QEMU_BIN="${TEST_VM_QEMU:-$TEST_VM_ARCH_QEMU}"
VM_ROOT_INPUT="${TEST_VM_WORK_DIR:-${REPO_ROOT}/build/test-vm}"
@@ -986,9 +986,9 @@ build_initrd()
"$REPO_ROOT/systemd/shirudo-initrd.service.in" >"$unit"
seed="$RUN_DIR/initrd-seed"
mkdir -p "$seed/usr/lib/systemd/system/initrd.target.wants"
- cp "$REPO_ROOT/contrib/verity-vm/shirudo-test-seed.service" \
+ cp "$REPO_ROOT/testing/vm/files/shirudo-test-seed.service" \
"$seed/usr/lib/systemd/system/shirudo-test-seed.service"
- cp "$REPO_ROOT/contrib/verity-vm/seed-root.sh" \
+ cp "$REPO_ROOT/testing/vm/files/seed-root.sh" \
"$seed/shirudo-test-seed-root.sh"
ln -sf ../shirudo-test-seed.service \
"$seed/usr/lib/systemd/system/initrd.target.wants/shirudo-test-seed.service"
@@ -1010,9 +1010,9 @@ build_initrd()
"$seed/shirudo-test-images/"
cp "$TEST_VM_HOST_BUNDLE/verity/bootstrap.conf" \
"$seed/shirudo-test-images/bootstrap.conf"
- cp "$REPO_ROOT/contrib/verity-vm/seed-images.sh" \
+ cp "$REPO_ROOT/testing/vm/files/seed-images.sh" \
"$seed/shirudo-test-seed-images.sh"
- cat "$REPO_ROOT/contrib/verity-vm/shirudo-test-seed-images.conf" \
+ cat "$REPO_ROOT/testing/vm/files/shirudo-test-seed-images.conf" \
>>"$seed/usr/lib/systemd/system/shirudo-test-seed.service"
cert="$RUN_DIR/cert.der"
cp "$TEST_VM_HOST_BUNDLE/fixtures/cert.der" "$cert"
@@ -1449,7 +1449,7 @@ EOF
cat >>"$USER_DATA" <<'EOF'
mount -t 9p -o trans=virtio,version=9p2000.L,msize=104857600,ro shirudo-src /mnt/shirudo-src || rc=$?
if [ "$rc" -eq 0 ]; then
- bash /mnt/shirudo-src/contrib/test-vm-guest.sh || rc=$?
+ bash /mnt/shirudo-src/testing/vm/guest.sh || rc=$?
fi
printf '%s\n' "$rc" >/mnt/shirudo-out/status
sync
diff --git a/contrib/test-vm-runtime-packages b/testing/vm/runtime-packages
similarity index 100%
rename from contrib/test-vm-runtime-packages
rename to testing/vm/runtime-packages
diff --git a/contrib/bpf-deps.sh b/tools/bpf-deps/bpf-deps.sh
similarity index 93%
rename from contrib/bpf-deps.sh
rename to tools/bpf-deps/bpf-deps.sh
index 2a0acecd..3d79335b 100755
--- a/contrib/bpf-deps.sh
+++ b/tools/bpf-deps/bpf-deps.sh
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
#
-# contrib/bpf-deps.sh [KERNEL_SRC] -- refresh vendor/libbpf from a
+# tools/bpf-deps/bpf-deps.sh [KERNEL_SRC] -- refresh vendor/libbpf from a
# kernel tree. Without an argument (or KERNEL_SRC in the environment) a
# shallow clone of bpf-next is used. Overwrites the copied sources and UAPI
# headers, regenerates bpf_helper_defs.h, records the commit in COMMIT and
@@ -10,7 +10,7 @@
set -eu
-REPO_ROOT=$(CDPATH= cd "$(dirname "$0")/.." && pwd)
+REPO_ROOT=$(CDPATH= cd "$(dirname "$0")/../.." && pwd)
VENDOR="$REPO_ROOT/vendor/libbpf"
REPOSITORY="${BPF_NEXT_REPOSITORY:-git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git}"
KERNEL_SRC="${1:-${KERNEL_SRC:-}}"
@@ -72,7 +72,7 @@ python3 "$KERNEL_SRC/scripts/bpf_doc.py" --header \
commit=$(git -C "$KERNEL_SRC" rev-parse HEAD 2>/dev/null || echo unknown)
describe=$(git -C "$KERNEL_SRC" describe --always --tags 2>/dev/null || echo unknown)
{
- printf '# Written by contrib/bpf-deps.sh; do not edit.\n'
+ printf '# Written by tools/bpf-deps/bpf-deps.sh; do not edit.\n'
printf 'source=%s\n' "$source_desc"
printf 'commit=%s\n' "$commit"
printf 'describe=%s\n' "$describe"
diff --git a/vendor/libbpf/COMMIT b/vendor/libbpf/COMMIT
index 39e74abb..0e63ec8c 100644
--- a/vendor/libbpf/COMMIT
+++ b/vendor/libbpf/COMMIT
@@ -1,4 +1,4 @@
-# Written by contrib/bpf-deps.sh; do not edit.
+# Written by tools/bpf-deps/bpf-deps.sh; do not edit.
source=/home/darkstar/net
commit=f5bffe9f098fbf1b60e0242c7b96e06d1e4256d5
describe=v6.11-rc6-188859-gf5bffe9f098f
diff --git a/vendor/libbpf/Makefile b/vendor/libbpf/Makefile
index 13dfca31..59ad2ddc 100644
--- a/vendor/libbpf/Makefile
+++ b/vendor/libbpf/Makefile
@@ -3,7 +3,7 @@
#
# Build the vendored libbpf as a static archive. The sources under bpf/
# and include/uapi/ are copied verbatim from a kernel tree by
-# contrib/bpf-deps.sh; include/linux and include/asm are small
+# tools/bpf-deps/bpf-deps.sh; include/linux and include/asm are small
# shirudo-owned shims standing in for the kernel's tools/include.
CC ?= cc