mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2026-10-24 00:48:56 +03:00
tests: prefer GCC sanitization macros
* tests/test-c-stack.c, tests/test-calloc-posix.c: * tests/test-dprintf-posix2.c, tests/test-explicit_bzero.c: * tests/test-fprintf-posix3.c, tests/test-free.c: * tests/test-malloc-posix.c, tests/test-memset_explicit.c: * tests/test-reallocarray.c, tests/test-sigsegv-catch-stackoverflow1.c: * tests/test-sigsegv-catch-stackoverflow2.c: Simplify now that gnulib-common.m4 supports GCC-like macros.
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
2026-09-23 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
tests: prefer GCC sanitization macros
|
||||
* tests/test-c-stack.c, tests/test-calloc-posix.c:
|
||||
* tests/test-dprintf-posix2.c, tests/test-explicit_bzero.c:
|
||||
* tests/test-fprintf-posix3.c, tests/test-free.c:
|
||||
* tests/test-malloc-posix.c, tests/test-memset_explicit.c:
|
||||
* tests/test-reallocarray.c, tests/test-sigsegv-catch-stackoverflow1.c:
|
||||
* tests/test-sigsegv-catch-stackoverflow2.c:
|
||||
Simplify now that gnulib-common.m4 supports GCC-like macros.
|
||||
|
||||
getdelim: check for other sanitizers
|
||||
* lib/stdio.in.h (__has_feature): Remove.
|
||||
(getdelim): Also check for other relevant sanitizers.
|
||||
|
||||
@@ -31,10 +31,7 @@
|
||||
#include "macros.h"
|
||||
|
||||
/* Skip this test when an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
||||
@@ -25,11 +25,6 @@
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
/* For determining whether an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
|
||||
/* Work around clang bug
|
||||
<https://github.com/llvm/llvm-project/issues/114772>. */
|
||||
void *(*volatile my_calloc) (size_t, size_t) = calloc;
|
||||
@@ -39,7 +34,7 @@ void *(*volatile my_calloc) (size_t, size_t) = calloc;
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) \
|
||||
#if defined __SANITIZE_ADDRESS__ \
|
||||
|| defined __FILC__
|
||||
/* Avoid a "filc safety error: attempt to allocate object that is too big" */
|
||||
fputs ("Skipping test: large allocations are unsupported\n", stderr);
|
||||
|
||||
@@ -35,10 +35,7 @@ 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)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
|
||||
int
|
||||
main ()
|
||||
|
||||
@@ -64,10 +64,7 @@ test_static (void)
|
||||
a "heap use after free".
|
||||
Skip it also with Fil-C, because that environment does not support the
|
||||
conversion of uintptr_t to a pointer or the re-use of a freed pointer. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) \
|
||||
#if defined __SANITIZE_ADDRESS__ \
|
||||
|| defined __FILC__
|
||||
|
||||
static void
|
||||
@@ -150,10 +147,7 @@ test_heap (void)
|
||||
|
||||
/* Skip this part when an address sanitizer is in use, because it would report
|
||||
a "stack use after return". */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
|
||||
static void
|
||||
test_stack (void)
|
||||
|
||||
@@ -39,10 +39,7 @@ 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)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
|
||||
int
|
||||
main ()
|
||||
|
||||
@@ -92,10 +92,7 @@ main ()
|
||||
|
||||
/* Skip this test when an address sanitizer is in use, because it would report
|
||||
a "heap buffer overflow". */
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(a) 0
|
||||
#endif
|
||||
#if !(defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer))
|
||||
#ifndef __SANITIZE_ADDRESS__
|
||||
/* Test a less common code path.
|
||||
When malloc() is based on mmap(), free() can sometimes call munmap().
|
||||
munmap() usually succeeds, but fails in a particular situation: when
|
||||
|
||||
@@ -25,11 +25,6 @@
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
/* For determining whether an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
|
||||
/* Work around clang bug
|
||||
<https://github.com/llvm/llvm-project/issues/114772>. */
|
||||
void *(*volatile my_malloc) (size_t) = malloc;
|
||||
@@ -39,7 +34,7 @@ void *(*volatile my_malloc) (size_t) = malloc;
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) \
|
||||
#if defined __SANITIZE_ADDRESS__ \
|
||||
|| defined __FILC__
|
||||
/* Avoid a "filc safety error: attempt to allocate object that is too big" */
|
||||
fputs ("Skipping test: large allocations are unsupported\n", stderr);
|
||||
|
||||
@@ -101,10 +101,7 @@ test_static (void)
|
||||
a "heap use after free".
|
||||
Skip it also with Fil-C, because that environment does not support the
|
||||
conversion of uintptr_t to a pointer or the re-use of a freed pointer. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) \
|
||||
#if defined __SANITIZE_ADDRESS__ \
|
||||
|| defined __FILC__
|
||||
|
||||
static void
|
||||
@@ -187,10 +184,7 @@ test_heap (void)
|
||||
|
||||
/* Skip this part when an address sanitizer is in use, because it would report
|
||||
a "stack use after return". */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
|
||||
static void
|
||||
test_stack (void)
|
||||
|
||||
@@ -28,11 +28,6 @@ SIGNATURE_CHECK (reallocarray, void *, (void *, size_t, size_t));
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
/* For determining whether an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
|
||||
/* Work around clang bug
|
||||
<https://github.com/llvm/llvm-project/issues/114772>. */
|
||||
void *(*volatile my_reallocarray) (void *, size_t, size_t) = reallocarray;
|
||||
@@ -42,7 +37,7 @@ void *(*volatile my_reallocarray) (void *, size_t, size_t) = reallocarray;
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer) \
|
||||
#if defined __SANITIZE_ADDRESS__ \
|
||||
|| defined __FILC__
|
||||
/* Avoid a "filc safety error: attempt to allocate object that is too big" */
|
||||
fputs ("Skipping test: large allocations are unsupported\n", stderr);
|
||||
|
||||
@@ -33,10 +33,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
/* Skip this test when an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
# undef HAVE_STACK_OVERFLOW_RECOVERY
|
||||
#endif
|
||||
|
||||
|
||||
@@ -34,10 +34,7 @@
|
||||
#include <limits.h>
|
||||
|
||||
/* Skip this test when an address sanitizer is in use. */
|
||||
#ifndef __has_feature
|
||||
# define __has_feature(a) 0
|
||||
#endif
|
||||
#if defined __SANITIZE_ADDRESS__ || __has_feature (address_sanitizer)
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
# undef HAVE_STACK_OVERFLOW_RECOVERY
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user