1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00
Files
Colin Walters d4c19f7d31 tests: Add a suite which runs tests under systemd
And add a single test which verifies that our internal `reboot`
code actually does what it should (via systemd-run etc.)

This took me way, way too long to do...there were so many missteps
and confusion. First of all, I kept trying to use `systemd.extra-unit`
from https://www.freedesktop.org/software/systemd/man/latest/systemd-debug-generator.html#
but that doesn't exist in stream9.

I spent way too long trying to debug the fact that switching from
`podman run <image> /sbin/init` to `podman run <image> /bin/sh -c '<stuff> && exec /sbin/init`
fails because in the latter case podman's auto-detection fails and
we need to explicitly say `--systemd=always`. In retrospect obvious...but oh well.

On the positive side, I think with some cleanup we could extend this model
and generalize it for "test running in a container with systemd" (with
a lot of cleanup really)

Signed-off-by: Colin Walters <walters@verbum.org>
2025-07-18 07:42:05 -04:00

23 lines
727 B
Bash
Executable File

#!/bin/bash
# Verify that invoking `bootc internals reboot` actually invokes a reboot, when
# running inside systemd.
# xref:
# - https://github.com/bootc-dev/bootc/issues/1416
# - https://github.com/bootc-dev/bootc/issues/1419
set -euo pipefail
image=$1
tmpd=$(mktemp -d)
log() {
echo "$@"
"$@"
}
log timeout 120 podman run --rm --systemd=always --privileged -v /sys:/sys:ro --label bootc.test=reboot --net=none -v $(pwd):/src:ro -v $tmpd:/run/bootc-test-reboot $image /bin/sh -c 'cp /src/*.service /etc/systemd/system && systemctl enable bootc-test-reboot && exec /sbin/init' || true
ls -al $tmpd
if test '!' -f $tmpd/success; then
echo "reboot failed" 1>&2
rm -rf "$tmpd"
exit 1
fi
rm -rf "$tmpd"
echo "ok reboot"