richardphibel / rpms / systemd

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