]> git.ipfire.org Git - thirdparty/linux.git/blob - tools/testing/selftests/mm/Makefile
Merge tag 'mm-stable-2023-04-27-15-30' of git://git.kernel.org/pub/scm/linux/kernel...
[thirdparty/linux.git] / tools / testing / selftests / mm / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 # Makefile for mm selftests
3
4 LOCAL_HDRS += $(selfdir)/mm/local_config.h $(top_srcdir)/mm/gup_test.h
5
6 include local_config.mk
7
8 ifeq ($(CROSS_COMPILE),)
9 uname_M := $(shell uname -m 2>/dev/null || echo not)
10 else
11 uname_M := $(shell echo $(CROSS_COMPILE) | grep -o '^[a-z0-9]\+')
12 endif
13 MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/ppc64/')
14
15 # Without this, failed build products remain, with up-to-date timestamps,
16 # thus tricking Make (and you!) into believing that All Is Well, in subsequent
17 # make invocations:
18 .DELETE_ON_ERROR:
19
20 # Avoid accidental wrong builds, due to built-in rules working just a little
21 # bit too well--but not quite as well as required for our situation here.
22 #
23 # In other words, "make $SOME_TEST" is supposed to fail to build at all,
24 # because this Makefile only supports either "make" (all), or "make /full/path".
25 # However, the built-in rules, if not suppressed, will pick up CFLAGS and the
26 # initial LDLIBS (but not the target-specific LDLIBS, because those are only
27 # set for the full path target!). This causes it to get pretty far into building
28 # things despite using incorrect values such as an *occasionally* incomplete
29 # LDLIBS.
30 MAKEFLAGS += --no-builtin-rules
31
32 CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/tools/include/uapi $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
33 LDLIBS = -lrt -lpthread
34
35 TEST_GEN_PROGS = cow
36 TEST_GEN_PROGS += compaction_test
37 TEST_GEN_PROGS += gup_test
38 TEST_GEN_PROGS += hmm-tests
39 TEST_GEN_PROGS += hugetlb-madvise
40 TEST_GEN_PROGS += hugepage-mmap
41 TEST_GEN_PROGS += hugepage-mremap
42 TEST_GEN_PROGS += hugepage-shm
43 TEST_GEN_PROGS += hugepage-vmemmap
44 TEST_GEN_PROGS += khugepaged
45 TEST_GEN_PROGS += madv_populate
46 TEST_GEN_PROGS += map_fixed_noreplace
47 TEST_GEN_PROGS += map_hugetlb
48 TEST_GEN_PROGS += map_populate
49 TEST_GEN_PROGS += memfd_secret
50 TEST_GEN_PROGS += migration
51 TEST_GEN_PROGS += mkdirty
52 TEST_GEN_PROGS += mlock-random-test
53 TEST_GEN_PROGS += mlock2-tests
54 TEST_GEN_PROGS += mrelease_test
55 TEST_GEN_PROGS += mremap_dontunmap
56 TEST_GEN_PROGS += mremap_test
57 TEST_GEN_PROGS += on-fault-limit
58 TEST_GEN_PROGS += thuge-gen
59 TEST_GEN_PROGS += transhuge-stress
60 TEST_GEN_PROGS += uffd-stress
61 TEST_GEN_PROGS += uffd-unit-tests
62 TEST_GEN_PROGS += soft-dirty
63 TEST_GEN_PROGS += split_huge_page_test
64 TEST_GEN_PROGS += ksm_tests
65 TEST_GEN_PROGS += ksm_functional_tests
66 TEST_GEN_PROGS += mdwe_test
67
68 ifeq ($(MACHINE),x86_64)
69 CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
70 CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
71 CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_program.c -no-pie)
72
73 VMTARGETS := protection_keys
74 BINARIES_32 := $(VMTARGETS:%=%_32)
75 BINARIES_64 := $(VMTARGETS:%=%_64)
76
77 ifeq ($(CAN_BUILD_WITH_NOPIE),1)
78 CFLAGS += -no-pie
79 endif
80
81 ifeq ($(CAN_BUILD_I386),1)
82 TEST_GEN_PROGS += $(BINARIES_32)
83 endif
84
85 ifeq ($(CAN_BUILD_X86_64),1)
86 TEST_GEN_PROGS += $(BINARIES_64)
87 endif
88 else
89
90 ifneq (,$(findstring $(MACHINE),ppc64))
91 TEST_GEN_PROGS += protection_keys
92 endif
93
94 endif
95
96 ifneq (,$(filter $(MACHINE),arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sparc64 x86_64))
97 TEST_GEN_PROGS += va_high_addr_switch
98 TEST_GEN_PROGS += virtual_address_range
99 TEST_GEN_PROGS += write_to_hugetlbfs
100 endif
101
102 TEST_PROGS := run_vmtests.sh
103
104 TEST_FILES := test_vmalloc.sh
105 TEST_FILES += test_hmm.sh
106 TEST_FILES += va_high_addr_switch.sh
107
108 include ../lib.mk
109
110 $(TEST_GEN_PROGS): vm_util.c
111
112 $(OUTPUT)/uffd-stress: uffd-common.c
113 $(OUTPUT)/uffd-unit-tests: uffd-common.c
114
115 ifeq ($(MACHINE),x86_64)
116 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
117 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
118
119 define gen-target-rule-32
120 $(1) $(1)_32: $(OUTPUT)/$(1)_32
121 .PHONY: $(1) $(1)_32
122 endef
123
124 define gen-target-rule-64
125 $(1) $(1)_64: $(OUTPUT)/$(1)_64
126 .PHONY: $(1) $(1)_64
127 endef
128
129 ifeq ($(CAN_BUILD_I386),1)
130 $(BINARIES_32): CFLAGS += -m32 -mxsave
131 $(BINARIES_32): LDLIBS += -lrt -ldl -lm
132 $(BINARIES_32): $(OUTPUT)/%_32: %.c
133 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
134 $(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-32,$(t))))
135 endif
136
137 ifeq ($(CAN_BUILD_X86_64),1)
138 $(BINARIES_64): CFLAGS += -m64 -mxsave
139 $(BINARIES_64): LDLIBS += -lrt -ldl
140 $(BINARIES_64): $(OUTPUT)/%_64: %.c
141 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(notdir $^) $(LDLIBS) -o $@
142 $(foreach t,$(VMTARGETS),$(eval $(call gen-target-rule-64,$(t))))
143 endif
144
145 # x86_64 users should be encouraged to install 32-bit libraries
146 ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01)
147 all: warn_32bit_failure
148
149 warn_32bit_failure:
150 @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \
151 echo "environment. This will reduce test coverage of 64-bit" 2>&1; \
152 echo "kernels. If you are using a Debian-like distribution," 2>&1; \
153 echo "try:"; 2>&1; \
154 echo ""; \
155 echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \
156 echo ""; \
157 echo "If you are using a Fedora-like distribution, try:"; \
158 echo ""; \
159 echo " yum install glibc-devel.*i686"; \
160 exit 0;
161 endif
162 endif
163
164 # IOURING_EXTRA_LIBS may get set in local_config.mk, or it may be left empty.
165 $(OUTPUT)/cow: LDLIBS += $(IOURING_EXTRA_LIBS)
166
167 $(OUTPUT)/mlock-random-test $(OUTPUT)/memfd_secret: LDLIBS += -lcap
168
169 $(OUTPUT)/ksm_tests: LDLIBS += -lnuma
170
171 $(OUTPUT)/migration: LDLIBS += -lnuma
172
173 local_config.mk local_config.h: check_config.sh
174 /bin/sh ./check_config.sh $(CC)
175
176 EXTRA_CLEAN += local_config.mk local_config.h
177
178 ifeq ($(IOURING_EXTRA_LIBS),)
179 all: warn_missing_liburing
180
181 warn_missing_liburing:
182 @echo ; \
183 echo "Warning: missing liburing support. Some tests will be skipped." ; \
184 echo
185 endif