[binutils-gdb] [gdb/testsuite] Fix gdb.base/trace-commands.exp with editing off

Tom de Vries vries@sourceware.org
Fri Mar 31 15:15:43 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=103409bb38502b95cb60475939a49c2b059673d5

commit 103409bb38502b95cb60475939a49c2b059673d5
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Mar 31 17:15:37 2023 +0200

    [gdb/testsuite] Fix gdb.base/trace-commands.exp with editing off
    
    With test-case gdb.base/trace-commands.exp and editing off, I run into fails
    because multi-line commands are issued using gdb_test_sequence, which
    doesn't handle them correctly.
    
    Fix this by using gdb_test instead.
    
    Tested on x86_64-linux.
    
    PR testsuite/30288
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30288

Diff:
---
 gdb/testsuite/gdb.base/trace-commands.exp | 67 ++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 27 deletions(-)

diff --git a/gdb/testsuite/gdb.base/trace-commands.exp b/gdb/testsuite/gdb.base/trace-commands.exp
index c37b6d99d08..c936d228097 100644
--- a/gdb/testsuite/gdb.base/trace-commands.exp
+++ b/gdb/testsuite/gdb.base/trace-commands.exp
@@ -69,27 +69,33 @@ gdb_test "show trace-commands" \
 gdb_test "echo hi\\n" {\+echo hi\\n[\r\n]+hi} "simple trace-commands test"
 
 # Nested test
-gdb_test_sequence "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend" \
-    "nested trace-commands test" {
-  {[\r\n]\+if 1}
-  {[\r\n]\+\+set \$i = 0}
-  {[\r\n]\+\+while \$i < 5}
-  {[\r\n]\+\+\+func \$i}
-  {[\r\n]\+\+\+\+echo in func \$i\\n}
-  {[\r\n]\+\+\+set \$i \+= 1}
-  {[\r\n]\+\+\+func \$i}
-  {[\r\n]\+\+\+\+echo in func \$i\\n}
-  {[\r\n]\+\+\+set \$i \+= 1}
-  {[\r\n]\+\+\+func \$i}
-  {[\r\n]\+\+\+\+echo in func \$i\\n}
-  {[\r\n]\+\+\+set \$i \+= 1}
-  {[\r\n]\+\+\+func \$i}
-  {[\r\n]\+\+\+\+echo in func \$i\\n}
-  {[\r\n]\+\+\+set \$i \+= 1}
-  {[\r\n]\+\+\+func \$i}
-  {[\r\n]\+\+\+\+echo in func \$i\\n}
-  {[\r\n]\+\+\+set \$i \+= 1}
+set strings {
+    {+if 1}
+    {++set $i = 0}
+    {++while $i < 5}
+    {+++func $i}
+    {++++echo in func $i\n}
+    {+++set $i += 1}
+    {+++func $i}
+    {++++echo in func $i\n}
+    {+++set $i += 1}
+    {+++func $i}
+    {++++echo in func $i\n}
+    {+++set $i += 1}
+    {+++func $i}
+    {++++echo in func $i\n}
+    {+++set $i += 1}
+    {+++func $i}
+    {++++echo in func $i\n}
+    {+++set $i += 1}
+}
+set re {}
+foreach string $strings {
+    lappend re [string_to_regexp $string]
 }
+set re [join $re "\r\n(.*\r\n)?"]
+set cmd "if 1\nset \$i = 0\nwhile \$i < 5\nfunc \$i\nset \$i += 1\nend\nend"
+gdb_test $cmd $re "nested trace-commands test"
 
 # Function with source works
 gdb_test_sequence "define topfunc\nsource $tracecommandsscript\nend" \
@@ -111,13 +117,20 @@ gdb_test_sequence "topfunc" "nested trace-commands test with source" {
 }
 
 # Test nest depth resets properly on error
-gdb_test_sequence "if 1\nif 2\nload\necho should not get here\\n\nend\nend" \
-    "depth resets on error part 1" {
-  {[\r\n]\+if 1}
-  {[\r\n]\+\+if 2}
-  {[\r\n]\+\+\+load}
-  {[\r\n]No executable file specified\.}
-  {[\r\n]Use the "file" or "exec-file" command\.}
+set cmd "if 1\nif 2\nload\necho should not get here\\n\nend\nend"
+set strings {
+  {+if 1}
+  {++if 2}
+  {+++load}
+  {No executable file specified.}
+  {Use the "file" or "exec-file" command.}
+}
+set re {}
+foreach string $strings {
+    lappend re [string_to_regexp $string]
 }
+set re [join $re "\r\n(.*\r\n)?"]
+gdb_test $cmd $re "depth resets on error part 1"
+
 gdb_test "echo hi\\n" {[\r\n]\+echo hi\\n[\r\n]+hi} \
 	 "depth resets on error part 2"


More information about the Gdb-cvs mailing list