diff options
author | Bruno Haible <bruno@clisp.org> | 2021-04-08 01:37:05 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2021-04-08 01:37:05 +0200 |
commit | 2a7948aad478bcdcd2472b380054f84e7360ec10 (patch) | |
tree | 40c686f26f7a1bf17c7f425eef1bbbc9477d5616 /tests/test-execute-main.c | |
parent | dbb1926d7d0ff41c35ae05bcf3ee03a2c6b1377b (diff) | |
download | gnulib-2a7948aad478bcdcd2472b380054f84e7360ec10.tar.gz |
execute tests: Avoid test failure in certain environments.
Reported by Dmitry V. Levin <ldv@altlinux.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00082.html>.
* tests/test-execute-main.c (main): Close file descriptors 3..19.
* tests/test-execute-child.c (main): Remove NetBSD workaround.
* modules/execute-tests (configure.ac): Test for close_range function.
Diffstat (limited to 'tests/test-execute-main.c')
-rw-r--r-- | tests/test-execute-main.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c index 39e24af125..944dcd1ee2 100644 --- a/tests/test-execute-main.c +++ b/tests/test-execute-main.c @@ -58,6 +58,31 @@ main (int argc, char *argv[]) char *prog_path = argv[1]; const char *progname = "test-execute-child"; int test = atoi (argv[2]); + + switch (test) + { + case 14: + case 15: + case 16: + /* Close file descriptors that have been inherited from the parent + process and that would cause failures in test-execute-child.c. + Such file descriptors have been seen: + - with GNU make, when invoked as 'make -j N' with j > 1, + - in some versions of the KDE desktop environment, + - on NetBSD. + */ + #if HAVE_CLOSE_RANGE + if (close_range (3, 20 - 1, 0) < 0) + #endif + { + int fd; + for (fd = 3; fd < 20; fd++) + close (fd); + } + default: + break; + } + switch (test) { case 0: |