]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: extend the "hashed" unit names coverage a bit
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 22 Apr 2022 16:03:14 +0000 (18:03 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 Apr 2022 23:45:25 +0000 (08:45 +0900)
Follow-up to #22759.

test/units/testsuite-64.sh

index f9185a4517913699c15b521aaee8915d30686986..cabbad2db5c2ba9c1536adf8c97b9192a7b812f8 100755 (executable)
@@ -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() {