public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: tests/
Date: Thu, 21 Oct 2021 02:48:00 +0000 (UTC)	[thread overview]
Message-ID: <1634784059.ac981df3077edde8bfc95dc54d8a82943986042f.vapier@gentoo> (raw)

commit:     ac981df3077edde8bfc95dc54d8a82943986042f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 21 02:40:59 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Oct 21 02:40:59 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=ac981df3

tests: handle fd leakage from GNU make jobservers

Current versions of GNU make (at least v4.3) seem to be leaking its
jobserver fds to children which breaks some tests that expect fd 3
and higher to be free.  Add some startup logic to clean those to fix
`make -j check` failures.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 tests/atlocal.in  | 18 ++++++++++++++++++
 tests/script-1.sh |  5 ++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/tests/atlocal.in b/tests/atlocal.in
index 91b41b2..e8213c0 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -24,5 +24,23 @@ export SANDBOX_VERBOSE=0
 # If the terminal has this flag set, the tests get all messed up.
 stty -tostop 2>/dev/null || :
 
+# Some tests want this internal path.
+for devfd in /proc/self/fd /dev/fd ; do
+	[ -e "${devfd}" ] && break
+done
+
+# GNU make likes to leak fds when using jobservers (i.e. using -j).
+case "${MAKEFLAGS}" in
+*--jobserver-auth=*)
+	flags=${MAKEFLAGS#*--jobserver-auth=}
+	flags=${flags%% *}
+	for fd in $(echo "${flags}" | tr ',' ' ') ; do
+		if [ -e "${devfd}/${fd}" ] ; then
+			eval "exec ${fd}>&-"
+		fi
+	done
+	;;
+esac
+
 # This script must finish with ($? == 0) else the autotest runner gets upset.
 :

diff --git a/tests/script-1.sh b/tests/script-1.sh
index 3ac6252..8b18114 100755
--- a/tests/script-1.sh
+++ b/tests/script-1.sh
@@ -1,5 +1,8 @@
 #!/bin/sh
 # http://bugs.gentoo.org/257418
 [ "${at_xfail}" = "yes" ] && exit 77 # see script-0
-(>/dev/fd/3)
+(
+cd "${devfd}"
+>3
+)
 exit 0


             reply	other threads:[~2021-10-21  2:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  2:48 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-07-01 23:52 [gentoo-commits] proj/sandbox:master commit in: tests/ Mike Gilbert
2023-06-22 13:54 Mike Gilbert
2023-06-22 13:54 Mike Gilbert
2021-11-03 19:13 Mike Frysinger
2021-10-24  0:54 Mike Frysinger
2021-10-23 22:19 Mike Frysinger
2021-10-22  7:21 Michał Górny
2021-10-22  4:54 Mike Frysinger
2021-10-22  4:15 Mike Frysinger
2021-10-18  5:21 Mike Frysinger
2020-05-31 10:52 Michał Górny
2019-06-27 21:41 Sergei Trofimovich
2018-02-19  5:50 Michał Górny
2016-03-29 12:24 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-12-20 21:33 Mike Frysinger
2015-09-28 20:17 Mike Frysinger
2015-09-27  6:13 Mike Frysinger
2015-09-11  7:53 Mike Frysinger
2015-09-11  7:53 Mike Frysinger
2012-12-24 23:58 Mike Frysinger
2012-11-26 10:10 Mike Frysinger
2012-06-24  6:14 Mike Frysinger
2012-06-23 21:27 Mike Frysinger
2012-03-06 19:00 Mike Frysinger
2012-03-05  7:01 Mike Frysinger
2012-03-05  7:01 Mike Frysinger
2011-07-08 19:53 Mike Frysinger
2011-07-04 23:06 Mike Frysinger
2011-07-04 23:06 Mike Frysinger

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=1634784059.ac981df3077edde8bfc95dc54d8a82943986042f.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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