]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: add test case for long unit names
authorMichal Sekletar <msekleta@redhat.com>
Wed, 23 Mar 2022 12:35:44 +0000 (13:35 +0100)
committerMichal Sekletar <msekleta@redhat.com>
Fri, 8 Apr 2022 13:18:29 +0000 (15:18 +0200)
test/units/testsuite-60.sh

index eb174f00ed481aec4931bfa9d907ffc369406812..239d7b0d4c9350a74c41441b2268777229aeb0e0 100755 (executable)
@@ -8,6 +8,25 @@ systemd-analyze log-target journal
 
 NUM_DIRS=20
 
+# make sure we can handle mounts at very long paths such that mount unit name must be hashed to fall within our unit name limit
+LONGPATH="$(printf "/$(printf "x%0.s" {1..255})%0.s" {1..7})"
+LONGMNT="$(systemd-escape --suffix=mount --path "$LONGPATH")"
+TS="$(date '+%H:%M:%S')"
+
+mkdir -p "$LONGPATH"
+mount -t tmpfs tmpfs "$LONGPATH"
+systemctl daemon-reload
+
+# check that unit is active(mounted)
+systemctl --no-pager show -p SubState --value "$LONGPATH" | grep -q mounted
+
+# check that relevant part of journal doesn't contain any errors related to unit
+[ "$(journalctl -b --since="$TS" --priority=err | grep -c "$LONGMNT")" = "0" ]
+
+# check that we can successfully stop the mount unit
+systemctl stop "$LONGPATH"
+rm -rf "$LONGPATH"
+
 # mount/unmount enough times to trigger the /proc/self/mountinfo parsing rate limiting
 
 for ((i = 0; i < NUM_DIRS; i++)); do