]> Savannah Git Hosting - gnulib.git/commitdiff
fprintf-posix-tests: Avoid a test failure on macOS 10.13.
authorBruno Haible <bruno@clisp.org>
Thu, 3 Dec 2020 20:00:35 +0000 (21:00 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 3 Dec 2020 20:58:21 +0000 (21:58 +0100)
Reported by Martin Storsjö <martin@martin.st> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.

* tests/test-fprintf-posix3.c: Skip the test on macOS.
(main): Return a different exit code at each point. Allow 100 KB extra
memory consumption.
* tests/test-fprintf-posix3.sh: Update. Remove the "get_rusage_as()
doesn't work" diagnostic.

ChangeLog
tests/test-fprintf-posix3.c
tests/test-fprintf-posix3.sh

index d5ee34f1cd2682f58a607a99fa8ee7b2719888ec..6ff86eb0af9237c20bfb394bc595d813c49c1971 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-12-03  Bruno Haible  <bruno@clisp.org>
+
+       fprintf-posix-tests: Avoid a test failure on macOS 10.13.
+       Reported by Martin Storsjö <martin@martin.st> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00003.html>.
+       * tests/test-fprintf-posix3.c: Skip the test on macOS.
+       (main): Return a different exit code at each point. Allow 100 KB extra
+       memory consumption.
+       * tests/test-fprintf-posix3.sh: Update. Remove the "get_rusage_as()
+       doesn't work" diagnostic.
+
 2020-12-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        canonicalize: refactor can_mode flag
index 67bcb92db4999e3705c96dd712089feefe076274..5521839a393c9520840bcf93c9e210170563c791 100644 (file)
 
 #include <stdio.h>
 
+#if defined __APPLE__ && defined __MACH__                            /* macOS */
+
+/* On macOS 10.13, this test fails, because the address space size increases
+   by 10 MB to 42 MB during the test's execution.  But it's not a malloc
+   leak, as can be seen by running the 'leaks' program.  And it does not fail
+   if the test's output is redirected to /dev/null.  Probably piping a lot
+   of output to stdout, when not redirected to /dev/null, allocates intermediate
+   buffers in the virtual address space.  */
+
+int
+main ()
+{
+  fprintf (stderr, "Skipping test: cannot trust address space size on this platform\n");
+  return 78;
+}
+
+#else
+
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -84,7 +102,7 @@ main (int argc, char *argv[])
       if (memory == NULL)
         return 1;
       memset (memory, 17, MAX_ALLOC_TOTAL);
-      result = 78;
+      result = 80;
     }
   else
     {
@@ -98,14 +116,16 @@ main (int argc, char *argv[])
              but should not result in a permanent memory allocation.  */
           if (fprintf (stdout, "%011000d\n", 17) == -1
               && errno == ENOMEM)
-            return 1;
+            return 2;
         }
 
       result = 0;
     }
 
-  if (get_rusage_as () > initial_rusage_as + MAX_ALLOC_TOTAL)
-    return 1;
+  if (get_rusage_as () > initial_rusage_as + MAX_ALLOC_TOTAL + 100000)
+    return 3;
 
   return result;
 }
+
+#endif /* !macOS */
index 351d37594258e81146bc9cbf3fd82cfadbb551e3..96609c7f2f6da46f6a0527739ecbc7beb34eef43 100755 (executable)
@@ -4,7 +4,7 @@
 
 (${CHECKER} ./test-fprintf-posix3${EXEEXT} 0
  result=$?
- if test $result != 77 && test $result != 78; then result=1; fi
+ if test $result != 77 && test $result != 78 && test $result != 80; then result=1; fi
  exit $result
 ) 2>/dev/null
 malloc_result=$?
@@ -12,6 +12,10 @@ if test $malloc_result = 77; then
   echo "Skipping test: no way to determine address space size"
   exit 77
 fi
+if test $malloc_result = 78; then
+  echo "Skipping test: cannot trust address space size on this platform"
+  exit 77
+fi
 
 ${CHECKER} ./test-fprintf-posix3${EXEEXT} 1 > /dev/null
 result=$?
@@ -23,9 +27,4 @@ if test $result != 0; then
   exit 1
 fi
 
-if test $malloc_result = 78; then
-  echo "Skipping test: get_rusage_as() doesn't work"
-  exit 77
-fi
-
 exit 0