Skip to content

Commit 5006511

Browse files
committed
test: escape '+' from uname -r before using in regex via '=~'
It will otherwise interpret characters such as '+' as if they were regex, and break matching. For example TEST-71-HOSTNAME started failing when uname -r started including a '+': FAIL: 'Kernel: Linux 6.12.33+deb13-amd64' not found in: Static hostname: host Icon name: computer-vm Chassis: vm 🖴 Machine ID: e6471c1f95ab49098827498ed816cdf7 Boot ID: 231da987f64d4af59f2076fbb638c611 Virtualization: kvm Operating System: Debian GNU/Linux 13 (trixie) Kernel: Linux 6.12.33+deb13-amd64 Architecture: x86-64 (cherry picked from commit a0dfb0245662e31ded34730010e0e92be9bd9f1a) (cherry picked from commit de5642b63e5c9210052b97105457a3debf5cc309) (cherry picked from commit c6e94cb7910d5f12bd64c21cd4ed36499c6addf1) (cherry picked from commit 359fed1)
1 parent 2e690f8 commit 5006511

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/units/testsuite-71.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ testcase_hostname() {
3131
if [[ -n "$orig" ]]; then
3232
assert_in "Static hostname: $orig" "$(hostnamectl)"
3333
fi
34-
assert_in "Kernel: $(uname -s) $(uname -r)" "$(hostnamectl)"
34+
assert_in "Kernel: $(uname -s) $(uname -r | sed 's/\+/\\+/g')" "$(hostnamectl)"
3535

3636
# change hostname
3737
assert_rc 0 hostnamectl set-hostname testhost

0 commit comments

Comments
 (0)