From: Bruno Haible Date: Mon, 3 Jun 2024 13:34:21 +0000 (+0200) Subject: dprintf-posix tests: Skip the memory leak test on macOS. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=0c841a961b486e5de2a8da9c901ea07dca6f52d1;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index f15f96e2cf..713edc13eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2024-06-03 Bruno Haible + + 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 pthread-* tests, regex tests: Prepare for use of 'alarm'. diff --git a/tests/test-dprintf-posix2.c b/tests/test-dprintf-posix2.c index 3263072ebd..6e01d7e782 100644 --- a/tests/test-dprintf-posix2.c +++ b/tests/test-dprintf-posix2.c @@ -20,6 +20,20 @@ #include +#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 */ diff --git a/tests/test-dprintf-posix2.sh b/tests/test-dprintf-posix2.sh index 12e25bc318..2827f4a209 100755 --- a/tests/test-dprintf-posix2.sh +++ b/tests/test-dprintf-posix2.sh @@ -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