]> Savannah Git Hosting - gnulib.git/commitdiff
dprintf-posix tests: Skip the memory leak test on macOS.
authorBruno Haible <bruno@clisp.org>
Mon, 3 Jun 2024 13:34:21 +0000 (15:34 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 23:21:46 +0000 (01:21 +0200)
* tests/test-dprintf-posix2.c: Skip the test on macOS.
(main): Return a different exit code at each point. Allow 100 KB extra
memory consumption.
* tests/test-dprintf-posix2.sh: Update.

ChangeLog
tests/test-dprintf-posix2.c
tests/test-dprintf-posix2.sh

index cc82e9f0f57f9cfa9efc58c4abad89f49d227b2b..f85987ccb69dbe793f5f86b26b6622b2c0bf2157 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-06-03  Bruno Haible  <bruno@clisp.org>
+
+       dprintf-posix tests: Skip the memory leak test on macOS.
+       * tests/test-dprintf-posix2.c: Skip the test on macOS.
+       (main): Return a different exit code at each point. Allow 100 KB extra
+       memory consumption.
+       * tests/test-dprintf-posix2.sh: Update.
+
 2024-06-03  Bruno Haible  <bruno@clisp.org>
 
        pthread-* tests, regex tests: Prepare for use of 'alarm'.
index 3263072ebd2e696e52a2c26350fc6623c3d69c44..6e01d7e782ea1012128e709e1b632ec86217a413 100644 (file)
 
 #include <stdio.h>
 
+#if defined __APPLE__ && defined __MACH__                            /* macOS */
+
+/* On macOS 11, 12, 13, 14, this test sometimes fails.  Probably for the same
+   reason as mentioned in the comment in test-fprintf-posix3.c.  */
+
+int
+main ()
+{
+  fprintf (stderr, "Skipping test: cannot trust address space size on this platform\n");
+  return 78;
+}
+
+#else
+
 /* Skip this test when an address sanitizer is in use, since it would fail.  */
 #ifndef __has_feature
 # define __has_feature(a) 0
@@ -121,16 +135,17 @@ main (int argc, char *argv[])
              but should not result in a permanent memory allocation.  */
           if (dprintf (STDOUT_FILENO, "%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 /* ! address sanitizer enabled */
+#endif /* !macOS */
index 12e25bc3182b3ee9ad081642eef78213249e77bd..2827f4a209210fa06ba2e6e2260bea6ae3f5ee6e 100755 (executable)
@@ -4,7 +4,7 @@
 
 (${CHECKER} ./test-dprintf-posix2${EXEEXT} 0
  result=$?
- if test $result != 77 && test $result != 79 && test $result != 80 && test $result != 81; then result=1; fi
+ if test $result != 77 && test $result != 78 && test $result != 79 && test $result != 80 && test $result != 81; 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
 if test $malloc_result = 79; then
   echo "Skipping test: cannot trust address space size when running under QEMU"
   exit 77