1 |
commit: ac981df3077edde8bfc95dc54d8a82943986042f |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 21 02:40:59 2021 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 21 02:40:59 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=ac981df3 |
7 |
|
8 |
tests: handle fd leakage from GNU make jobservers |
9 |
|
10 |
Current versions of GNU make (at least v4.3) seem to be leaking its |
11 |
jobserver fds to children which breaks some tests that expect fd 3 |
12 |
and higher to be free. Add some startup logic to clean those to fix |
13 |
`make -j check` failures. |
14 |
|
15 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
16 |
|
17 |
tests/atlocal.in | 18 ++++++++++++++++++ |
18 |
tests/script-1.sh | 5 ++++- |
19 |
2 files changed, 22 insertions(+), 1 deletion(-) |
20 |
|
21 |
diff --git a/tests/atlocal.in b/tests/atlocal.in |
22 |
index 91b41b2..e8213c0 100644 |
23 |
--- a/tests/atlocal.in |
24 |
+++ b/tests/atlocal.in |
25 |
@@ -24,5 +24,23 @@ export SANDBOX_VERBOSE=0 |
26 |
# If the terminal has this flag set, the tests get all messed up. |
27 |
stty -tostop 2>/dev/null || : |
28 |
|
29 |
+# Some tests want this internal path. |
30 |
+for devfd in /proc/self/fd /dev/fd ; do |
31 |
+ [ -e "${devfd}" ] && break |
32 |
+done |
33 |
+ |
34 |
+# GNU make likes to leak fds when using jobservers (i.e. using -j). |
35 |
+case "${MAKEFLAGS}" in |
36 |
+*--jobserver-auth=*) |
37 |
+ flags=${MAKEFLAGS#*--jobserver-auth=} |
38 |
+ flags=${flags%% *} |
39 |
+ for fd in $(echo "${flags}" | tr ',' ' ') ; do |
40 |
+ if [ -e "${devfd}/${fd}" ] ; then |
41 |
+ eval "exec ${fd}>&-" |
42 |
+ fi |
43 |
+ done |
44 |
+ ;; |
45 |
+esac |
46 |
+ |
47 |
# This script must finish with ($? == 0) else the autotest runner gets upset. |
48 |
: |
49 |
|
50 |
diff --git a/tests/script-1.sh b/tests/script-1.sh |
51 |
index 3ac6252..8b18114 100755 |
52 |
--- a/tests/script-1.sh |
53 |
+++ b/tests/script-1.sh |
54 |
@@ -1,5 +1,8 @@ |
55 |
#!/bin/sh |
56 |
# http://bugs.gentoo.org/257418 |
57 |
[ "${at_xfail}" = "yes" ] && exit 77 # see script-0 |
58 |
-(>/dev/fd/3) |
59 |
+( |
60 |
+cd "${devfd}" |
61 |
+>3 |
62 |
+) |
63 |
exit 0 |