teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0775-tests-add-test-case-for-long-unit-names.patch

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