1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

test: extend the "hashed" unit names coverage a bit

Follow-up to #22759.
This commit is contained in:
Frantisek Sumsal 2022-04-22 18:03:14 +02:00 committed by Yu Watanabe
parent b1aca4da60
commit 98f8c31638

View File

@ -489,7 +489,7 @@ testcase_iscsi_lvm() {
}
testcase_long_sysfs_path() {
local link logfile mpoint
local cursor link logfile mpoint
local expected_symlinks=(
"/dev/disk/by-label/data_vol"
"/dev/disk/by-label/swap_vol"
@ -500,6 +500,12 @@ testcase_long_sysfs_path() {
"/dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222"
)
# Create a cursor file to skip messages generated by udevd in initrd, as it
# might not be the same up-to-date version as we currently run (hence generating
# messages we check for later and making the test fail)
cursor="$(mktemp)"
journalctl --cursor-file="${cursor:?}" -n0 -q
# Make sure the test device is connected and show its "wonderful" path
stat /sys/block/vda
readlink -f /sys/block/vda/dev
@ -526,13 +532,20 @@ testcase_long_sysfs_path() {
udevadm settle
logfile="$(mktemp)"
[[ "$(journalctl -b -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
# Check state of affairs after https://github.com/systemd/systemd/pull/22759
# Note: can't use `--cursor-file` here, since we don't want to update the cursor
# after using it
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic --grep "Unit name .*vda.?\.device\" too long, falling back to hashed unit name" | wc -l)" -gt 0 ]]
# Check if the respective "hashed" units exist and are active (plugged)
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda1)"
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda2)"
# Make sure we don't unnecessarily spam the log
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/vda[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
[[ "$(wc -l <"$logfile")" -lt 10 ]]
: >/etc/fstab
rm -fr "${logfile:?}" "${mpoint:?}"
rm -fr "${cursor:?}" "${logfile:?}" "${mpoint:?}"
}
testcase_mdadm_basic() {