From: Lennart Poettering Date: Fri, 7 Mar 2025 08:32:58 +0000 (+0100) Subject: test: add test checking if pattern based hostnames work X-Git-Tag: v258-rc1~1111^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1bc816c098dfeed50fd95dbb647440251d0e4fa;p=thirdparty%2Fsystemd.git test: add test checking if pattern based hostnames work --- 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