Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | PROJECT := libmalloc TEST_DIR := tests/ DEVELOPER_DIR ?= $(shell xcode-select -p) include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.common TRACE_FILES := \ $(notdir $(wildcard $(SRCROOT)/../traces/*.mtrace)) # add trace files without the traces/ prefix, fex: # 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)) EXCLUDED_SOURCES := \ nano_trace_replay.c CXX := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find clang++) WARNING_CFLAGS := -Wno-format-invalid-specifier -Wno-format-extra-args OTHER_CFLAGS += \ -DDARWINTEST \ -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 \ -I$(SRCROOT)/../include \ $(WARNING_CFLAGS) PRIVATE_FRAMEWORKS = $(SDKROOT)/System/Library/PrivateFrameworks PERFDATA_FRAMEWORK = perfdata nano-trace-replay_%: $(SRCROOT)/nano_trace_replay.c $(CC) \ $(CFLAGS) $(DT_CFLAGS) $(OTHER_CFLAGS) \ $(LDFLAGS) $(DT_LDFLAGS) $(OTHER_LDFLAGS) \ -DTRACE_NAME="$(patsubst nano-trace-replay_%,%,$(notdir $@))" \ $(patsubst _Photos_puja,-DTEST_TIMEOUT=3000,$(findstring _Photos_puja,$(notdir $@))) \ -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 : % $(EXTRACTMETA) extract -i /$(INSTALLPATH)/$(notdir $<) -b $(SYMROOT)/$(notdir $<) -o $@ @plutil -convert binary1 $@ SANITIZER_DYLIB_PATH := /usr/appleinternal/lib/sanitizers/ asan: OTHER_CFLAGS += -fsanitize=address asan: OTHER_LDFLAGS += -Wl,-rpath -Wl,$(SANITIZER_DYLIB_PATH) ifeq ($(Embedded),NO) 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 endif madvise: OTHER_CFLAGS += -I../src xzone: OTHER_LDFLAGS += -ldarwintest_utils malloc_type: OTHER_CFLAGS += -ftyped-memory-operations ifneq ($(PLATFORM),WatchOS) # Modify the BATS plist to run general tests again with xzone malloc enabled add_xzone_tests: bats.plist xcrun -sdk $(SDKROOT) python3 ./add_xzone_tests.py $(SYMROOT)/bats.plist CUSTOM_TARGETS += libmalloc_debug_symlink # Create a symlink to the debug version of the dylib that can be picked up in # isolation using DYLD_LIBRARY_PATH and DYLD_IMAGE_SUFFIX libmalloc_debug_symlink: ; install-libmalloc_debug_symlink: mkdir -p $(INSTALLDIR) ln -sf /usr/lib/system/libsystem_malloc_debug.dylib $(INSTALLDIR)/libsystem_malloc_testdebug.dylib .PHONY: add_xzone_tests # Ensure that we add the xzone tests before bats.plist is installed to the # dstroot install: add_xzone_tests endif # ($(PLATFORM),WatchOS) .DEFAULT_GOAL := all include $(DEVELOPER_DIR)/AppleInternal/Makefiles/darwintest/Makefile.targets |