From: Bruno Haible Date: Fri, 26 Jan 2024 00:12:08 +0000 (+0100) Subject: execute tests: Avoid test failure on macOS 14. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c269c5d95881cee2851392c664d0da0d117da477;p=gnulib.git execute tests: Avoid test failure on macOS 14. Reported by Guangyu Li in . * tests/test-execute-main.c (main): In the tests 17, 18, 19, 20, use the file descriptors 15, 16 instead of 10, 11, respectively. * tests/test-execute-child.c (main): Likewise. --- diff --git a/ChangeLog b/ChangeLog index f984973eca..867365ac54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-01-25 Bruno Haible + + execute tests: Avoid test failure on macOS 14. + Reported by Guangyu Li in + . + * tests/test-execute-main.c (main): In the tests 17, 18, 19, 20, use the + file descriptors 15, 16 instead of 10, 11, respectively. + * tests/test-execute-child.c (main): Likewise. + 2024-01-25 Bruno Haible Resolve conflicts for functions introduced in Android API level 35. diff --git a/tests/test-execute-child.c b/tests/test-execute-child.c index 53d0252a7f..7660c7cc18 100644 --- a/tests/test-execute-child.c +++ b/tests/test-execute-child.c @@ -1,5 +1,5 @@ /* Child program invoked by test-execute-main. - Copyright (C) 2009-2023 Free Software Foundation, Inc. + Copyright (C) 2009-2024 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -199,14 +199,14 @@ main (int argc, char *argv[]) including the file position. */ { char buf[6]; - int n = read (10, buf, sizeof (buf)); + int n = read (15, buf, sizeof (buf)); return !(n == 4 && memcmp (buf, "obar", 4) == 0); } case 18: /* Check that file descriptors >= 3, open for writing, can be inherited, including the file position. */ { - int n = write (10, "bar", 3); + int n = write (15, "bar", 3); return !(n == 3); } case 19: @@ -217,9 +217,9 @@ main (int argc, char *argv[]) isatty() property, part 2 (character devices). */ { #if defined _WIN32 && ! defined __CYGWIN__ - return 4 + 2 * (_isatty (10) != 0) + (_isatty (11) != 0); + return 4 + 2 * (_isatty (15) != 0) + (_isatty (16) != 0); #else - return 4 + 2 * (isatty (10) != 0) + (isatty (11) != 0); + return 4 + 2 * (isatty (15) != 0) + (isatty (16) != 0); #endif } case 21: diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c index afd6a749bd..67c00ee6f3 100644 --- a/tests/test-execute-main.c +++ b/tests/test-execute-main.c @@ -1,5 +1,5 @@ /* Test of execute. - Copyright (C) 2020-2023 Free Software Foundation, Inc. + Copyright (C) 2020-2024 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -82,7 +82,8 @@ main (int argc, char *argv[]) - with GNU make, when invoked as 'make -j N' with j > 1, - in some versions of the KDE desktop environment, - on NetBSD, - - in MacPorts with the "trace mode" enabled. + - in MacPorts with the "trace mode" enabled, + - on macOS 14. */ #if HAVE_CLOSE_RANGE if (close_range (3, 20 - 1, 0) < 0) @@ -363,11 +364,11 @@ main (int argc, char *argv[]) ASSERT (fclose (fp) == 0); int fd = open (BASE ".tmp", O_RDONLY); - ASSERT (fd >= 0 && fd < 10); + ASSERT (fd >= 0 && fd < 15); - ASSERT (dup2 (fd, 10) >= 0); + ASSERT (dup2 (fd, 15) >= 0); close (fd); - fd = 10; + fd = 15; char buf[2]; ASSERT (read (fd, buf, sizeof (buf)) == sizeof (buf)); @@ -388,11 +389,11 @@ main (int argc, char *argv[]) including the file position. */ remove (BASE ".tmp"); int fd = open (BASE ".tmp", O_RDWR | O_CREAT | O_TRUNC, 0600); - ASSERT (fd >= 0 && fd < 10); + ASSERT (fd >= 0 && fd < 15); - ASSERT (dup2 (fd, 10) >= 0); + ASSERT (dup2 (fd, 15) >= 0); close (fd); - fd = 10; + fd = 15; ASSERT (write (fd, "Foo", 3) == 3); /* The file position is now 3. */ @@ -420,26 +421,26 @@ main (int argc, char *argv[]) ASSERT (fclose (fp) == 0); int fd_in = open (BASE ".tmp", O_RDONLY); - ASSERT (fd_in >= 0 && fd_in < 10); + ASSERT (fd_in >= 0 && fd_in < 15); int fd_out = open (BASE ".tmp", O_WRONLY | O_APPEND); - ASSERT (fd_out >= 0 && fd_out < 10); + ASSERT (fd_out >= 0 && fd_out < 15); - ASSERT (dup2 (fd_in, 10) >= 0); + ASSERT (dup2 (fd_in, 15) >= 0); close (fd_in); - fd_in = 10; + fd_in = 15; - ASSERT (dup2 (fd_out, 11) >= 0); + ASSERT (dup2 (fd_out, 16) >= 0); close (fd_out); - fd_out = 11; + fd_out = 16; const char *prog_argv[3] = { prog_path, "19", NULL }; int ret = execute (progname, prog_argv[0], prog_argv, NULL, false, false, false, false, true, false, NULL); #if defined _WIN32 && ! defined __CYGWIN__ - ASSERT (ret == 4 + 2 * (_isatty (10) != 0) + (_isatty (11) != 0)); + ASSERT (ret == 4 + 2 * (_isatty (15) != 0) + (_isatty (16) != 0)); #else - ASSERT (ret == 4 + 2 * (isatty (10) != 0) + (isatty (11) != 0)); + ASSERT (ret == 4 + 2 * (isatty (15) != 0) + (isatty (16) != 0)); #endif close (fd_in); @@ -451,19 +452,19 @@ main (int argc, char *argv[]) { /* Check that file descriptors >= 3, when inherited, preserve their isatty() property, part 2 (character devices). */ - ASSERT (dup2 (STDIN_FILENO, 10) >= 0); - int fd_in = 10; + ASSERT (dup2 (STDIN_FILENO, 15) >= 0); + int fd_in = 15; - ASSERT (dup2 (STDOUT_FILENO, 11) >= 0); - int fd_out = 11; + ASSERT (dup2 (STDOUT_FILENO, 16) >= 0); + int fd_out = 16; const char *prog_argv[3] = { prog_path, "20", NULL }; int ret = execute (progname, prog_argv[0], prog_argv, NULL, false, false, false, false, true, false, NULL); #if defined _WIN32 && ! defined __CYGWIN__ - ASSERT (ret == 4 + 2 * (_isatty (10) != 0) + (_isatty (11) != 0)); + ASSERT (ret == 4 + 2 * (_isatty (15) != 0) + (_isatty (16) != 0)); #else - ASSERT (ret == 4 + 2 * (isatty (10) != 0) + (isatty (11) != 0)); + ASSERT (ret == 4 + 2 * (isatty (15) != 0) + (isatty (16) != 0)); #endif close (fd_in);