From 2f42745d767ef540ae6860feeddaa1210abb6e35 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 13 Feb 2026 12:03:06 +0100 Subject: [PATCH] [gdb/testsuite] Improve gdb.testsuite/quotemeta.exp Improve test-case gdb.testsuite/quotemeta.exp by: - catching errors in check_quotemeta - logging argument and results of calling quotemeta using verbose -log - renaming quotemeta_fail to check_quotemeta_fail for consistency with check_quotemeta - reducing escaping using {} - adding a missing test checking "@bad-name" --- gdb/testsuite/gdb.testsuite/quotemeta.exp | 40 +++++++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.testsuite/quotemeta.exp b/gdb/testsuite/gdb.testsuite/quotemeta.exp index e3375b8cf44..138fb997a4c 100644 --- a/gdb/testsuite/gdb.testsuite/quotemeta.exp +++ b/gdb/testsuite/gdb.testsuite/quotemeta.exp @@ -16,11 +16,36 @@ # Test the quotemeta facility. proc check_quotemeta {name input expected} { - gdb_assert {[quotemeta $input] == $expected} $name + set me "check_quotemeta" + verbose -log "$me: input: $input" + + set res [catch {set output [quotemeta $input]} msg] + if {$res == 0} { + verbose -log "$me: output: $output" + } else { + verbose -log "$me: catch_res: $res, catch_msg: $msg" + } + + set ok [expr {$res == 0 && $output == $expected}] + if {!$ok} { + verbose -log "$me: expected: $expected" + } + gdb_assert {$ok} $name } -proc quotemeta_fail {name input} { - gdb_assert {[catch {quotemeta $input}]} $name +proc check_quotemeta_fail {name input} { + set me "check_quotemeta_fail" + verbose -log "$me: input: $input" + + set res [catch {set output [quotemeta $input]} msg] + if {$res == 0} { + verbose -log "$me: output: $output" + } else { + verbose -log "$me: catch_res: $res, catch_msg: $msg" + } + + set ok [expr {$res == 1}] + gdb_assert {$ok} $name } check_quotemeta hex "@HEX" "$hex" @@ -31,16 +56,17 @@ check_quotemeta multi-brace "@{{{DECIMAL}}}" "$decimal" check_quotemeta regexp "@/hello/" hello check_quotemeta regexp-2 "@/hello/@/.*/" "hello.*" -check_quotemeta quoting ".*" "\\.\\*" +check_quotemeta quoting ".*" {\.\*} check_quotemeta dots @... .* check_quotemeta at @@ @ check_quotemeta slash-regexp "@{{/.*/.*/}}" ".*/.*" -check_quotemeta spaces "hello world" "hello\\s+world" +check_quotemeta spaces "hello world" {hello\s+world} check_quotemeta shy-brace "@{{DECIMAL}}@{{DECIMAL}}" "$decimal$decimal" -quotemeta_fail mismatch-brace "@{{{DECIMAL}}" -quotemeta_fail no-such-subst @NOTHING +check_quotemeta_fail mismatch-brace "@{{{DECIMAL}}" +check_quotemeta_fail no-such-subst @NOTHING +check_quotemeta_fail bad-name @bad-name -- 2.47.3