public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: fix duplicate test names in gdb.trace/circ.exp
@ 2024-03-05 16:35 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2024-03-05 16:35 UTC (permalink / raw)
  To: gdb-cvs

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

commit f08311ceb1ba4e19eab7070e676416337455a074
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Thu Feb 1 12:57:11 2024 +0000

    gdb/testsuite: fix duplicate test names in gdb.trace/circ.exp
    
    This fixes some duplicate test names in gdb.trace/circ.exp when using
    native-gdbserver and native-extended-gdbserver boards.
    
    In this test we set the trace buffer size twice.  The same test name
    was used each time the size was adjusted.
    
    I've fixed this issue by:
    
      1. Creating a new proc, set_trace_buffer_size, which factors out the
      code to change the buffer size, and uses test names based on the
      size we're setting the buffer too,
    
      2. Calling the new proc each time we want to adjust the buffer size.
    
    After this the duplicate test names are resolved.  There should be no
    change in what is tested after this commit.

Diff:
---
 gdb/testsuite/gdb.trace/circ.exp | 76 ++++++++++++++++++++++++----------------
 1 file changed, 45 insertions(+), 31 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/circ.exp b/gdb/testsuite/gdb.trace/circ.exp
index 66bb64852fd..d123a1e7686 100644
--- a/gdb/testsuite/gdb.trace/circ.exp
+++ b/gdb/testsuite/gdb.trace/circ.exp
@@ -115,45 +115,59 @@ gdb_test "show circular-trace-buffer" \
     "Target's use of circular trace buffer is on." \
     "show circular-trace-buffer (on)"
 
-# Check if changing the trace buffer size is supported.  This step is
-# repeated twice.  This helps in case the trace buffer size is 100.
-set test_size 100
-set test "change buffer size to $test_size"
-gdb_test_multiple "set trace-buffer-size $test_size" $test {
-    -re ".*Target does not support this command.*$gdb_prompt $" {
-	unsupported "target does not support changing trace buffer size"
-	return 1
+# Use 'set trace-buffer-size' to change the trace buffer size to
+# REQUIRED_SIZE.  Return -1 if the current target doesn't support
+# adjusting the trace buffer size.  Return 0 if the adjustment failed
+# for some other reason.  Return 1 if the trace buffer size was
+# correctly adjusted.
+#
+# If this proc returns -1 then a suitable call to the unsupported proc
+# will have already been made.
+proc set_trace_buffer_size { required_size } {
+    set test_passed false
+    gdb_test_multiple "set trace-buffer-size $required_size" "" {
+	-re -wrap ".*Target does not support this command.*" {
+	    unsupported "target does not support changing trace buffer size"
+	    return -1
+	}
+	-re -wrap "" {
+	    pass $gdb_test_name
+	    set test_passed true
+	}
     }
-    -re "$gdb_prompt $" {
-	pass $test
+
+    if { !$test_passed } {
+	return 0
     }
-}
 
-set test "check whether setting trace buffer size is supported"
-gdb_test_multiple "tstatus" $test {
-    -re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*$gdb_prompt $" {
-	set total_size $expect_out(2,string)
-	if { $test_size != $total_size } {
-	    unsupported "target does not support changing trace buffer size"
-	    return 1
+    set test_passed false
+    gdb_test_multiple "tstatus" "check trace-buffer-size is $required_size" {
+	-re -wrap ".*Trace buffer has ($::decimal) bytes of ($::decimal) bytes free.*" {
+	    set total_size $expect_out(2,string)
+	    if { $required_size != $total_size } {
+		unsupported "target does not support changing trace buffer size"
+		return -1
+	    }
+	    pass $gdb_test_name
+	    set test_passed true
 	}
-	pass $test
     }
+
+    if { !$test_passed } {
+	return 0
+    }
+
+    return 1
 }
 
-set test_size 400
-gdb_test_no_output "set trace-buffer-size $test_size" \
-    "change buffer size to $test_size"
+# Check if changing the trace buffer size is supported.  This step is
+# repeated twice.  This helps in case the trace buffer size is 100.
+if {[set_trace_buffer_size 100] < 0} {
+    return
+}
 
-gdb_test_multiple "tstatus" $test {
-    -re ".*Trace buffer has ($decimal) bytes of ($decimal) bytes free.*$gdb_prompt $" {
-	set total_size $expect_out(2,string)
-	if { $test_size != $total_size } {
-	    unsupported "target does not support changing trace buffer size"
-	    return 1
-	}
-	pass $test
-    }
+if {[set_trace_buffer_size 400] < 0} {
+    return
 }
 
 gdb_test_no_output "set circular-trace-buffer off" \

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-05 16:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 16:35 [binutils-gdb] gdb/testsuite: fix duplicate test names in gdb.trace/circ.exp Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).