From db5d89309a6df2b505c52d70bf5a638190777027 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 4 Apr 2025 23:26:03 +0900 Subject: [PATCH] TEST-17-UDEV: check journal about inotify watch --- test/units/TEST-17-UDEV.watch.sh | 53 +++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/test/units/TEST-17-UDEV.watch.sh b/test/units/TEST-17-UDEV.watch.sh index 410f5a7f778..bf82ac3712d 100755 --- a/test/units/TEST-17-UDEV.watch.sh +++ b/test/units/TEST-17-UDEV.watch.sh @@ -5,6 +5,9 @@ set -o pipefail # tests for udev watch +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + function check_validity() { local f ID_OR_HANDLE @@ -12,15 +15,28 @@ function check_validity() { ID_OR_HANDLE="$(readlink "$f")" test -L "/run/udev/watch/${ID_OR_HANDLE}" test "$(readlink "/run/udev/watch/${ID_OR_HANDLE}")" = "$(basename "$f")" + + if [[ "${1:-}" == "1" ]]; then + journalctl -n 1 -q -u systemd-udevd.service --invocation=0 --grep "Found inotify watch .*$ID_OR_HANDLE" + fi done } function check() { for _ in {1..2}; do + systemctl reset-failed systemd-udevd.service systemctl restart systemd-udevd.service - udevadm control --ping udevadm settle --timeout=30 - check_validity + + journalctl --sync + + # Check if the inotify watch fd is received from fd store. + journalctl -n 1 -q -u systemd-udevd.service --invocation=0 --grep 'Received inotify fd \(\d\) from service manager.' + + # Check if there is no broken symlink chain. + assert_eq "$(journalctl -n 1 -q -u systemd-udevd.service --invocation=0 --grep 'Found broken inotify watch' || :)" "" + + check_validity 1 for _ in {1..2}; do udevadm trigger -w --action add --subsystem-match=block @@ -34,6 +50,24 @@ function check() { done } +# Check if the first invocation (should be in initrd) pushed the inotify fd to fdstore, +# and the next invocation gained the fd from service manager. +# TNote the service may be started without generating debugging logs. Let's check failure log. +if ! journalctl -n 1 -q -u systemd-udevd.service --invocation=1 --grep 'Pushed inotify fd to service manager.'; then + assert_eq "$(journalctl -n 1 -q -u systemd-udevd.service --invocation=1 --grep 'Failed to push inotify fd to service manager.' || :)" "" +fi +if ! journalctl -n 1 -q -u systemd-udevd.service --invocation=2 --grep 'Received inotify fd \(\d\) from service manager.'; then + assert_eq "$(journalctl -n 1 -q -u systemd-udevd.service --invocation=2 --grep 'Pushed inotify fd to service manager.' || :)" "" +fi + +mkdir -p /run/systemd/system/systemd-udevd.service.d/ +cat >/run/systemd/system/systemd-udevd.service.d/10-debug.conf </run/udev/rules.d/00-debug.rules </run/udev/rules.d/50-testsuite.rules <