]> Savannah Git Hosting - gnulib.git/commitdiff
execute tests: Avoid test failure on macOS 14.
authorBruno Haible <bruno@clisp.org>
Fri, 26 Jan 2024 00:12:08 +0000 (01:12 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Jan 2024 17:36:34 +0000 (18:36 +0100)
Reported by Guangyu Li <gl343@cornell.edu> in
<https://lists.gnu.org/archive/html/bug-gettext/2024-01/msg00006.html>.

* 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.

ChangeLog
tests/test-execute-child.c
tests/test-execute-main.c

index f984973eca5861e45f3ffa3b460412156cde8d5a..867365ac54dc847863bb50601f57747d8d956204 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-25  Bruno Haible  <bruno@clisp.org>
+
+       execute tests: Avoid test failure on macOS 14.
+       Reported by Guangyu Li <gl343@cornell.edu> in
+       <https://lists.gnu.org/archive/html/bug-gettext/2024-01/msg00006.html>.
+       * 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  <bruno@clisp.org>
 
        Resolve conflicts for functions introduced in Android API level 35.
index 53d0252a7f60fa264335d604396a4e5c491d99cf..7660c7cc187b0212bfdd3a0c916e6dffaa9e9df5 100644 (file)
@@ -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:
index afd6a749bdcaa5530494ba7592521ba4cb189283..67c00ee6f3455cc2335ca3f73f5b2a1911e09222 100644 (file)
@@ -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);