bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: "Martin Storsjö" <martin@martin.st>
Subject: Re: fprintf-posix on macOS
Date: Thu, 03 Dec 2020 21:59:22 +0100	[thread overview]
Message-ID: <1805336.4ARsbI03nN@omega> (raw)
In-Reply-To: <alpine.DEB.2.23.453.2012011509530.4295@cone.martin.st>

Martin Storsjö wrote:
> FAIL: test-fprintf-posix3.sh

This patch fixes it. It now produces a diagnostic
"Skipping test: cannot trust address space size on this platform"


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.

diff --git a/tests/test-fprintf-posix3.c b/tests/test-fprintf-posix3.c
index 67bcb92..5521839 100644
--- a/tests/test-fprintf-posix3.c
+++ b/tests/test-fprintf-posix3.c
@@ -20,6 +20,24 @@
 
 #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 */
diff --git a/tests/test-fprintf-posix3.sh b/tests/test-fprintf-posix3.sh
index 351d375..96609c7 100755
--- a/tests/test-fprintf-posix3.sh
+++ b/tests/test-fprintf-posix3.sh
@@ -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



  parent reply	other threads:[~2020-12-03 20:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 13:14 Issues with posix functions on modern macOS/Xcode Martin Storsjö
2020-12-01 13:50 ` Martin Storsjö
2020-12-01 18:58 ` Bruno Haible
2020-12-02 18:56 ` Bruno Haible
2021-01-02 20:43   ` Bruno Haible
2021-03-21  2:57     ` Bruno Haible
2021-03-21 13:58       ` Bruno Haible
2020-12-02 21:52 ` strsignal on macOS Bruno Haible
2020-12-03 20:59 ` Bruno Haible [this message]
2020-12-04 23:24 ` utime " Bruno Haible
2021-01-02 16:03 ` renameatu: Fix test failures " Bruno Haible
2021-01-02 18:06 ` utimens: " Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1805336.4ARsbI03nN@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=martin@martin.st \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).