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 7/7] [gdb/testsuite] Use unique portnum in parallel testing (check//% case)
Date: Mon, 15 Apr 2024 17:56:27 +0200	[thread overview]
Message-ID: <20240415155627.22108-7-tdevries@suse.de> (raw)
In-Reply-To: <20240415155627.22108-1-tdevries@suse.de>

Make target check//% is the gdb variant of a similar gcc make target [1].

When running tests using check//%:
...
$ cd build/gdb
$ make check//unix/{-fPIE/-pie,-fno-PIE/-no-pie} -j2 TESTS=gdb.server/*.exp
...
we get:
...
$ cat build/gdb/testsuite.unix.-fPIE.-pie/cache/portnum
2427
$ cat build/gdb/testsuite.unix.-fno-PIE.-no-pie/cache/portnum
2423
...

The problem is that there are two portnum files used in parallel.

Fix this by:
- creating a common lockdir build/gdb/testsuite.lockdir for make target
  check//%,
- passing this down to the runtests invocations using variable GDB_LOCK_DIR,
  and
- using GDB_LOCK_DIR in lock_dir.

Tested on aarch64-linux.

PR testsuite/31632
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31632

[1] https://gcc.gnu.org/install/test.html
---
 gdb/Makefile.in                 | 8 ++++++--
 gdb/testsuite/lib/gdb-utils.exp | 5 +++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 23894ea4a4d..5a63f166107 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2002,6 +2002,10 @@ check-all-boards: force
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) check-all-boards; \
 	else true; fi
 
+testsuite.lockdir: force
+	rm -rf $@
+	mkdir -p $@
+
 # The idea is to parallelize testing of multilibs, for example:
 #   make -j3 check//sh-hms-sim/{-m1,-m2,-m3,-m3e,-m4}/{,-nofpu}
 # will run 3 concurrent sessions of check, eventually testing all 10
@@ -2010,7 +2014,7 @@ check-all-boards: force
 # used, this rule will harmlessly fail to match.  Used FORCE_PARALLEL to
 # prevent serialized checking due to the passed RUNTESTFLAGS.
 # FIXME: use config.status --config not --version, when available.
-check//%: force
+check//%: force testsuite.lockdir
 	@if [ -f testsuite/config.status ]; then \
 	  rootme=`pwd`; export rootme; \
 	  rootsrc=`cd $(srcdir); pwd`; export rootsrc; \
@@ -2028,7 +2032,7 @@ check//%: force
 	     ); \
 	  else :; fi && cd $$testdir && \
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) \
-	    RUNTESTFLAGS="--target_board=$$variant $(RUNTESTFLAGS)" \
+	    RUNTESTFLAGS="GDB_LOCK_DIR=$$rootme/testsuite.lockdir --target_board=$$variant $(RUNTESTFLAGS)" \
 	    FORCE_PARALLEL=$(if $(FORCE_PARALLEL),1,$(if $(RUNTESTFLAGS),,1)) \
 	    "$$target"; \
 	else true; fi
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 1f30d807ff0..95c53d030d8 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -180,6 +180,11 @@ proc lock_file_release {info} {
 # Return directory where we keep lock files.
 
 proc lock_dir {} {
+    if { [info exists ::GDB_LOCK_DIR] } {
+	# When using check//.
+	return $::GDB_LOCK_DIR
+    }
+
     return [make_gdb_parallel_path cache]
 }
 
-- 
2.35.3


  parent reply	other threads:[~2024-04-15 15:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 15:56 [PATCH 1/7] [gdb/testsuite] Factor out proc get_portnum Tom de Vries
2024-04-15 15:56 ` [PATCH 2/7] [gdb/testsuite] Make portnum a persistent global Tom de Vries
2024-05-03 20:20   ` Tom Tromey
2024-04-15 15:56 ` [PATCH 3/7] [gdb/testsuite] Factor out proc with_lock Tom de Vries
2024-05-03 20:22   ` Tom Tromey
2024-04-15 15:56 ` [PATCH 4/7] [gdb/testsuite] Factor out proc lock_dir Tom de Vries
2024-05-03 20:23   ` Tom Tromey
2024-04-15 15:56 ` [PATCH 5/7] [gdb/testsuite] Move gpu-parallel.lock to cache dir Tom de Vries
2024-05-03 20:25   ` Tom Tromey
2024-04-15 15:56 ` [PATCH 6/7] [gdb/testsuite] Use unique portnum in parallel testing Tom de Vries
2024-05-03 20:27   ` Tom Tromey
2024-04-15 15:56 ` Tom de Vries [this message]
2024-05-03 20:30   ` [PATCH 7/7] [gdb/testsuite] Use unique portnum in parallel testing (check//% case) Tom Tromey
2024-05-04  7:48     ` Tom de Vries
2024-05-03 20:19 ` [PATCH 1/7] [gdb/testsuite] Factor out proc get_portnum Tom Tromey

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