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: [PATCH v4 4/6] gdb/testsuite: Simplify gdb.threads/threadcrash.exp
Date: Fri,  8 Mar 2024 10:33:40 +0100	[thread overview]
Message-ID: <20240308093342.26745-5-tdevries@suse.de> (raw)
In-Reply-To: <20240308093342.26745-1-tdevries@suse.de>

I noticed in gdb.threads/threadcrash.exp that the usage of test_list is
somewhat convoluted.

Simplify the test-case by storing a classification instead of a pattern in
test_list.

Tested on arm-linux and x86_64-linux.
---
 gdb/testsuite/gdb.threads/threadcrash.exp | 89 +++++++++++++++--------
 1 file changed, 60 insertions(+), 29 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index 966708acd96..16fd7eb4e23 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -46,52 +46,31 @@ proc thread_apply_all {} {
 	    exp_continue
 	}
 	-re "^\r\n${hs}syscall_task .location=SIGNAL_ALT_STACK$hs$eol" {
-	    lappend test_list [multi_line ".*sleep.*" \
-				   ".*do_syscall_task .location=SIGNAL_ALT_STACK.*" \
-				   ".*signal_handler.*" \
-				   ".*signal handler called.*" \
-				   ".*pthread_kill.*" \
-				   ".*thread_function.*"]
+	    lappend test_list 1
 	    exp_continue
 	}
 	-re "^\r\n${hs}syscall_task .location=SIGNAL_HANDLER$hs$eol" {
-	    lappend test_list [multi_line ".*sleep.*" \
-				   ".*do_syscall_task .location=SIGNAL_HANDLER.*" \
-				   ".*signal_handler.*" \
-				   ".*signal handler called.*" \
-				   ".*pthread_kill.*" \
-				   ".*thread_function.*"]
+	    lappend test_list 2
 	    exp_continue
 	}
 	-re "^\r\n${hs}syscall_task .location=NORMAL$hs$eol" {
-	    lappend test_list [multi_line ".*sleep.*" \
-				   ".*do_syscall_task .location=NORMAL.*" \
-				   ".*thread_function.*"]
+	    lappend test_list 3
 	    exp_continue
 	}
 	-re "^\r\n${hs}spin_task .location=SIGNAL_ALT_STACK$hs$eol" {
-	    lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_ALT_STACK.*" \
-				   ".*signal_handler.*" \
-				   ".*signal handler called.*" \
-				   ".*pthread_kill.*" \
-				   ".*thread_function.*"]
+	    lappend test_list 4
 	    exp_continue
 	}
 	-re "^\r\n${hs}spin_task .location=SIGNAL_HANDLER$hs$eol" {
-	    lappend test_list [multi_line ".*do_spin_task .location=SIGNAL_HANDLER.*" \
-				   ".*signal_handler.*" \
-				   ".*signal handler called.*" \
-				   ".*pthread_kill.*" \
-				   ".*thread_function.*"]
+	    lappend test_list 5
 	    exp_continue
 	}
 	-re "^\r\n${hs}spin_task .location=NORMAL$hs$eol" {
-	    lappend test_list [multi_line ".*do_spin_task .location=NORMAL..*" \
-				   ".*thread_function.*"]
+	    lappend test_list 6
 	    exp_continue
 	}
 	-re "^\r\n${hs}main$hs$eol" {
-	    lappend test_list ".*main.*"
+	    lappend test_list 7
 	    exp_continue
 	}
 	-re "^\r\n$hs$eol" {
@@ -122,7 +101,59 @@ proc do_full_test {} {
     for {set i 0} {$i < $thread_count } {incr i} {
 	set thread_num [expr [llength $test_list] - $i]
 
-	gdb_test "thread apply $thread_num backtrace" [lindex $test_list $i]
+	set type [lindex $test_list $i]
+	if { $type == 1 } {
+	    set re \
+		[multi_line \
+		     ".sleep.*" \
+		     ".*do_syscall_task .location=SIGNAL_ALT_STACK.*" \
+		     ".*signal_handler.*" \
+		     ".*signal handler called.*" \
+		     ".*pthread_kill.*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 2 } {
+	    set re \
+		[multi_line \
+		     ".*sleep.*" \
+		     ".*do_syscall_task .location=SIGNAL_HANDLER.*" \
+		     ".*signal_handler.*" \
+		     ".*signal handler called.*" \
+		     ".*pthread_kill.*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 3 } {
+	    set re \
+		[multi_line \
+		     ".*sleep.*" \
+		     ".*do_syscall_task .location=NORMAL.*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 4 } {
+	    set re \
+		[multi_line \
+		     ".*do_spin_task .location=SIGNAL_ALT_STACK.*" \
+		     ".*signal_handler.*" \
+		     ".*signal handler called.*" \
+		     ".*pthread_kill.*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 5 } {
+	    set re \
+		[multi_line \
+		     ".*do_spin_task .location=SIGNAL_HANDLER.*" \
+		     ".*signal_handler.*" \
+		     ".*signal handler called.*" \
+		     ".*pthread_kill.*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 6 } {
+	    set re \
+		[multi_line \
+		     ".*do_spin_task .location=NORMAL..*" \
+		     ".*thread_function.*"]
+	} elseif { $type == 7 } {
+	    set re ".*main.*"
+	} else {
+	    error "invalid type: $type"
+	}
+
+	gdb_test "thread apply $thread_num backtrace" $re
     }
 }
 
-- 
2.35.3


  parent reply	other threads:[~2024-03-08 11:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  9:33 [PATCH v4 0/6] Fixes to gdb.threads/threadcrash.exp Tom de Vries
2024-03-08  9:33 ` [PATCH v4 1/6] gdb/testsuite: Reduce indentation in gdb.threads/threadcrash.exp Tom de Vries
2024-03-13 17:12   ` Tom Tromey
2024-03-08  9:33 ` [PATCH v4 2/6] gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore Tom de Vries
2024-03-13 17:17   ` Tom Tromey
2024-03-08  9:33 ` [PATCH v4 3/6] gdb/testsuite: Use _inferior_thread_count in gdb.threads/threadcrash.exp Tom de Vries
2024-03-08  9:33 ` Tom de Vries [this message]
2024-03-08  9:33 ` [PATCH v4 5/6] gdb/testsuite: Reduce gdb.threads/threadcrash.exp reliance on libc symbols Tom de Vries
2024-03-08  9:33 ` [PATCH v4 6/6] gdb/testsuite: Add kfail in gdb.threads/threadcrash.exp on 32-bit arm targets Tom de Vries
2024-03-08 10:24   ` Tom de Vries
2024-03-08 23:57     ` Thiago Jung Bauermann
2024-03-11 10:15       ` Tom de Vries
2024-03-11 18:10         ` Thiago Jung Bauermann
2024-03-11 23:03           ` Thiago Jung Bauermann

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=20240308093342.26745-5-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).