[PATCH v2 02/10] Add mcheck tests to malloc

DJ Delorie dj@redhat.com
Thu Jul 1 22:14:34 GMT 2021


Siddhesh Poyarekar <siddhesh@sourceware.org> writes:
> diff --git a/Rules b/Rules
> index c6b635c3f7..ba13598df6 100644
> --- a/Rules
> +++ b/Rules
> @@ -155,6 +155,7 @@ xtests: tests $(xtests-special)
>  else
>  tests: $(tests:%=$(objpfx)%.out) $(tests-internal:%=$(objpfx)%.out) \
>         $(tests-container:%=$(objpfx)%.out) \
> +       $(tests-mcheck:%=$(objpfx)%-mcheck.out) \

Ok.

> @@ -166,7 +167,8 @@ ifeq ($(run-built-tests),no)
>  tests-expected =
>  else
>  tests-expected = $(tests) $(tests-internal) $(tests-printers) \
> -	$(tests-container) $(tests-malloc-check:%=%-malloc-check)
> +	$(tests-container) $(tests-malloc-check:%=%-malloc-check) \
> +	$(tests-mcheck:%=%-mcheck)

Ok.

> @@ -192,6 +194,7 @@ else
>  binaries-pie-tests =
>  binaries-pie-notests =
>  endif
> +binaries-mcheck-tests = $(tests-mcheck:%=%-mcheck)

Ok.

> @@ -202,6 +205,7 @@ binaries-static-tests =
>  binaries-static =
>  binaries-pie-tests =
>  binaries-pie-notests =
> +binaries-mcheck-tests =

Ok.

> @@ -226,6 +230,15 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \
>  	$(+link-tests)
>  endif
>  
> +ifneq "$(strip $(binaries-mcheck-tests))" ""
> +$(addprefix $(objpfx),$(binaries-mcheck-tests)): %-mcheck: %.o \
> +  $(link-extra-libs-tests) \
> +  $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
> +  $(common-objpfx)malloc/libmcheck.a \
> +  $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
> +	$(+link-tests)
> +endif
> +

ok

> diff --git a/malloc/Makefile b/malloc/Makefile
> index 9bc2e50a9a..c8256abbbf 100644
> --- a/malloc/Makefile
> +++ b/malloc/Makefile
> @@ -77,6 +77,26 @@ tests-exclude-malloc-check = tst-malloc-check tst-malloc-usable \
>  # Run all tests with MALLOC_CHECK_=3
>  tests-malloc-check = $(filter-out $(tests-exclude-malloc-check),$(tests))
>  
> +# Tests that don't play well with mcheck.  They are either bugs in mcheck or
> +# the tests expect specific internal behavior that is changed due to linking to
> +# libmcheck.a.
> +tests-exclude-mcheck = tst-mallocstate \
> +	tst-safe-linking tst-malloc-usable \
> +	tst-malloc-backtrace \
> +	tst-malloc-fork-deadlock \
> +	tst-malloc-stats-cancellation \
> +	tst-malloc-tcache-leak \
> +	tst-malloc-thread-exit \
> +	tst-malloc-thread-fail \
> +	tst-malloc-usable-static \
> +	tst-malloc-usable-static-tunables \
> +	tst-malloc-usable-tunables \
> +	tst-malloc_info \
> +	tst-memalign \
> +	tst-posix_memalign
> +
> +tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
> +

Ok.

> @@ -118,6 +138,11 @@ $(objpfx)tst-mallocfork3: $(shared-thread-library)
>  $(objpfx)tst-mallocfork3-mcheck: $(shared-thread-library)
>  $(objpfx)tst-malloc-fork-deadlock: $(shared-thread-library)
>  $(objpfx)tst-malloc-stats-cancellation: $(shared-thread-library)
> +$(objpfx)tst-malloc-backtrace-mcheck: $(shared-thread-library)
> +$(objpfx)tst-malloc-thread-exit-mcheck: $(shared-thread-library)
> +$(objpfx)tst-malloc-thread-fail-mcheck: $(shared-thread-library)
> +$(objpfx)tst-malloc-fork-deadlock-mcheck: $(shared-thread-library)
> +$(objpfx)tst-malloc-stats-cancellation-mcheck: $(shared-thread-library)
>  $(objpfx)tst-malloc-backtrace-malloc-check: $(shared-thread-library)
>  $(objpfx)tst-malloc-thread-exit-malloc-check: $(shared-thread-library)
>  $(objpfx)tst-malloc-thread-fail-malloc-check: $(shared-thread-library)
> @@ -253,17 +278,24 @@ $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
>  $(tests:%=$(objpfx)%.o): CPPFLAGS += -DTEST_NO_MALLOPT
>  
>  $(objpfx)tst-interpose-nothread: $(objpfx)tst-interpose-aux-nothread.o
> +$(objpfx)tst-interpose-nothread-mcheck: $(objpfx)tst-interpose-aux-nothread.o
>  $(objpfx)tst-interpose-nothread-malloc-check: \
>  	$(objpfx)tst-interpose-aux-nothread.o
>  $(objpfx)tst-interpose-thread: \
>    $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
> +$(objpfx)tst-interpose-thread-mcheck: \
> +  $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
>  $(objpfx)tst-interpose-thread-malloc-check: \
>    $(objpfx)tst-interpose-aux-thread.o $(shared-thread-library)
>  $(objpfx)tst-interpose-static-nothread: $(objpfx)tst-interpose-aux-nothread.o
> +$(objpfx)tst-interpose-static-nothread-mcheck: \
> +	$(objpfx)tst-interpose-aux-nothread.o
>  $(objpfx)tst-interpose-static-nothread-malloc-check: \
>  	$(objpfx)tst-interpose-aux-nothread.o
>  $(objpfx)tst-interpose-static-thread: \
>    $(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
> +$(objpfx)tst-interpose-static-thread-mcheck: \
> +  $(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
>  $(objpfx)tst-interpose-static-thread-malloc-check: \
>    $(objpfx)tst-interpose-aux-thread.o $(static-thread-library)
>  
> @@ -280,6 +312,9 @@ $(objpfx)tst-dynarray-fail-mem.out: $(objpfx)tst-dynarray-fail.out
>  $(objpfx)tst-malloc-tcache-leak: $(shared-thread-library)
>  $(objpfx)tst-malloc_info: $(shared-thread-library)
>  $(objpfx)tst-mallocfork2: $(shared-thread-library)
> +$(objpfx)tst-malloc-tcache-leak-mcheck: $(shared-thread-library)
> +$(objpfx)tst-malloc_info-mcheck: $(shared-thread-library)
> +$(objpfx)tst-mallocfork2-mcheck: $(shared-thread-library)
>  $(objpfx)tst-malloc-tcache-leak-malloc-check: $(shared-thread-library)
>  $(objpfx)tst-malloc_info-malloc-check: $(shared-thread-library)
>  $(objpfx)tst-mallocfork2-malloc-check: $(shared-thread-library)

Ok.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>



More information about the Libc-alpha mailing list