]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test checking if pattern based hostnames work
authorLennart Poettering <lennart@poettering.net>
Fri, 7 Mar 2025 08:32:58 +0000 (09:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Mar 2025 17:01:42 +0000 (18:01 +0100)
test/units/TEST-71-HOSTNAME.sh

index 0813a07d46e4e5a8daa3271409547ea17e49f227..f844ccfcdb02365cebe1ebab550469bb28c3265d 100755 (executable)
@@ -262,6 +262,22 @@ test_varlink() {
     cmp "$A" "$B"
 }
 
+test_wildcard() {
+    SAVED="$(cat /etc/hostname)"
+
+    P='foo-??-??.????bar'
+    hostnamectl set-hostname "$P"
+    H="$(hostname)"
+    # Validate that the hostname is not the literal pattern, but matches the pattern shell style
+    assert_neq "$H" "$P"
+    [[ "$P" == "$H" ]]
+    assert_eq "$(cat /etc/hostname)" "$P"
+
+    assert_in "Static hostname: foo-" "$(hostnamectl)"
+
+    hostnamectl set-hostname "$SAVED"
+}
+
 run_testcases
 
 touch /testok