From: Bruno Haible Date: Thu, 3 Dec 2020 20:00:35 +0000 (+0100) Subject: fprintf-posix-tests: Avoid a test failure on macOS 10.13. X-Git-Tag: v1.0~3430 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=a080bb306f0de925bacb89febf2ca9379b3a25a2;p=gnulib.git fprintf-posix-tests: Avoid a test failure on macOS 10.13. Reported by Martin Storsjö in . * 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/ChangeLog b/ChangeLog index d5ee34f1cd..6ff86eb0af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2020-12-03 Bruno Haible + + fprintf-posix-tests: Avoid a test failure on macOS 10.13. + Reported by Martin Storsjö in + . + * 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 canonicalize: refactor can_mode flag diff --git a/tests/test-fprintf-posix3.c b/tests/test-fprintf-posix3.c index 67bcb92db4..5521839a39 100644 --- a/tests/test-fprintf-posix3.c +++ b/tests/test-fprintf-posix3.c @@ -20,6 +20,24 @@ #include +#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 #include #include @@ -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 351d375942..96609c7f2f 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