mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
3af61b9224
Otherwise we might hit a window where the coredump happens before
midnight, but we check for it after midnight, which yields no results.
E.g.:
```
$ coredumpctl --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
$ coredumpctl --since 23:59:55 --no-legend --no-pager --file system.journal
No coredumps found.
$ coredumpctl --since "2022-01-04 23:59:59" --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
```
(cherry picked from commit 1b51599f29
)
49 lines
1.0 KiB
Bash
Executable File
49 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
set -ex
|
|
|
|
test_rule="/run/udev/rules.d/49-test.rules"
|
|
|
|
setup() {
|
|
mkdir -p "${test_rule%/*}"
|
|
cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
|
|
cat >"${test_rule}" <<EOF
|
|
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", OPTIONS="log_level=debug"
|
|
ACTION=="add", SUBSYSTEM=="mem", KERNEL=="null", PROGRAM=="/bin/sleep 60"
|
|
EOF
|
|
echo "event_timeout=10" >>/etc/udev/udev.conf
|
|
echo "timeout_signal=SIGABRT" >>/etc/udev/udev.conf
|
|
|
|
systemctl restart systemd-udevd.service
|
|
}
|
|
|
|
teardown() {
|
|
set +e
|
|
|
|
mv -f /etc/udev/udev.conf.bckp /etc/udev/udev.conf
|
|
rm -f "$test_rule"
|
|
systemctl restart systemd-udevd.service
|
|
}
|
|
|
|
run_test() {
|
|
since="$(date '+%F %T')"
|
|
|
|
SYSTEMD_LOG_LEVEL=debug udevadm trigger --verbose --settle --action add /dev/null
|
|
|
|
for _ in {1..20}; do
|
|
if coredumpctl --since "$since" --no-legend --no-pager | grep /bin/udevadm ; then
|
|
return 0
|
|
fi
|
|
sleep .5
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
trap teardown EXIT
|
|
|
|
setup
|
|
run_test
|
|
|
|
exit 0
|