]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Avoid large timeout in gdb.base/checkpoint.exp
authorTom de Vries <tdevries@suse.de>
Mon, 23 Sep 2024 20:03:56 +0000 (22:03 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 23 Sep 2024 20:03:56 +0000 (22:03 +0200)
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>
gdb/testsuite/gdb.base/checkpoint.exp

index f87f528e1676cca34aa38517b376e0e8cb8688db..31b5a13bb8f94a5ac2b7eafa10407ff5fd985925 100644 (file)
@@ -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
 #