diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-12-13 17:22:01 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-09-01 17:40:12 +0200 |
commit | 31abedbb0325dee21cfdd9ec398918e85739c67e (patch) | |
tree | f5867f46d400b6238e76f493816e4dbab11bdbd1 | |
parent | libudev: also expose API to check for current tags in libudev (diff) | |
download | systemd-31abedbb0325dee21cfdd9ec398918e85739c67e.tar.xz systemd-31abedbb0325dee21cfdd9ec398918e85739c67e.zip |
test: add test for new "sticky" tags logic
l--------- | test/TEST-55-UDEV-TAGS/Makefile | 1 | ||||
-rwxr-xr-x | test/TEST-55-UDEV-TAGS/test.sh | 8 | ||||
-rw-r--r-- | test/units/testsuite-55.service | 7 | ||||
-rwxr-xr-x | test/units/testsuite-55.sh | 66 |
4 files changed, 82 insertions, 0 deletions
diff --git a/test/TEST-55-UDEV-TAGS/Makefile b/test/TEST-55-UDEV-TAGS/Makefile new file mode 120000 index 0000000000..e9f93b1104 --- /dev/null +++ b/test/TEST-55-UDEV-TAGS/Makefile @@ -0,0 +1 @@ +../TEST-01-BASIC/Makefile
\ No newline at end of file diff --git a/test/TEST-55-UDEV-TAGS/test.sh b/test/TEST-55-UDEV-TAGS/test.sh new file mode 100755 index 0000000000..325d70f011 --- /dev/null +++ b/test/TEST-55-UDEV-TAGS/test.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e +TEST_DESCRIPTION="UDEV tags management" +TEST_NO_NSPAWN=1 + +. $TEST_BASE_DIR/test-functions + +do_test "$@" 55 diff --git a/test/units/testsuite-55.service b/test/units/testsuite-55.service new file mode 100644 index 0000000000..2127a4db7f --- /dev/null +++ b/test/units/testsuite-55.service @@ -0,0 +1,7 @@ +[Unit] +Description=TESTSUITE-55-UDEV-TAGS + +[Service] +ExecStartPre=rm -f /failed /testok +ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh +Type=oneshot diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh new file mode 100755 index 0000000000..ffceefb6a5 --- /dev/null +++ b/test/units/testsuite-55.sh @@ -0,0 +1,66 @@ +#!/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 + +echo OK > /testok + +exit 0 |