]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Improve gdb.testsuite/quotemeta.exp
authorTom de Vries <tdevries@suse.de>
Fri, 13 Feb 2026 11:03:06 +0000 (12:03 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 13 Feb 2026 11:03:06 +0000 (12:03 +0100)
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

index e3375b8cf44c1a16fcd3192980c0b7c6216c1642..138fb997a4c89355ee37b319235bfb6a36344e06 100644 (file)
 # 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