test: add tests for worker error code

This commit is contained in:
Yu Watanabe 2022-03-29 14:58:58 +09:00
parent 6467bda59d
commit 10176f0011

View File

@ -3,6 +3,7 @@
set -ex
test_rule="/run/udev/rules.d/49-test.rules"
KILL_PID=
setup() {
mkdir -p "${test_rule%/*}"
@ -22,18 +23,37 @@ EOF
teardown() {
set +e
if [[ -n "$KILL_PID" ]]; then
kill "$KILL_PID"
fi
rm -rf "$TMPDIR"
mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
rm -f "$test_rule"
systemctl restart systemd-udevd.service
}
run_test() {
local since
since="$(date '+%F %T')"
SYSTEMD_LOG_LEVEL=debug udevadm trigger --verbose --settle --action add /dev/null
TMPDIR=$(mktemp -d -p /tmp udev-tests.XXXXXX)
udevadm monitor --udev --property --subsystem-match=mem >"$TMPDIR"/monitor.txt &
KILL_PID="$!"
for _ in {1..20}; do
SYSTEMD_LOG_LEVEL=debug udevadm trigger --verbose --action add /dev/null
for _ in {1..40}; do
if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
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
return 0
fi
sleep .5