Merge pull request #30464 from CodethinkLabs/misc-integration-test-fixes

Misc integration test fixes
This commit is contained in:
Luca Boccassi 2023-12-18 16:11:16 +01:00 committed by GitHub
commit c2d5d8c401
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 4 deletions

View file

@ -4,7 +4,7 @@
Images=system
[Output]
OutputDirectory=mkosi.output
@OutputDirectory=mkosi.output
BuildDirectory=mkosi.builddir
CacheDirectory=mkosi.cache

View file

@ -44,7 +44,7 @@ EOF
fi
if [ ! -f "$BUILDDIR"/build.ninja ]; then
sysvinit_path=$(realpath /etc/init.d)
[[ -d /etc/rc.d/init.d ]] && sysvinit_path="/etc/rc.d/init.d" || sysvinit_path="/etc/init.d"
if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then
UKIFY="disabled"

View file

@ -33,6 +33,7 @@ Packages=
strace
systemd
tmux
tar
tree
udev
util-linux

View file

@ -8,4 +8,5 @@ Packages=
btrfs-progs
compsize
f2fs-tools
glibc-langpack-en
kernel-core

View file

@ -83,3 +83,12 @@ if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then
alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
alternatives --set python3 /usr/bin/python3.9
fi
mkdir -p /usr/lib/sysusers.d
cat >/usr/lib/sysusers.d/testuser.conf <<EOF
u testuser 4711 "Test User" /home/testuser
EOF
mkdir -p /usr/lib/tmpfiles.d
cat >/usr/lib/tmpfiles.d/testuser.conf <<EOF
q /home/testuser 0700 4711 4711
EOF

View file

@ -5,6 +5,11 @@ set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
maybe_mount_usr_overlay
trap 'maybe_umount_usr_overlay' EXIT
clear_unit() {
local unit_name="${1:?}"

View file

@ -12,10 +12,13 @@ at_exit() {
rm -fvr "/usr/lib/systemd/system/$UNIT_NAME" "/etc/systemd/system/$UNIT_NAME.d" "+4"
fi
maybe_umount_usr_overlay
rm -f /etc/init.d/issue-24990
return 0
}
maybe_mount_usr_overlay
trap at_exit EXIT
# Create a simple unit file for testing

View file

@ -3,7 +3,7 @@
set -eux
set -o pipefail
if journalctl -b -t systemd --grep '\.device: Changed plugged -> dead'; then
if journalctl -b -t systemd --grep '(?<!loop.|diskseq-.)\.device: Changed plugged -> dead'; then
exit 1
fi

View file

@ -6,6 +6,9 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
maybe_mount_usr_overlay
trap 'maybe_umount_usr_overlay' EXIT
teardown_test_dependencies() (
set +eux

View file

@ -179,7 +179,7 @@ systemd-analyze security --json=short | jq
if [[ ! -v ASAN_OPTIONS ]]; then
# check that systemd-analyze cat-config paths work in a chroot
mkdir -p /tmp/root
mount --bind / /tmp/root
mount --rbind / /tmp/root
systemd-analyze cat-config systemd/system-preset >/tmp/out1
chroot /tmp/root systemd-analyze cat-config systemd/system-preset >/tmp/out2
diff /tmp/out{1,2}

View file

@ -9,6 +9,9 @@ set -o pipefail
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
maybe_mount_usr_overlay
trap 'maybe_umount_usr_overlay' EXIT
enable_debug() {
mkdir -p /run/systemd/system/systemd-localed.service.d
cat >>/run/systemd/system/systemd-localed.service.d/override.conf <<EOF

View file

@ -216,3 +216,19 @@ kernel_supports_lsm() {
return 1
}
MOUNTED_USR_OVERLAY=false
maybe_mount_usr_overlay() {
if [[ ! -w /usr ]]; then
mkdir -p /tmp/usr-overlay/{upperdir,workdir}
mount -t overlay -o lowerdir=/usr,upperdir=/tmp/usr-overlay/upperdir,workdir=/tmp/usr-overlay/workdir overlay /usr
MOUNTED_USR_OVERLAY=true
fi
}
maybe_umount_usr_overlay() {
if "$MOUNTED_USR_OVERLAY"; then
umount -l /usr
fi
}