Skip to content

Commit 36d2304

Browse files
committed
loop/010: fix the flood udev events during the test
There still have many udev events on some special server like [1], let's try to stop systemd-udevd before the test, and start systemd-udevd after the test, you can find more details on the link. [1] $ uname -r 6.17.0-0.rc2.250821g068a56e56fa8.27.fc44.aarch64 $ free -g total used free shared buff/cache available Mem: 68 0 65 0 2 67 Swap: 7 0 7 $ nproc 8 $ rpm -qa systemd systemd-257.7-1.fc43.aarch64 $ ./check loop/010; time udevadm settle --timeout 1200 loop/010 (check stale loop partition) [passed] runtime 91.214s ... 91.224s real 19m37.788s user 0m0.002s sys 0m0.006s Link: #181 Signed-off-by: Yi Zhang <[email protected]>
1 parent 24fcc04 commit 36d2304

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

common/rc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,37 @@ _systemctl_stop() {
544544
done
545545
}
546546

547+
_systemctl_unit_is_active() {
548+
local unit="$1"
549+
550+
if command -v systemctl &>/dev/null &&
551+
systemctl is-active --quiet "$unit"; then
552+
return 0
553+
fi
554+
return 1
555+
}
556+
557+
_systemd_stop_udevd() {
558+
if _systemctl_unit_is_active "systemd-udevd"; then
559+
systemctl --quiet stop systemd-udevd
560+
systemctl --quiet mask systemd-udevd
561+
else
562+
echo "WARNING: systemd-udevd is not active"
563+
fi
564+
}
565+
566+
_systemd_start_udevd() {
567+
if ! _systemctl_unit_is_active "systemd-udevd"; then
568+
systemctl --quiet unmask systemd-udevd
569+
systemctl --quiet start systemd-udevd
570+
fi
571+
if ! _systemctl_unit_is_active "systemd-udevd"; then
572+
echo "WARNING: systemd-udevd not started"
573+
return 1
574+
fi
575+
return 0
576+
}
577+
547578
# Run the given command as NORMAL_USER
548579
_run_user() {
549580
su "$NORMAL_USER" -c "$1"

tests/loop/010

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ test() {
6060
mkfs.xfs --force "${loop_device}p1" >& /dev/null
6161
losetup --detach "${loop_device}" >& /dev/null
6262

63+
# This test generates udev events faster than the rate at which udevd
64+
# can process events. Stop systemd-udevd to prevent future test cases
65+
# fail.
66+
_systemd_stop_udevd
67+
6368
create_loop "${loop_device}" &
6469
create_pid=$!
6570
detach_loop "${loop_device}" &
@@ -78,5 +83,8 @@ test() {
7883
if _dmesg_since_test_start | grep --quiet "$grep_str"; then
7984
echo "Fail"
8085
fi
86+
87+
_systemd_start_udevd
88+
8189
echo "Test complete"
8290
}

0 commit comments

Comments
 (0)