1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 00:13:24 +02:00

test: add test for systemd upgrade

Add a basic test to check that systemd works after an upgrade
This commit is contained in:
Matteo Croce
2025-04-14 16:32:47 +02:00
committed by Daan De Meyer
parent 43aacae83a
commit 030b227cec
6 changed files with 141 additions and 1 deletions

View File

@@ -51,6 +51,8 @@ Packages=
polkit
procps-ng
python3-pexpect
# needed to upgrade and downgrade systemd-ukify in tests
python3-zstd
quota
rpm
softhsm

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
if [[ "$1" == "build" ]]; then
exit 0
fi
pkgdir=/usr/host-pkgs
distrover=$(dnf repoquery --disablerepo mkosi --latest-limit=1 --queryformat='%{evr}' systemd)
develver=$(rpm -q --queryformat='%{evr}' systemd)
distromajor=$(dnf repoquery --disablerepo mkosi --latest-limit=1 --queryformat='%{version}' systemd)
develmajor=$(rpm -q --queryformat='%{v}' systemd)
distromajor=$(grep -o '^[0-9]\+' <<<"$distromajor")
develmajor=$(grep -o '^[0-9]\+' <<<"$develmajor")
deltaver=$((develmajor - distromajor))
if [[ $deltaver -gt 2 ]]; then
echo "Skipping upgrade test, distro version is too old: $distrover"
exit 0
elif [[ $deltaver -le 0 ]]; then
echo "Skipping upgrade test, distro version is newer or equal: $distrover"
exit 0
fi
# Filter only noarch and arch packages otherwise on CentOS 9 we could end having i686 packages too
distropkgs=$(dnf repoquery 'systemd*' | grep -F "$distrover" | grep -e noarch -e "$DISTRIBUTION_ARCHITECTURE" | grep -v -e -debuginfo -e -debugsource -e standalone)
develpkgs=$(dnf repoquery 'systemd*' | grep -F "$develver" | grep -e noarch -e "$DISTRIBUTION_ARCHITECTURE" | grep -v -e -debuginfo -e -debugsource -e standalone)
# shellcheck disable=SC2086
dnf download --arch noarch --arch "$DISTRIBUTION_ARCHITECTURE" --destdir "$BUILDROOT$pkgdir/distro" $distropkgs
# shellcheck disable=SC2086
dnf download --arch noarch --arch "$DISTRIBUTION_ARCHITECTURE" --destdir "$BUILDROOT$pkgdir/devel" $develpkgs

View File

@@ -10,7 +10,16 @@ if [[ ! -f "$BUILDROOT/$LIBSYSTEMD" ]]; then
fi
# ASAN and syscall filters aren't compatible with each other.
find "$BUILDROOT"/usr "$BUILDROOT"/etc -name '*.service' -type f -exec sed -i 's/^\(MemoryDeny\|SystemCall\)/# \1/' {} +
find "$BUILDROOT"/usr "$BUILDROOT"/etc -name '*.service' -type f | while read -r unit; do
if grep -q -e MemoryDeny -e SystemCall "$unit" ; then
mkdir -p "$unit.d"
cat > "$unit.d/sanitizer-compat.conf" <<EOF
[Service]
MemoryDenyWriteExecute=no
SystemCallFilter=
EOF
fi
done
# 'systemd-hwdb update' takes > 50s when built with sanitizers so let's not run it by default.
systemctl --root="$BUILDROOT" mask systemd-hwdb-update.service