From f1bc816c098dfeed50fd95dbb647440251d0e4fa Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 7 Mar 2025 09:32:58 +0100 Subject: [PATCH] test: add test checking if pattern based hostnames work --- test/units/TEST-71-HOSTNAME.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/units/TEST-71-HOSTNAME.sh b/test/units/TEST-71-HOSTNAME.sh index 0813a07d46e..f844ccfcdb0 100755 --- a/test/units/TEST-71-HOSTNAME.sh +++ b/test/units/TEST-71-HOSTNAME.sh @@ -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 -- 2.47.3