aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-10-20 22:40:59 -0400
committerMike Frysinger <vapier@gentoo.org>2021-10-20 22:40:59 -0400
commitac981df3077edde8bfc95dc54d8a82943986042f (patch)
tree74569a6830b5c713466c3b67ec3994d4403045d6 /tests
parentlibsandbox: drop redundant regs ptrace lookup (diff)
downloadsandbox-ac981df3077edde8bfc95dc54d8a82943986042f.tar.gz
sandbox-ac981df3077edde8bfc95dc54d8a82943986042f.tar.bz2
sandbox-ac981df3077edde8bfc95dc54d8a82943986042f.zip
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@gentoo.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/atlocal.in18
-rwxr-xr-xtests/script-1.sh5
2 files changed, 22 insertions, 1 deletions
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