62b301
From 1c2a0bde1bc3510d9bdc07410ff90429ebed391f Mon Sep 17 00:00:00 2001
62b301
From: Michal Sekletar <msekleta@redhat.com>
62b301
Date: Wed, 23 Mar 2022 13:35:44 +0100
62b301
Subject: [PATCH] tests: add test case for long unit names
62b301
62b301
(cherry picked from commit 2ef0101e0b2813e8c99fc8f137dbaa763ca16057)
62b301
62b301
Related: #1940973
62b301
---
62b301
 test/TEST-60-MOUNT-RATELIMIT/testsuite.sh | 19 +++++++++++++++++++
62b301
 1 file changed, 19 insertions(+)
62b301
62b301
diff --git a/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh b/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
62b301
index 8158754667..6211050faf 100755
62b301
--- a/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
62b301
+++ b/test/TEST-60-MOUNT-RATELIMIT/testsuite.sh
62b301
@@ -7,6 +7,25 @@ systemd-analyze log-target journal
62b301
 
62b301
 NUM_DIRS=20
62b301
 
62b301
+# 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
62b301
+LONGPATH="$(printf "/$(printf "x%0.s" {1..255})%0.s" {1..7})"
62b301
+LONGMNT="$(systemd-escape --suffix=mount --path "$LONGPATH")"
62b301
+TS="$(date '+%H:%M:%S')"
62b301
+
62b301
+mkdir -p "$LONGPATH"
62b301
+mount -t tmpfs tmpfs "$LONGPATH"
62b301
+systemctl daemon-reload
62b301
+
62b301
+# check that unit is active(mounted)
62b301
+systemctl --no-pager show -p SubState --value "$LONGPATH" | grep -q mounted
62b301
+
62b301
+# check that relevant part of journal doesn't contain any errors related to unit
62b301
+[ "$(journalctl -b --since="$TS" --priority=err | grep -c "$LONGMNT")" = "0" ]
62b301
+
62b301
+# check that we can successfully stop the mount unit
62b301
+systemctl stop "$LONGPATH"
62b301
+rm -rf "$LONGPATH"
62b301
+
62b301
 # mount/unmount enough times to trigger the /proc/self/mountinfo parsing rate limiting
62b301
 
62b301
 for ((i = 0; i < NUM_DIRS; i++)); do