[v4,3/6] gdb/testsuite: Use _inferior_thread_count in gdb.threads/threadcrash.exp

Message ID 20240308093342.26745-4-tdevries@suse.de
State Committed
Headers
Series Fixes to gdb.threads/threadcrash.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom de Vries March 8, 2024, 9:33 a.m. UTC
  From: Guinevere Larsen <blarsen@redhat.com>

A linaro PR [1] reports that the gdb.threads/threadcrash.exp test-case fails
to cout the number of threads in the inferior:
...
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == 7
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == [llength $test_list]
...

Fix this by getting the convenience variable _inferior_thread_count as opposed
to calculating it based on the output of "info threads".

Tested on arm-linux and x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>

[1] https://linaro.atlassian.net/browse/GNU-1120
---
 gdb/testsuite/gdb.threads/threadcrash.exp | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)
  

Patch

diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index 592098b9c38..966708acd96 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -20,26 +20,6 @@ 
 # a gcore.
 
 
-# Check that the inferior has 7 threads, and return the number of threads (7).
-# We return the thread count so that, even if there is some error in the test,
-# the final log doesn't get flooded with failures.
-
-proc test_thread_count {} {
-    set thread_count 0
-
-    gdb_test_multiple "info threads" "getting thread count" -lbl {
-	-re "Thread" {
-	    incr thread_count
-	    exp_continue
-	}
-	-re "$::gdb_prompt " {
-	    gdb_assert {$thread_count == 7}
-	}
-    }
-
-    return $thread_count
-}
-
 # Use 'thread apply all backtrace' to check if all expected threads
 # are present, and stopped in the expected locations.  Set the global
 # TEST_LIST to be the a list of regexps expected to match all the
@@ -132,7 +112,8 @@  proc thread_apply_all {} {
 
 proc do_full_test {} {
     global test_list
-    set thread_count [test_thread_count]
+    set thread_count [get_valueof "" "\$_inferior_thread_count" 0]
+    gdb_assert {$thread_count == 7}
 
     thread_apply_all