public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC 1/2] [gdb/testsuite] Modernize gdb.base/huge.exp
Date: Mon,  4 Sep 2023 07:41:47 +0200	[thread overview]
Message-ID: <20230904054148.24552-1-tdevries@suse.de> (raw)

Rewrite test-case gdb.base/huge.exp:
- use build_executable rather than gdb_compile,
- use save_vars,
- factor out hardcoded loop limits min and max,
- handle compilation failure using require, and
- avoid using . in regexp to match $, {} and <>.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.base/huge.exp | 51 +++++++++++++++++++++------------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp
index e28310c6eef..fc8909db8ee 100644
--- a/gdb/testsuite/gdb.base/huge.exp
+++ b/gdb/testsuite/gdb.base/huge.exp
@@ -23,29 +23,44 @@ require {!target_info exists gdb,skip_huge_test}
 
 standard_testfile .c
 
-for { set size [expr 2 * 1024 * 1024] } { $size > 10 } { set size [expr $size / 2] } {
-  if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
-	    executable [list debug "additional_flags=-DCRASH_GDB=$size"]] \
-      == "" } break
-}
-if { $size < 10 } {
-     untested "size less than 10"
-     return -1
+set max [expr 2 * 1024 * 1024]
+set min 16
+
+set opts {}
+lappend opts debug
+
+set compilation_succeeded 0
+for { set size $max } { $size >= $min } { set size [expr $size / 2] } {
+    set try_opts [concat $opts [list additional_flags=-DCRASH_GDB=$size]]
+    if { [build_executable $testfile.exp $testfile $srcfile $try_opts] == -1 } {
+	continue
+    }
+
+    set compilation_succeeded 1
+    break
 }
+require {expr $compilation_succeeded}
 
 # Start with a fresh gdb.
-
 clean_restart ${binfile}
 
-set prev_timeout $timeout
-set timeout 30
-
-if {![runto_main]} {
-    return -1
-}
+save_vars { timeout } {
+    set timeout 30
 
-gdb_test_no_output "set max-value-size unlimited"
+    if {![runto_main]} {
+	return -1
+    }
 
-gdb_test "print a" ".1 = .0 .repeats \[0123456789\]+ times.." "print a very large data object"
+    gdb_test_no_output "set max-value-size unlimited"
 
-set timeout $prev_timeout
+    set re \
+	[list \
+	     [string_to_regexp $] \
+	     $decimal \
+	     " = " \
+	     [string_to_regexp "{0 <repeats "] \
+	     $decimal \
+	     [string_to_regexp " times>}"]]
+    set re [join $re ""]
+    gdb_test "print a" $re "print a very large data object"
+}

base-commit: 0f020d9cedc947c09717984e0182828eb5f81208
-- 
2.35.3


             reply	other threads:[~2023-09-04  5:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  5:41 Tom de Vries [this message]
2023-09-04  5:41 ` [RFC 2/2] [gdb/exp] Clean up asap in value_print_array_elements Tom de Vries
2023-09-14 14:51   ` Tom Tromey
2023-09-14 14:20 ` [RFC 1/2] [gdb/testsuite] Modernize gdb.base/huge.exp Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230904054148.24552-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).