]> Savannah Git Hosting - gnulib.git/commitdiff
dprintf-posix, fprintf-posix tests: Avoid test failures with ASAN.
authorBruno Haible <bruno@clisp.org>
Thu, 9 May 2024 10:56:55 +0000 (12:56 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 17 May 2024 23:08:07 +0000 (01:08 +0200)
* tests/test-dprintf-posix2.c (main): Skip the test if ASAN is enabled.
* tests/test-fprintf-posix3.c (main): Likewise.
* tests/test-dprintf-posix2.sh: Update.
* tests/test-fprintf-posix3.sh: Likewise.

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

index edc5e65949a28dd0125105a4ae0f87f048207f4c..2ce25bdf0e4c151379a796b718ee6775cb72d77d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-05-09  Bruno Haible  <bruno@clisp.org>
+
+       dprintf-posix, fprintf-posix tests: Avoid test failures with ASAN.
+       * tests/test-dprintf-posix2.c (main): Skip the test if ASAN is enabled.
+       * tests/test-fprintf-posix3.c (main): Likewise.
+       * tests/test-dprintf-posix2.sh: Update.
+       * tests/test-fprintf-posix3.sh: Likewise.
+
 2024-05-08  Bruno Haible  <bruno@clisp.org>
 
        sigsegv, c-stack tests: Avoid test failures with ASAN.
index 8eb86437627d50be84c3bd9dce420bb5a5b0c128..3263072ebd2e696e52a2c26350fc6623c3d69c44 100644 (file)
 
 #include <stdio.h>
 
+/* Skip this test when an address sanitizer is in use, since it would fail.  */
+#ifndef __has_feature
+# define __has_feature(a) 0
+#endif
+#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+
+int
+main ()
+{
+  fprintf (stderr, "Skipping test: address sanitizer's malloc behaves differently\n");
+  return 80;
+}
+
+#else
+
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -92,7 +107,7 @@ main (int argc, char *argv[])
       if (memory == NULL)
         return 1;
       memset (memory, 17, MAX_ALLOC_TOTAL);
-      result = 80;
+      result = 81;
     }
   else
     {
@@ -117,3 +132,5 @@ main (int argc, char *argv[])
 
   return result;
 }
+
+#endif /* ! address sanitizer enabled */
index 7a548188f31a873e23bd0676ffc1128a43471467..12e25bc3182b3ee9ad081642eef78213249e77bd 100755 (executable)
@@ -4,7 +4,7 @@
 
 (${CHECKER} ./test-dprintf-posix2${EXEEXT} 0
  result=$?
- if test $result != 77 && test $result != 79 && test $result != 80; then result=1; fi
+ if test $result != 77 && test $result != 79 && test $result != 80 && test $result != 81; then result=1; fi
  exit $result
 ) 2>/dev/null
 malloc_result=$?
@@ -16,6 +16,10 @@ if test $malloc_result = 79; then
   echo "Skipping test: cannot trust address space size when running under QEMU"
   exit 77
 fi
+if test $malloc_result = 80; then
+  echo "Skipping test: address sanitizer's malloc behaves differently"
+  exit 77
+fi
 
 ${CHECKER} ./test-dprintf-posix2${EXEEXT} 1 > /dev/null
 result=$?
@@ -27,7 +31,7 @@ if test $result != 0; then
   exit 1
 fi
 
-if test $malloc_result = 80; then
+if test $malloc_result = 81; then
   echo "Skipping test: get_rusage_as() doesn't work"
   exit 77
 fi
index 3a2ba7f9266e549acd52212014cb987d2a9cf7ad..f2d31e71ac6252060e0386f78f95787f37d85aec 100644 (file)
@@ -38,6 +38,21 @@ main ()
 
 #else
 
+/* Skip this test when an address sanitizer is in use, since it would fail.  */
+#ifndef __has_feature
+# define __has_feature(a) 0
+#endif
+#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
+
+int
+main ()
+{
+  fprintf (stderr, "Skipping test: address sanitizer's malloc behaves differently\n");
+  return 80;
+}
+
+#else
+
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -109,7 +124,7 @@ main (int argc, char *argv[])
       if (memory == NULL)
         return 1;
       memset (memory, 17, MAX_ALLOC_TOTAL);
-      result = 80;
+      result = 81;
     }
   else
     {
@@ -135,4 +150,5 @@ main (int argc, char *argv[])
   return result;
 }
 
+#endif /* ! address sanitizer enabled */
 #endif /* !macOS */
index a79273ee2e111b99d0332832363e4d6917bd9a9d..2fe1f27d4084ca0674fd889374de7d6114fd1f86 100755 (executable)
@@ -4,7 +4,7 @@
 
 (${CHECKER} ./test-fprintf-posix3${EXEEXT} 0
  result=$?
- if test $result != 77 && test $result != 78 && test $result != 79 && test $result != 80; 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=$?
@@ -20,6 +20,10 @@ if test $malloc_result = 79; then
   echo "Skipping test: cannot trust address space size when running under QEMU"
   exit 77
 fi
+if test $malloc_result = 80; then
+  echo "Skipping test: address sanitizer's malloc behaves differently"
+  exit 77
+fi
 
 ${CHECKER} ./test-fprintf-posix3${EXEEXT} 1 > /dev/null
 result=$?