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

Tom de Vries tdevries@suse.de
Fri Sep 20 17:26:26 GMT 2024


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.
---
 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
 #

base-commit: c588e374965509b81a623ce9ef79a026f27d2592
-- 
2.35.3



More information about the Gdb-patches mailing list