]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add integration test for udev event timeout 15378/head
authorMichal Sekletár <msekleta@redhat.com>
Thu, 30 Apr 2020 21:22:08 +0000 (23:22 +0200)
committerMichal Sekletár <msekleta@redhat.com>
Fri, 5 Jun 2020 09:09:21 +0000 (11:09 +0200)
Note that run_test() calls coredumpctl in a loop because in certain
environments (1 vCPU unaccelerated QEMU VM) it might take quite a
while to process the coredump.

test/TEST-49-UDEV-EVENT-TIMEOUT/Makefile [new symlink]
test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh [new file with mode: 0755]
test/units/testsuite-49.service [new file with mode: 0644]
test/units/testsuite-49.sh [new file with mode: 0755]

diff --git a/test/TEST-49-UDEV-EVENT-TIMEOUT/Makefile b/test/TEST-49-UDEV-EVENT-TIMEOUT/Makefile
new file mode 120000 (symlink)
index 0000000..e9f93b1
--- /dev/null
@@ -0,0 +1 @@
+../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh b/test/TEST-49-UDEV-EVENT-TIMEOUT/test.sh
new file mode 100755 (executable)
index 0000000..249d8a2
--- /dev/null
@@ -0,0 +1,8 @@
+#!/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
diff --git a/test/units/testsuite-49.service b/test/units/testsuite-49.service
new file mode 100644 (file)
index 0000000..f471771
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=TEST-49-UDEV-EVENT-TIMEOUT
+
+[Service]
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+Type=oneshot
diff --git a/test/units/testsuite-49.sh b/test/units/testsuite-49.sh
new file mode 100755 (executable)
index 0000000..ffa9801
--- /dev/null
@@ -0,0 +1,47 @@
+#!/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
+
+echo OK > /testok
+
+exit 0