2021-03-05 09:36:04 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-10-17 16:13:06 +00:00
|
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
2021-03-05 09:36:04 +00:00
|
|
|
set -ex
|
|
|
|
|
|
|
|
test_rule="/run/udev/rules.d/49-test.rules"
|
2022-03-29 05:58:58 +00:00
|
|
|
KILL_PID=
|
2021-03-05 09:36:04 +00:00
|
|
|
|
|
|
|
setup() {
|
|
|
|
mkdir -p "${test_rule%/*}"
|
|
|
|
cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
|
2021-03-07 05:18:07 +00:00
|
|
|
cat >"${test_rule}" <<EOF
|
2021-09-15 21:14:18 +00:00
|
|
|
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", OPTIONS="log_level=debug"
|
|
|
|
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", PROGRAM=="/bin/sleep 60"
|
2021-03-07 05:18:07 +00:00
|
|
|
EOF
|
2022-01-19 10:03:52 +00:00
|
|
|
cat >>/etc/udev/udev.conf <<EOF
|
|
|
|
event_timeout=10
|
|
|
|
timeout_signal=SIGABRT
|
|
|
|
EOF
|
2021-03-05 09:36:04 +00:00
|
|
|
|
|
|
|
systemctl restart systemd-udevd.service
|
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
set +e
|
|
|
|
|
2022-03-29 05:58:58 +00:00
|
|
|
if [[ -n "$KILL_PID" ]]; then
|
|
|
|
kill "$KILL_PID"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
|
2021-03-05 09:36:04 +00:00
|
|
|
mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
|
|
|
|
rm -f "$test_rule"
|
|
|
|
systemctl restart systemd-udevd.service
|
|
|
|
}
|
|
|
|
|
|
|
|
run_test() {
|
2022-03-29 05:58:58 +00:00
|
|
|
local since
|
|
|
|
|
2022-01-05 11:06:52 +00:00
|
|
|
since="$(date '+%F %T')"
|
2021-03-05 09:36:04 +00:00
|
|
|
|
2022-03-29 05:58:58 +00:00
|
|
|
TMPDIR=$(mktemp -d -p /tmp udev-tests.XXXXXX)
|
|
|
|
udevadm monitor --udev --property --subsystem-match=mem >"$TMPDIR"/monitor.txt &
|
|
|
|
KILL_PID="$!"
|
2021-03-05 09:36:04 +00:00
|
|
|
|
2022-03-29 05:58:58 +00:00
|
|
|
SYSTEMD_LOG_LEVEL=debug udevadm trigger --verbose --action add /dev/null
|
|
|
|
|
|
|
|
for _ in {1..40}; do
|
2021-03-05 09:36:04 +00:00
|
|
|
if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
|
2022-03-29 05:58:58 +00:00
|
|
|
kill "$KILL_PID"
|
|
|
|
KILL_PID=
|
|
|
|
|
|
|
|
cat "$TMPDIR"/monitor.txt
|
|
|
|
grep -q 'UDEV_WORKER_FAILED=1' "$TMPDIR"/monitor.txt
|
|
|
|
grep -q 'UDEV_WORKER_SIGNAL=6' "$TMPDIR"/monitor.txt
|
|
|
|
grep -q 'UDEV_WORKER_SIGNAL_NAME=ABRT' "$TMPDIR"/monitor.txt
|
2021-03-05 09:36:04 +00:00
|
|
|
return 0
|
|
|
|
fi
|
2021-09-15 21:14:18 +00:00
|
|
|
sleep .5
|
2021-03-05 09:36:04 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
trap teardown EXIT
|
|
|
|
|
|
|
|
setup
|
|
|
|
run_test
|
|
|
|
|
|
|
|
exit 0
|