[binutils-gdb] [gdb/testsuite] Avoid large timeout in gdb.base/checkpoint.exp

Tom de Vries vries@sourceware.org
Mon Sep 23 20:03:50 GMT 2024


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

commit 2edcfde44c5bf915af5fbe2f25ebafd7ba57fad3
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Sep 23 22:03:56 2024 +0200

    [gdb/testsuite] Avoid large timeout in gdb.base/checkpoint.exp
    
    I ran the testsuite in an environment simulating a stressed system, and the
    only test-cases that timed out in gdb.base were gdb.base/checkpoint.exp and
    gdb.base/checkpoint-ns.exp (which includes gdb.base/checkpoints.exp).
    
    In test-case gdb.base/checkpoint.exp there's a part where the timeout is
    increased with 120 seconds (in the default case that's from 10 to 130), to
    accommodate for a single command creating 600+ checkpoints.
    
    Instead, rewrite the test to present a gdb prompt each time a checkpoint is
    created, for which the default timeout is sufficient.
    
    Also ensure that the amount of checkpoints added is exactly 600 rather than
    600+.
    
    Tested on aarch64-linux.
    
    Approved-By: Tom Tromey <tom@tromey.com>

Diff:
---
 gdb/testsuite/gdb.base/checkpoint.exp | 50 ++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 18 deletions(-)

diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index f87f528e167..31b5a13bb8f 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -295,30 +295,48 @@ clean_restart $binfile
 runto_main
 gdb_breakpoint $break1_loc
 
-gdb_test "commands\nsilent\nif (lines % 2)\ncheckpoint\nend\n  continue\nend" \
+set cmd \
+    [join \
+	 [list \
+	      "commands" \
+	      "if (lines % 2)" \
+	      "  checkpoint" \
+	      "else" \
+	      "  continue" \
+	      "end" \
+	      "end"] \
+	 "\n"]
+gdb_test $cmd \
     "" \
     "set checkpoint breakpoint"
 
-set prev_timeout $timeout
-set timeout [expr $timeout + 120]
-verbose "Timeout now $timeout sec."
-
-gdb_breakpoint $break2_loc
-gdb_test "continue" "breakpoint 2.*" "break2 with many checkpoints"
+set nr_ok 0
+for {set iter 0} {$iter < 600} {incr iter} {
+    set ok 0
+    gdb_test_multiple "continue" "" {
+	-re -wrap "breakpoint 1.*" {
+	    set ok 1
+	}
+	-re -wrap "" {
+	}
+    }
+    if { $ok } {
+	incr nr_ok
+    } else {
+	break
+    }
+}
+gdb_assert { $nr_ok == 600 } "break1 with many checkpoints"
 
 set count 0
 set msg "info checkpoints with at least 600 checkpoints"
 gdb_test_multiple "info checkpoints" $msg {
-    -re "  $decimal process \[^\r\]*\r\n" {
+    -re "\r\n  $decimal process \[^\r\]*" {
 	incr count
 	exp_continue
     }
-    -re "$gdb_prompt $" {
-	if { $count >= 600 } {
-	    pass $msg
-	} else {
-	    fail $msg
-	}
+    -re -wrap "" {
+	gdb_assert { $count == 600 } $gdb_test_name
     }
 }
 
@@ -329,10 +347,6 @@ gdb_test_multiple "info checkpoints" $msg {
 gdb_test "kill" "" "kill all one with many checkpoints" \
     "Kill the program being debugged.*y or n. $" "y"
 
-# Restore old timeout
-set timeout $prev_timeout
-verbose "Timeout now $timeout sec."
-
 #
 # Finished: cleanup
 #


More information about the Gdb-cvs mailing list