Loading...
--- libmalloc/libmalloc-409.60.6/tests/Makefile
+++ libmalloc/libmalloc-521.120.7/tests/Makefile
@@ -1,7 +1,7 @@
PROJECT := libmalloc
TEST_DIR := tests/
-DEVELOPER_DIR ?= /Applications/Xcode.app/Contents/Developer/
+DEVELOPER_DIR ?= $(shell xcode-select -p)
include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common
@@ -12,13 +12,9 @@
# exclude_this_file.mtrace
EXCLUDED_TRACE_FILES :=
-CUSTOM_TARGETS = \
- MALLOC_BENCH
-
OTHER_TEST_TARGETS = \
$(addprefix nano-trace-replay_, $(basename $(filter-out $(EXCLUDED_TRACE_FILES), $(TRACE_FILES))))
-MALLOCBENCHTEST_DIR = $(SRCROOT)/MallocBenchTest
BATS_PLISTS_EXTRACT = \
$(patsubst %,$(SYMROOT)/%.plist,$(OTHER_TEST_TARGETS))
@@ -29,8 +25,12 @@
WARNING_CFLAGS := -Wno-format-invalid-specifier -Wno-format-extra-args
OTHER_CFLAGS += \
-DDARWINTEST \
+ -DOS_ATOMIC_CONFIG_MEMORY_ORDER_DEPENDENCY=1 \
-DOS_UNFAIR_LOCK_INLINE=1 \
+ -DT_META_TAG_XZONE=T_META_TAG\(\"xzone\"\) \
+ -DT_META_TAG_XZONE_ONLY=T_META_TAG\(\"xzone_only\"\) \
-fno-builtin \
+ -fno-typed-memory-operations \
-lCrashReporterClient \
-I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders \
-I$(SRCROOT)/../private \
@@ -49,17 +49,7 @@
-o $@ \
$(SRCROOT)/nano_trace_replay.c
-# For now, we only build and run MallocBench on iOS. macOS requires
-# us to adopt installAPI.
-LOWER_SDKROOT = $(shell echo $(SDKROOT) | tr '[:upper:]' '[:lower:]')
-ifneq (, $(findstring iphoneos,$(LOWER_SDKROOT)))
-include MallocBenchTest/Makefile.malloc-bench
-BATS_PLISTS = $(BATS_PLISTS_EXTRACT) $(MALLOCBENCHTEST_DIR)/MallocBench.plist
-else
-include MallocBenchTest/Makefile.dummy
BATS_PLISTS = $(BATS_PLISTS_EXTRACT)
-endif
-
BATS_PLISTS += $(PROJECT_DIR)/tests/xctests/BATS.plist
$(BATS_PLISTS_EXTRACT): %.plist : %
@@ -74,10 +64,49 @@
tsan: CFLAGS := $(filter-out $(ARCH_FLAGS),$(CFLAGS)) -arch x86_64 -fsanitize=thread
tsan: OTHER_LDFLAGS += -Wl,-rpath -Wl,$(SANITIZER_DYLIB_PATH)
else
-EXCLUDED_SOURCES += tsan.c magazine_medium_test.c
+EXCLUDED_SOURCES += tsan.c
endif
+bounds_test: OTHER_CFLAGS += -fbounds-attributes
+
+malloc_msl: OTHER_CFLAGS += -F $(PRIVATE_FRAMEWORKS)
+malloc_msl: OTHER_CFLAGS += -framework MallocStackLogging
+malloc_msl: OTHER_LDFLAGS += -F $(PRIVATE_FRAMEWORKS)
+malloc_msl: OTHER_LDFLAGS += -framework MallocStackLogging
+
+malloc_with_options_test: OTHER_LDFLAGS += -F $(PRIVATE_FRAMEWORKS)
+malloc_with_options_test: OTHER_LDFLAGS += -framework ktrace
+malloc_with_options_test: OTHER_CFLAGS += -I../src
+
madvise: OTHER_CFLAGS += -I../src
+malloc_claimed_address_tests: OTHER_CFLAGS += -I../src
+scribble_tests: OTHER_CFLAGS += -I../src
+malloc_size_test: OTHER_CFLAGS += -I../src
+
+xzone: OTHER_LDFLAGS += -ldarwintest_utils
+
+malloc_type: OTHER_CFLAGS += -ftyped-memory-operations
+
+EXCLUDED_SOURCES += malloc_type_callsite_cpp.cpp
+
+malloc_type_callsite_cpp.o: malloc_type_callsite_cpp.cpp
+ $(CXX) $(OTHER_CXXFLAGS) $(CXXFLAGS) -fno-typed-memory-operations -fno-typed-cxx-new-delete -c $< -o $(SYMROOT)/$@
+
+malloc_type_callsite: malloc_type_callsite_cpp.o
+malloc_type_callsite: OTHER_CFLAGS += $(SYMROOT)/malloc_type_callsite_cpp.o
+malloc_type_callsite: OTHER_LDFLAGS += -lc++
+
+# BATS test plist handling
+# - Modify plist (add tests) to run general tests again with xzone malloc enabled
+project_test_configs: bats.plist
+ cp ./libmalloc_pgm.plist $(DSTROOT)/AppleInternal/CoreOS/BATS/unit_tests/
+ xcrun -sdk $(SDKROOT) python3 ./add_xzone_tests.py $(SYMROOT)/bats.plist --platform $(PLATFORM)
+
+.PHONY: project_test_configs
+
+# Ensure that we add the xzone tests before bats.plist is installed to the
+# dstroot
+install: project_test_configs
.DEFAULT_GOAL := all