summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-24-CRYPTSETUP/test.sh7
-rwxr-xr-xtest/TEST-55-OOMD/test.sh13
-rw-r--r--test/knot-data/knot.conf2
-rw-r--r--test/test-functions12
-rwxr-xr-xtest/test-shutdown.py5
-rwxr-xr-xtest/test-sysusers.sh.in2
-rwxr-xr-xtest/units/testsuite-23.utmp.sh22
-rwxr-xr-xtest/units/testsuite-43.sh5
-rwxr-xr-xtest/units/testsuite-55.sh68
9 files changed, 76 insertions, 60 deletions
diff --git a/test/TEST-24-CRYPTSETUP/test.sh b/test/TEST-24-CRYPTSETUP/test.sh
index ea86512..807b035 100755
--- a/test/TEST-24-CRYPTSETUP/test.sh
+++ b/test/TEST-24-CRYPTSETUP/test.sh
@@ -70,9 +70,10 @@ test_create_image() {
/dev/mapper/$DM_NAME /var ext4 defaults 0 1
EOF
- # Forward journal messages to the console, so we have something
- # to investigate even if we fail to mount the encrypted /var
- echo ForwardToConsole=yes >> "$initdir/etc/systemd/journald.conf"
+ # Forward journal messages to the console, so we have something to investigate even if we fail to mount
+ # the encrypted /var
+ mkdir "$initdir/etc/systemd/journald.conf.d/"
+ echo -ne "[Journal]\nForwardToConsole=yes\n" >"$initdir/etc/systemd/journald.conf.d/99-forward.conf"
# If $INITRD wasn't provided explicitly, generate a custom one with dm-crypt
# support
diff --git a/test/TEST-55-OOMD/test.sh b/test/TEST-55-OOMD/test.sh
index b1ab7c4..00ca4b9 100755
--- a/test/TEST-55-OOMD/test.sh
+++ b/test/TEST-55-OOMD/test.sh
@@ -12,19 +12,16 @@ TEST_NO_NSPAWN=1
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
- # Create a swap file
- (
- image_install mkswap swapon swapoff stress
+ local workspace="${1:?}"
- dd if=/dev/zero of="${initdir:?}/swapfile" bs=1M count=48
- chmod 0600 "${initdir:?}/swapfile"
+ image_install mkswap swapon swapoff stress
+ image_install -o btrfs
- mkdir -p "${initdir:?}/etc/systemd/system/init.scope.d/"
- cat >>"${initdir:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
+ mkdir -p "${workspace:?}/etc/systemd/system/init.scope.d/"
+ cat >"${workspace:?}/etc/systemd/system/init.scope.d/test-55-oomd.conf" <<EOF
[Scope]
MemoryHigh=10G
EOF
- )
}
do_test "$@" 55
diff --git a/test/knot-data/knot.conf b/test/knot-data/knot.conf
index e3de69d..59814ba 100644
--- a/test/knot-data/knot.conf
+++ b/test/knot-data/knot.conf
@@ -48,8 +48,8 @@ policy:
ds-push: parent_zone_server
ksk-lifetime: 365d
ksk-submission: parent_zone_sbm
+ nsec3-iterations: 0
nsec3: on
- nsec3-iterations: 10
propagation-delay: 1s
signing-threads: 4
zone-max-ttl: 1s
diff --git a/test/test-functions b/test/test-functions
index 73fbef8..da17bff 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -223,6 +223,7 @@ BASICTOOLS=(
useradd
userdel
wc
+ whoami
xargs
xzcat
)
@@ -1257,10 +1258,14 @@ install_suse_systemd() {
local testsdir=/usr/lib/systemd/tests
local pkgs
+ dinfo "Install basic filesystem structure"
+ install_rpm filesystem
+
dinfo "Install SUSE systemd"
pkgs=(
systemd
+ systemd-boot
systemd-container
systemd-coredump
systemd-experimental
@@ -3151,9 +3156,10 @@ test_create_image() {
}
test_setup() {
- if get_bool "${TEST_REQUIRE_INSTALL_TESTS:?}" && \
- command -v meson >/dev/null && \
- [[ "$(meson configure "${BUILD_DIR:?}" | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
+ if ! get_bool "$NO_BUILD" && \
+ get_bool "${TEST_REQUIRE_INSTALL_TESTS:?}" && \
+ command -v meson >/dev/null && \
+ [[ "$(meson configure "${BUILD_DIR:?}" | grep install-tests | awk '{ print $2 }')" != "true" ]]; then
dfatal "$BUILD_DIR needs to be built with -Dinstall-tests=true"
exit 1
fi
diff --git a/test/test-shutdown.py b/test/test-shutdown.py
index 13e18ec..00f7a6c 100755
--- a/test/test-shutdown.py
+++ b/test/test-shutdown.py
@@ -4,6 +4,7 @@
import argparse
import logging
+import signal
import sys
import pexpect
@@ -90,7 +91,9 @@ def run(args):
except Exception as e:
logger.error(e)
logger.info("killing child pid %d", console.pid)
- console.terminate(force=True)
+
+ # Ask systemd-nspawn to stop and release the container's resources properly.
+ console.kill(signal.SIGTERM)
return ret
diff --git a/test/test-sysusers.sh.in b/test/test-sysusers.sh.in
index aafba7d..abb74d5 100755
--- a/test/test-sysusers.sh.in
+++ b/test/test-sysusers.sh.in
@@ -152,7 +152,7 @@ for f in $(ls -1 $SOURCE/unhappy-*.input | sort -V); do
echo "*** Running test $f"
prepare_testdir ${f%.input}
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
- $SYSUSERS --root=$TESTDIR 2>&1 | tail -n1 | sed -r 's/^[^:]+:[^:]+://' >$TESTDIR/err
+ SYSTEMD_LOG_LEVEL=info $SYSUSERS --root=$TESTDIR 2>&1 | tail -n1 | sed -r 's/^[^:]+:[^:]+://' >$TESTDIR/err
if ! diff -u $TESTDIR/err ${f%.*}.expected-err; then
echo "**** Unexpected error output for $f"
cat $TESTDIR/err
diff --git a/test/units/testsuite-23.utmp.sh b/test/units/testsuite-23.utmp.sh
new file mode 100755
index 0000000..4f84315
--- /dev/null
+++ b/test/units/testsuite-23.utmp.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+USER="test-23-utmp"
+
+cleanup() {
+ userdel "$USER"
+}
+
+trap cleanup EXIT
+useradd "$USER"
+
+assert_eq "$(systemd-run -qP -p UtmpIdentifier=test -p UtmpMode=user -p User=$USER whoami)" "$USER"
+assert_eq "$(systemd-run -qP -p UtmpIdentifier=test -p UtmpMode=user whoami)" "$(whoami)"
diff --git a/test/units/testsuite-43.sh b/test/units/testsuite-43.sh
index 014c174..0495e4a 100755
--- a/test/units/testsuite-43.sh
+++ b/test/units/testsuite-43.sh
@@ -3,6 +3,11 @@
set -eux
set -o pipefail
+if [[ "$(sysctl -ne kernel.apparmor_restrict_unprivileged_userns)" -eq 1 ]]; then
+ echo "Cannot create unprivileged user namespaces" >/skipped
+ exit 0
+fi
+
systemd-analyze log-level debug
runas() {
diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh
index 838ba3a..5c541d3 100755
--- a/test/units/testsuite-55.sh
+++ b/test/units/testsuite-55.sh
@@ -10,15 +10,9 @@ test "$(cat /sys/fs/cgroup/init.scope/memory.high)" != "max"
# Loose checks to ensure the environment has the necessary features for systemd-oomd
[[ -e /proc/pressure ]] || echo "no PSI" >>/skipped
-cgroup_type="$(stat -fc %T /sys/fs/cgroup/)"
-if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
- echo "no cgroup2" >>/skipped
-fi
-if [ ! -f /usr/lib/systemd/systemd-oomd ] && [ ! -f /lib/systemd/systemd-oomd ]; then
- echo "no oomd" >>/skipped
-fi
-
-if [[ -e /skipped ]]; then
+[[ "$(get_cgroup_hierarchy)" == "unified" ]] || echo "no cgroupsv2" >>/skipped
+[[ -x /usr/lib/systemd/systemd-oomd ]] || echo "no oomd" >>/skipped
+if [[ -s /skipped ]]; then
exit 0
fi
@@ -26,7 +20,14 @@ rm -rf /run/systemd/system/testsuite-55-testbloat.service.d
# Activate swap file if we are in a VM
if systemd-detect-virt --vm --quiet; then
- mkswap /swapfile
+ if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
+ btrfs filesystem mkswapfile -s 64M /swapfile
+ else
+ dd if=/dev/zero of=/swapfile bs=1M count=64
+ chmod 0600 /swapfile
+ mkswap /swapfile
+ fi
+
swapon /swapfile
swapon --show
fi
@@ -72,27 +73,16 @@ systemctl start testsuite-55-testchill.service
systemctl start testsuite-55-testbloat.service
# Verify systemd-oomd is monitoring the expected units
-# Try to avoid racing the oomctl output check by checking in a loop with a timeout
-oomctl_output=$(oomctl)
-timeout="$(date -ud "1 minutes" +%s)"
-while [[ $(date -u +%s) -le $timeout ]]; do
- if grep "/testsuite-55-workload.slice" <<< "$oomctl_output"; then
- break
- fi
- oomctl_output=$(oomctl)
- sleep 1
-done
-
-grep "/testsuite-55-workload.slice" <<< "$oomctl_output"
-grep "20.00%" <<< "$oomctl_output"
-grep "Default Memory Pressure Duration: 2s" <<< "$oomctl_output"
+timeout 1m bash -xec 'until oomctl | grep "/testsuite-55-workload.slice"; do sleep 1; done'
+oomctl | grep "/testsuite-55-workload.slice"
+oomctl | grep "20.00%"
+oomctl | grep "Default Memory Pressure Duration: 2s"
systemctl status testsuite-55-testchill.service
# systemd-oomd watches for elevated pressure for 2 seconds before acting.
# It can take time to build up pressure so either wait 2 minutes or for the service to fail.
-timeout="$(date -ud "2 minutes" +%s)"
-while [[ $(date -u +%s) -le $timeout ]]; do
+for _ in {0..59}; do
if ! systemctl status testsuite-55-testbloat.service; then
break
fi
@@ -105,32 +95,23 @@ if systemctl status testsuite-55-testbloat.service; then exit 42; fi
if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
# Make sure we also work correctly on user units.
+loginctl enable-linger testuser
systemctl start --machine "testuser@.host" --user testsuite-55-testchill.service
systemctl start --machine "testuser@.host" --user testsuite-55-testbloat.service
# Verify systemd-oomd is monitoring the expected units
# Try to avoid racing the oomctl output check by checking in a loop with a timeout
-oomctl_output=$(oomctl)
-timeout="$(date -ud "1 minutes" +%s)"
-while [[ $(date -u +%s) -le $timeout ]]; do
- if grep -E "/user.slice.*/testsuite-55-workload.slice" <<< "$oomctl_output"; then
- break
- fi
- oomctl_output=$(oomctl)
- sleep 1
-done
-
-grep -E "/user.slice.*/testsuite-55-workload.slice" <<< "$oomctl_output"
-grep "20.00%" <<< "$oomctl_output"
-grep "Default Memory Pressure Duration: 2s" <<< "$oomctl_output"
+timeout 1m bash -xec 'until oomctl | grep "/testsuite-55-workload.slice"; do sleep 1; done'
+oomctl | grep -E "/user.slice.*/testsuite-55-workload.slice"
+oomctl | grep "20.00%"
+oomctl | grep "Default Memory Pressure Duration: 2s"
systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service
# systemd-oomd watches for elevated pressure for 2 seconds before acting.
# It can take time to build up pressure so either wait 2 minutes or for the service to fail.
-timeout="$(date -ud "2 minutes" +%s)"
-while [[ $(date -u +%s) -le $timeout ]]; do
+for _ in {0..59}; do
if ! systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then
break
fi
@@ -142,6 +123,8 @@ done
if systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then exit 42; fi
if ! systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service; then exit 24; fi
+loginctl disable-linger testuser
+
# only run this portion of the test if we can set xattrs
if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then
sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
@@ -157,8 +140,7 @@ EOF
systemctl start testsuite-55-testmunch.service
systemctl start testsuite-55-testbloat.service
- timeout="$(date -ud "2 minutes" +%s)"
- while [[ "$(date -u +%s)" -le "$timeout" ]]; do
+ for _ in {0..59}; do
if ! systemctl status testsuite-55-testmunch.service; then
break
fi