1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

test: merge udev tests

This commit is contained in:
Yu Watanabe 2021-03-05 18:36:04 +09:00
parent daceb818cf
commit 1ebcf47296
40 changed files with 400 additions and 443 deletions

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="UDEV SYSTEMD_WANTS property"
TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
QEMU_TIMEOUT=300
do_test "$@" 17

View File

@ -1,11 +1,11 @@
#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="UDEV ID_RENAMING property"
IMAGE_NAME="udev-id-renaming"
TEST_DESCRIPTION="UDEV"
IMAGE_NAME="udev"
TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
QEMU_TIMEOUT=300
QEMU_TIMEOUT=500
test_append_files() {
(
@ -14,4 +14,4 @@ test_append_files() {
)
}
do_test "$@" 29
do_test "$@" 17

View File

@ -24,4 +24,4 @@ test_append_files() {
)
}
do_test "$@" 58
do_test "$@" 29

View File

@ -4,4 +4,4 @@ set -e
TEST_DESCRIPTION="test adding new BindPaths while unit is already running"
. $TEST_BASE_DIR/test-functions
do_test "$@" 57
do_test "$@" 49

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="test udev's event-timeout and timeout-signal options"
TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
do_test "$@" 49

View File

@ -45,4 +45,4 @@ check_result_qemu() {
return $ret
}
do_test "$@" 56
do_test "$@" 55

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -e
TEST_DESCRIPTION="UDEV tags management"
TEST_NO_NSPAWN=1
. $TEST_BASE_DIR/test-functions
do_test "$@" 55

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View File

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

72
test/units/testsuite-17.01.sh Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
rm -f /run/udev/rules.d/50-testsuite.rules
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
done
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service"
EOF
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
done
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service"
EOF
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q sda
) && break
sleep .5
done
rm /run/udev/rules.d/50-testsuite.rules
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
done
exit 0

57
test/units/testsuite-17.02.sh Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="remove", GOTO="lo_end"
SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
ACTION!="change", GOTO="lo_end"
SUBSYSTEM=="net", KERNEL=="lo", ENV{ID_RENAMING}="1"
LABEL="lo_end"
EOF
udevadm control --log-priority=debug --reload --timeout=600
udevadm trigger --action=add --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "active" ]] || exit 1
udevadm trigger --action=change --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "inactive" ]] || exit 1
udevadm trigger --action=move --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "active" ]] || exit 1
rm -f /run/udev/rules.d/50-testsuite.rules
udevadm control --reload --timeout=600
# test for issue #16967
ip link add hoge type dummy
udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/hoge
sleep 1
if ! systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
if ! systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
ip link set hoge name foobar
udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/foobar
sleep 1
if systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
if systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
if ! systemctl status sys-devices-virtual-net-foobar.device; then exit 1; fi
if ! systemctl status sys-subsystem-net-devices-foobar.device; then exit 1; fi
exit 0

45
test/units/testsuite-17.03.sh Executable file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -ex
test_rule="/run/udev/rules.d/49-test.rules"
setup() {
mkdir -p "${test_rule%/*}"
cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' > "${test_rule}"
echo "event_timeout=30" >> /etc/udev/udev.conf
echo "timeout_signal=SIGABRT" >> /etc/udev/udev.conf
systemctl restart systemd-udevd.service
}
teardown() {
set +e
mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
rm -f "$test_rule"
systemctl restart systemd-udevd.service
}
run_test() {
since="$(date +%T)"
echo add > /sys/class/net/lo/uevent
for n in {1..20}; do
sleep 5
if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
return 0
fi
done
return 1
}
trap teardown EXIT
setup
run_test
exit 0

64
test/units/testsuite-17.04.sh Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
! test -f /run/udev/tags/added/c1:3 &&
! test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*'
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", TAG+="added"
ACTION=="change", SUBSYSTEM=="mem", KERNEL=="null", TAG+="changed"
EOF
udevadm control --reload
udevadm trigger -c add /dev/null
while : ; do
test -f /run/udev/tags/added/c1:3 &&
! test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
break
sleep .5
done
udevadm control --reload
udevadm trigger -c change /dev/null
while : ; do
test -f /run/udev/tags/added/c1:3 &&
test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*' &&
break
sleep .5
done
udevadm control --reload
udevadm trigger -c add /dev/null
while : ; do
test -f /run/udev/tags/added/c1:3 &&
test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
break
sleep .5
done
exit 0

View File

@ -1,5 +1,5 @@
[Unit]
Description=TEST-17-UDEV-WANTS
Description=TEST-17-UDEV
[Service]
ExecStartPre=rm -f /failed /testok

View File

@ -1,74 +1,13 @@
#!/usr/bin/env bash
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
set -x
set -e
rm -f /run/udev/rules.d/50-testsuite.rules
udevadm control --reload
udevadm trigger /dev/sda
>/failed
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
for t in ${0%.sh}.*.sh; do
echo "Running $t"; ./$t
done
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="foobar.service"
EOF
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
done
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sda", ENV{SYSTEMD_WANTS}="waldo.service"
EOF
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q sda
) && break
sleep .5
done
rm /run/udev/rules.d/50-testsuite.rules
udevadm control --reload
udevadm trigger /dev/sda
while : ; do
(
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=foobar.service
udevadm info /dev/sda | grep -q -v SYSTEMD_WANTS=waldo.service
systemctl show -p WantedBy foobar.service | grep -q -v sda
systemctl show -p WantedBy waldo.service | grep -q -v sda
) && break
sleep .5
done
echo OK >/testok
exit 0
touch /testok
rm /failed

View File

@ -1,5 +1,5 @@
[Unit]
Description=TEST-29-UDEV-ID_RENAMING
Description=TEST-29-PORTABLE
[Service]
ExecStartPre=rm -f /failed /testok

View File

@ -1,58 +1,67 @@
#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
export SYSTEMD_LOG_LEVEL=debug
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="remove", GOTO="lo_end"
portablectl attach --now --runtime /usr/share/minimal_0.raw app0
SUBSYSTEM=="net", KERNEL=="lo", TAG+="systemd", ENV{SYSTEMD_ALIAS}+="/sys/subsystem/net/devices/lo"
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
ACTION!="change", GOTO="lo_end"
portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
SUBSYSTEM=="net", KERNEL=="lo", ENV{ID_RENAMING}="1"
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
LABEL="lo_end"
EOF
portablectl list | grep -q -F "minimal_1"
udevadm control --log-priority=debug --reload --timeout=600
udevadm trigger --action=add --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "active" ]] || exit 1
portablectl detach --now --runtime /usr/share/minimal_1.raw app0
udevadm trigger --action=change --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "inactive" ]] || exit 1
portablectl list | grep -q -F "No images."
udevadm trigger --action=move --settle /sys/devices/virtual/net/lo
udevadm info /sys/devices/virtual/net/lo
sleep 1
STATE=$(systemctl show --property=ActiveState --value sys-devices-virtual-net-lo.device)
[[ $STATE == "active" ]] || exit 1
# portablectl also works with directory paths rather than images
rm -f /run/udev/rules.d/50-testsuite.rules
udevadm control --reload --timeout=600
unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
# test for issue #16967
portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
ip link add hoge type dummy
udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/hoge
sleep 1
if ! systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
if ! systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
ip link set hoge name foobar
udevadm info --wait-for-initialization=10s /sys/devices/virtual/net/foobar
sleep 1
if systemctl status sys-devices-virtual-net-hoge.device; then exit 1; fi
if systemctl status sys-subsystem-net-devices-hoge.device; then exit 1; fi
if ! systemctl status sys-devices-virtual-net-foobar.device; then exit 1; fi
if ! systemctl status sys-subsystem-net-devices-foobar.device; then exit 1; fi
portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
portablectl list | grep -q -F "minimal_1"
portablectl detach --now --enable --runtime /tmp/minimal_1 app0
portablectl list | grep -q -F "No images."
echo OK > /testok

View File

@ -6,7 +6,7 @@ Type=notify
RemainAfterExit=yes
MountAPIVFS=yes
PrivateTmp=yes
BindPaths=/run/testservice-57-fixed:/tmp/testfile_fixed
BindPaths=/run/testservice-49-fixed:/tmp/testfile_fixed
InaccessiblePaths=/run/inaccessible
ExecStartPre=grep -q -F MARKER_FIXED /tmp/testfile_fixed
ExecStart=/bin/sh -c 'systemd-notify --ready; while ! grep -q -F MARKER_RUNTIME /tmp/testfile_runtime; do sleep 0.1; done; test ! -f /run/inaccessible/testfile_fixed'

View File

@ -1,6 +1,7 @@
[Unit]
Description=TEST-49-UDEV-EVENT-TIMEOUT
Description=TEST-49-RUNTIME-BIND-PATHS
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,46 +1,42 @@
#!/usr/bin/env bash
set -ex
test_rule="/run/udev/rules.d/49-test.rules"
echo "MARKER_FIXED" > /run/testservice-49-fixed
mkdir -p /run/inaccessible
setup() {
mkdir -p "${test_rule%/*}"
cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
echo 'KERNEL=="lo", SUBSYSTEM=="net", PROGRAM=="/bin/sleep 60"' > "${test_rule}"
echo "event_timeout=30" >> /etc/udev/udev.conf
echo "timeout_signal=SIGABRT" >> /etc/udev/udev.conf
systemctl start testsuite-49-namespaced.service
systemctl restart systemd-udevd.service
}
# Ensure that inaccessible paths aren't bypassed by the runtime setup
set +e
systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-fixed /run/inaccessible/testfile_fixed && exit 1
set -e
teardown() {
set +e
echo "MARKER_RUNTIME" > /run/testservice-49-runtime
mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
rm -f "$test_rule"
systemctl restart systemd-udevd.service
}
systemctl bind --mkdir testsuite-49-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime
run_test() {
since="$(date +%T)"
while systemctl show -P SubState testsuite-49-namespaced.service | grep -q running
do
sleep 0.1
done
echo add > /sys/class/net/lo/uevent
systemctl is-active testsuite-49-namespaced.service
for n in {1..20}; do
sleep 5
if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
return 0
fi
done
# Now test that systemctl bind fails when attempted on a non-namespaced unit
systemctl start testsuite-49-non-namespaced.service
return 1
}
set +e
systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testservice-49-runtime /tmp/testfile_runtime && exit 1
set -e
trap teardown EXIT
while systemctl show -P SubState testsuite-49-non-namespaced.service | grep -q running
do
sleep 0.1
done
setup
run_test
set +e
systemctl is-active testsuite-49-non-namespaced.service && exit 1
set -e
echo OK > /testok

View File

@ -5,5 +5,5 @@ Description=Create a lot of memory pressure
# A VERY small memory.high will cause the script (trying to use a lot of memory)
# to throttle and be put under heavy pressure.
MemoryHigh=1M
Slice=testsuite-56-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh
Slice=testsuite-55-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh

View File

@ -2,5 +2,5 @@
Description=No memory pressure
[Service]
Slice=testsuite-56-workload.slice
Slice=testsuite-55-workload.slice
ExecStart=sleep infinity

View File

@ -0,0 +1,7 @@
[Unit]
Description=Create some memory pressure
[Service]
MemoryHigh=2M
Slice=testsuite-55-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-55-slowgrowth.sh

View File

@ -1,7 +1,7 @@
[Unit]
Description=TESTSUITE-55-UDEV-TAGS
Description=TESTSUITE-55-OOMD
[Service]
ExecStartPre=rm -f /failed /testok
ExecStartPre=rm -f /failed /skipped /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,65 +1,75 @@
#!/bin/bash
#!/usr/bin/env bash
set -ex
set -o pipefail
mkdir -p /run/udev/rules.d/
systemd-analyze log-level debug
systemd-analyze log-target console
! test -f /run/udev/tags/added/c1:3 &&
! test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*'
# 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
[[ -e /skipped ]] && exit 0 || true
cat > /run/udev/rules.d/50-testsuite.rules <<EOF
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", TAG+="added"
ACTION=="change", SUBSYSTEM=="mem", KERNEL=="null", TAG+="changed"
EOF
rm -rf /etc/systemd/system/testsuite-55-testbloat.service.d
udevadm control --reload
udevadm trigger -c add /dev/null
echo "DefaultMemoryPressureDurationSec=5s" >> /etc/systemd/oomd.conf
while : ; do
test -f /run/udev/tags/added/c1:3 &&
! test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
systemctl start testsuite-55-testchill.service
systemctl start testsuite-55-testbloat.service
# Verify systemd-oomd is monitoring the expected units
oomctl | grep "/testsuite-55-workload.slice"
oomctl | grep "1.00%"
oomctl | grep "Default Memory Pressure Duration: 5s"
# systemd-oomd watches for elevated pressure for 5 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
if ! systemctl status testsuite-55-testbloat.service; then
break
sleep .5
fi
sleep 5
done
udevadm control --reload
udevadm trigger -c change /dev/null
# testbloat should be killed and testchill should be fine
if systemctl status testsuite-55-testbloat.service; then exit 42; fi
if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
while : ; do
test -f /run/udev/tags/added/c1:3 &&
test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:changed:.*' &&
break
# 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
sleep .5
done
mkdir -p /etc/systemd/system/testsuite-55-testbloat.service.d/
echo "[Service]" > /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
echo "ManagedOOMPreference=avoid" >> /etc/systemd/system/testsuite-55-testbloat.service.d/override.conf
udevadm control --reload
udevadm trigger -c add /dev/null
systemctl daemon-reload
systemctl start testsuite-55-testchill.service
systemctl start testsuite-55-testmunch.service
systemctl start testsuite-55-testbloat.service
while : ; do
test -f /run/udev/tags/added/c1:3 &&
test -f /run/udev/tags/changed/c1:3 &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: CURRENT_TAGS=.*:added:.*' &&
udevadm info /dev/null | grep -q 'E: TAGS=.*:changed:.*' &&
udevadm info /dev/null | grep -q -v 'E: CURRENT_TAGS=.*:changed:.*' &&
break
timeout=$(date -ud "2 minutes" +%s)
while [[ $(date -u +%s) -le $timeout ]]; do
if ! systemctl status testsuite-55-testmunch.service; then
break
fi
sleep 5
done
sleep .5
done
# testmunch should be killed since testbloat had the avoid xattr on it
if ! systemctl status testsuite-55-testbloat.service; then exit 25; fi
if systemctl status testsuite-55-testmunch.service; then exit 43; fi
if ! systemctl status testsuite-55-testchill.service; then exit 24; fi
fi
systemd-analyze log-level info
echo OK > /testok

View File

@ -1,7 +0,0 @@
[Unit]
Description=Create some memory pressure
[Service]
MemoryHigh=2M
Slice=testsuite-56-workload.slice
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh

View File

@ -1,7 +0,0 @@
[Unit]
Description=TESTSUITE-56-OOMD
[Service]
ExecStartPre=rm -f /failed /skipped /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,76 +0,0 @@
#!/usr/bin/env bash
set -ex
set -o pipefail
systemd-analyze log-level debug
systemd-analyze log-target console
# 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
[[ -e /skipped ]] && exit 0 || true
rm -rf /etc/systemd/system/testsuite-56-testbloat.service.d
echo "DefaultMemoryPressureDurationSec=5s" >> /etc/systemd/oomd.conf
systemctl start testsuite-56-testchill.service
systemctl start testsuite-56-testbloat.service
# Verify systemd-oomd is monitoring the expected units
oomctl | grep "/testsuite-56-workload.slice"
oomctl | grep "1.00%"
oomctl | grep "Default Memory Pressure Duration: 5s"
# systemd-oomd watches for elevated pressure for 5 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
if ! systemctl status testsuite-56-testbloat.service; then
break
fi
sleep 5
done
# testbloat should be killed and testchill should be fine
if systemctl status testsuite-56-testbloat.service; then exit 42; fi
if ! systemctl status testsuite-56-testchill.service; then exit 24; fi
# 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
mkdir -p /etc/systemd/system/testsuite-56-testbloat.service.d/
echo "[Service]" > /etc/systemd/system/testsuite-56-testbloat.service.d/override.conf
echo "ManagedOOMPreference=avoid" >> /etc/systemd/system/testsuite-56-testbloat.service.d/override.conf
systemctl daemon-reload
systemctl start testsuite-56-testchill.service
systemctl start testsuite-56-testmunch.service
systemctl start testsuite-56-testbloat.service
timeout=$(date -ud "2 minutes" +%s)
while [[ $(date -u +%s) -le $timeout ]]; do
if ! systemctl status testsuite-56-testmunch.service; then
break
fi
sleep 5
done
# testmunch should be killed since testbloat had the avoid xattr on it
if ! systemctl status testsuite-56-testbloat.service; then exit 25; fi
if systemctl status testsuite-56-testmunch.service; then exit 43; fi
if ! systemctl status testsuite-56-testchill.service; then exit 24; fi
fi
systemd-analyze log-level info
echo OK > /testok
exit 0

View File

@ -1,7 +0,0 @@
[Unit]
Description=TEST-57-RUNTIME-BIND-PATHS
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,43 +0,0 @@
#!/usr/bin/env bash
set -ex
echo "MARKER_FIXED" > /run/testservice-57-fixed
mkdir -p /run/inaccessible
systemctl start testsuite-57-namespaced.service
# Ensure that inaccessible paths aren't bypassed by the runtime setup
set +e
systemctl bind --mkdir testsuite-57-namespaced.service /run/testservice-57-fixed /run/inaccessible/testfile_fixed && exit 1
set -e
echo "MARKER_RUNTIME" > /run/testservice-57-runtime
systemctl bind --mkdir testsuite-57-namespaced.service /run/testservice-57-runtime /tmp/testfile_runtime
while systemctl show -P SubState testsuite-57-namespaced.service | grep -q running
do
sleep 0.1
done
systemctl is-active testsuite-57-namespaced.service
# Now test that systemctl bind fails when attempted on a non-namespaced unit
systemctl start testsuite-57-non-namespaced.service
set +e
systemctl bind --mkdir testsuite-57-non-namespaced.service /run/testservice-57-runtime /tmp/testfile_runtime && exit 1
set -e
while systemctl show -P SubState testsuite-57-non-namespaced.service | grep -q running
do
sleep 0.1
done
set +e
systemctl is-active testsuite-57-non-namespaced.service && exit 1
set -e
echo OK > /testok
exit 0

View File

@ -1,7 +0,0 @@
[Unit]
Description=TEST-58-PORTABLE
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View File

@ -1,68 +0,0 @@
#!/usr/bin/env bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -ex
set -o pipefail
export SYSTEMD_LOG_LEVEL=debug
portablectl attach --now --runtime /usr/share/minimal_0.raw app0
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
portablectl reattach --now --runtime /usr/share/minimal_1.raw app0
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
portablectl list | grep -q -F "minimal_1"
portablectl detach --now --runtime /usr/share/minimal_1.raw app0
portablectl list | grep -q -F "No images."
# portablectl also works with directory paths rather than images
unsquashfs -dest /tmp/minimal_0 /usr/share/minimal_0.raw
unsquashfs -dest /tmp/minimal_1 /usr/share/minimal_1.raw
portablectl attach --copy=symlink --now --runtime /tmp/minimal_0 app0
systemctl is-active app0.service
systemctl is-active app0-foo.service
set +o pipefail
set +e
systemctl is-active app0-bar.service && exit 1
set -e
set -o pipefail
portablectl reattach --now --enable --runtime /tmp/minimal_1 app0
systemctl is-active app0.service
systemctl is-active app0-bar.service
set +o pipefail
set +e
systemctl is-active app0-foo.service && exit 1
set -e
set -o pipefail
portablectl list | grep -q -F "minimal_1"
portablectl detach --now --enable --runtime /tmp/minimal_1 app0
portablectl list | grep -q -F "No images."
echo OK > /testok
exit 0