public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb/gdb-12-branch] gdb: testsuite: add new gdb_attach to check "attach" command
@ 2022-12-01 15:07 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2022-12-01 15:07 UTC (permalink / raw)
  To: gdb-cvs

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

commit 5091924da94bf68d4301a93fe848bf2c4a674f36
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Thu Mar 17 10:22:14 2022 +0800

    gdb: testsuite: add new gdb_attach to check "attach" command
    
    This commit adds new gdb_attach to centralize the failure checking of
    "attach" command. Return 0 if attach failed, otherwise return 1.
    
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Change-Id: I553cf386cef60c67d38e331904b4aa01e132104a

Diff:
---
 gdb/testsuite/lib/gdb.exp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 6f6acfe188a..819dfbfafca 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5151,6 +5151,32 @@ gdb_caching_proc can_spawn_for_attach {
     return 1
 }
 
+# Centralize the failure checking of "attach" command.
+# Return 0 if attach failed, otherwise return 1.
+
+proc gdb_attach { testpid args } {
+    parse_args {
+	{pattern ""}
+    }
+
+    if { [llength $args] != 0 } {
+	error "Unexpected arguments: $args"
+    }
+
+    gdb_test_multiple "attach $testpid" "attach" {
+	-re -wrap "Attaching to.*ptrace: Operation not permitted\\." {
+	    unsupported "$gdb_test_name (Operation not permitted)"
+	    return 0
+	}
+	-re -wrap "$pattern" {
+	    pass $gdb_test_name
+	    return 1
+	}
+    }
+
+    return 0
+}
+
 # Kill a progress previously started with spawn_wait_for_attach, and
 # reap its wait status.  PROC_SPAWN_ID is the spawn id associated with
 # the process.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-12-01 15:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-01 15:07 [binutils-gdb/gdb-12-branch] gdb: testsuite: add new gdb_attach to check "attach" command Simon Marchi

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