blob: 521fbdada5cc563bd56fde8a52d43e580a9065fd [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Ilya Leoshkevich9cae4ac2019-07-11 11:12:49 +02002include ../../../../scripts/Kbuild.include
Ilya Leoshkevich748e50c2019-07-11 16:29:27 +02003include ../../../scripts/Makefile.arch
Hendrik Brueckner618e1652017-12-04 10:56:48 +01004
Andrii Nakryiko74b5a592019-10-15 23:00:49 -07005CURDIR := $(abspath .)
6LIBDIR := $(abspath ../../../lib)
Zi Shen Lime8f1f342017-03-19 23:03:14 -07007BPFDIR := $(LIBDIR)/bpf
Andrii Nakryiko74b5a592019-10-15 23:00:49 -07008TOOLSDIR := $(abspath ../../../include)
9APIDIR := $(TOOLSDIR)/uapi
10GENDIR := $(abspath ../../../../include/generated)
Daniel Borkmann02ea80b2017-03-31 02:24:04 +020011GENHDR := $(GENDIR)/autoconf.h
Mickaël Salaünd498f872017-02-11 23:20:23 +010012
Daniel Borkmann02ea80b2017-03-31 02:24:04 +020013ifneq ($(wildcard $(GENHDR)),)
14 GENFLAGS := -DHAVE_GENHDR
15endif
16
Jiong Wang3ef84342019-01-26 12:26:14 -050017CLANG ?= clang
18LLC ?= llc
19LLVM_OBJCOPY ?= llvm-objcopy
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020020BPF_GCC ?= $(shell command -v bpf-gcc;)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070021CFLAGS += -g -Wall -O2 $(GENFLAGS) -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) \
22 -I$(GENDIR) -I$(TOOLSDIR) -I$(CURDIR) \
23 -Dbpf_prog_load=bpf_prog_test_load \
Jiong Wang9d120b42019-05-24 23:25:21 +010024 -Dbpf_load_program=bpf_test_load_program
Yonghong Songaf32efe2018-01-26 15:06:08 -080025LDLIBS += -lcap -lelf -lrt -lpthread
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +020026
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010027# Order correspond to 'make run_tests' order
David S. Miller18b3ad92017-05-10 11:43:51 -070028TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
Andrey Ignatov1d436882018-03-30 15:08:08 -070029 test_align test_verifier_log test_dev_cgroup test_tcpbpf_user \
Hangbin Liu25a79912019-06-04 10:35:05 +080030 test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
Andrii Nakryiko9bc63842019-10-22 23:09:13 -070031 test_cgroup_storage test_select_reuseport \
Andrii Nakryiko2d2a3ad2019-05-24 11:59:04 -070032 test_netcnt test_tcpnotify_user test_sock_fields test_sysctl test_hashmap \
Yonghong Songe13a2fe2019-10-21 21:31:19 -070033 test_cgroup_attach xdping test_progs-no_alu32
Jiong Wang3ef84342019-01-26 12:26:14 -050034
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070035# Also test bpf-gcc, if present
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020036ifneq ($(BPF_GCC),)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070037TEST_GEN_PROGS += test_progs-bpf_gcc
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +020038endif
39
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070040TEST_GEN_FILES =
41TEST_FILES =
42
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010043# Order correspond to 'make run_tests' order
44TEST_PROGS := test_kmod.sh \
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010045 test_xdp_redirect.sh \
46 test_xdp_meta.sh \
Toshiaki Makita88091ff2019-06-20 11:23:23 +090047 test_xdp_veth.sh \
Andrey Ignatov622adaf2018-03-30 15:08:06 -070048 test_offload.py \
William Tu933a7412018-04-26 14:01:39 -070049 test_sock_addr.sh \
Mathieu Xhonneuxc99a84e2018-05-20 14:58:17 +010050 test_tunnel.sh \
Sean Young6bdd5332018-05-27 12:24:10 +010051 test_lwt_seg6local.sh \
Andrey Ignatov5ecd8c22018-08-12 10:49:30 -070052 test_lirc_mode2.sh \
Petar Penkov50b3ed52018-09-14 07:46:22 -070053 test_skb_cgroup_id.sh \
Jesper Dangaard Brouer97396ff2018-10-09 12:04:53 +020054 test_flow_dissector.sh \
Jesper Dangaard Brouerd35661f2019-08-01 20:00:21 +020055 test_xdp_vlan_mode_generic.sh \
56 test_xdp_vlan_mode_native.sh \
Lorenz Bauerbafc0ba2019-03-22 09:54:06 +080057 test_lwt_ip_encap.sh \
Willem de Bruijn98cdabc2019-03-22 14:32:49 -040058 test_tcp_check_syncookie.sh \
Peter Oskolkov7df5e3d2019-03-22 16:40:19 -070059 test_tc_tunnel.sh \
Alan Maguirecd538502019-05-31 18:47:14 +010060 test_tc_edt.sh \
Quentin Monnet45c5589d2019-08-30 12:00:38 +010061 test_xdping.sh \
62 test_bpftool_build.sh
Daniel Borkmann5aa5bd12016-10-17 14:28:36 +020063
Anders Roxellf98937c2019-01-08 10:23:03 +010064TEST_PROGS_EXTENDED := with_addr.sh \
Stanislav Fomichev1be72f22019-01-14 09:41:41 -080065 with_tunnels.sh \
Anders Roxellf98937c2019-01-08 10:23:03 +010066 tcp_client.py \
Anders Roxell3035bb72019-08-20 15:41:21 +020067 tcp_server.py \
68 test_xdp_vlan.sh
Anders Roxellef4ab842018-10-10 16:27:04 +020069
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010070# Compile but not part of 'make run_tests'
Andrii Nakryikocb79a4e2019-10-15 23:00:51 -070071TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \
Hangbin Liu25a79912019-06-04 10:35:05 +080072 flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \
73 test_lirc_mode2_user
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010074
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070075TEST_CUSTOM_PROGS = urandom_read
76
Zi Shen Lime8f1f342017-03-19 23:03:14 -070077include ../lib.mk
Alexei Starovoitov1da8ac72017-03-10 22:05:55 -080078
Andrii Nakryiko03dcb782019-10-15 23:00:48 -070079# Define simple and short `make test_progs`, `make test_sysctl`, etc targets
80# to build individual tests.
81# NOTE: Semicolon at the end is critical to override lib.mk's default static
82# rule for binaries.
83$(notdir $(TEST_GEN_PROGS) \
84 $(TEST_PROGS) \
85 $(TEST_PROGS_EXTENDED) \
86 $(TEST_GEN_PROGS_EXTENDED) \
87 $(TEST_CUSTOM_PROGS)): %: $(OUTPUT)/% ;
88
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070089$(OUTPUT)/urandom_read: urandom_read.c
Ivan Veceraf6827522019-03-15 21:04:14 +010090 $(CC) -o $@ $< -Wl,--build-id
Jiong Wang3ef84342019-01-26 12:26:14 -050091
Jesper Dangaard Brouer41757dc2018-02-13 14:19:15 +010092BPFOBJ := $(OUTPUT)/libbpf.a
Zi Shen Lime8f1f342017-03-19 23:03:14 -070093
Andrii Nakryiko74b5a592019-10-15 23:00:49 -070094$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/test_stub.o $(BPFOBJ)
Jesper Dangaard Brouerf09b2e32018-02-08 12:48:27 +010095
Jesper Dangaard Brouer41757dc2018-02-13 14:19:15 +010096$(OUTPUT)/test_dev_cgroup: cgroup_helpers.c
Andrey Ignatov5ecd8c22018-08-12 10:49:30 -070097$(OUTPUT)/test_skb_cgroup_id_user: cgroup_helpers.c
Andrey Ignatov1d436882018-03-30 15:08:08 -070098$(OUTPUT)/test_sock: cgroup_helpers.c
Andrey Ignatove50b0a62018-03-30 15:08:03 -070099$(OUTPUT)/test_sock_addr: cgroup_helpers.c
Andrey Ignatov194db0d2018-07-30 17:42:31 -0700100$(OUTPUT)/test_socket_cookie: cgroup_helpers.c
John Fastabend16962b22018-04-23 14:30:38 -0700101$(OUTPUT)/test_sockmap: cgroup_helpers.c
Andrey Ignatovc65267e2018-07-11 17:33:35 -0700102$(OUTPUT)/test_tcpbpf_user: cgroup_helpers.c
Sowmini Varadhan435f90a2018-11-07 16:12:02 -0800103$(OUTPUT)/test_tcpnotify_user: cgroup_helpers.c trace_helpers.c
Yonghong Songf2690992018-06-03 15:59:43 -0700104$(OUTPUT)/get_cgroup_id_user: cgroup_helpers.c
Roman Gushchin68cfa3a2018-08-02 14:27:29 -0700105$(OUTPUT)/test_cgroup_storage: cgroup_helpers.c
Roman Gushchin371e4fc2018-09-28 14:46:00 +0000106$(OUTPUT)/test_netcnt: cgroup_helpers.c
Martin KaFai Laue0b27b32019-02-09 23:22:28 -0800107$(OUTPUT)/test_sock_fields: cgroup_helpers.c
Andrey Ignatov1f5fa9a2019-03-08 15:08:21 -0800108$(OUTPUT)/test_sysctl: cgroup_helpers.c
Roman Gushchinba0c0cc2019-05-25 09:37:40 -0700109$(OUTPUT)/test_cgroup_attach: cgroup_helpers.c
Jesper Dangaard Brouer41757dc2018-02-13 14:19:15 +0100110
Zi Shen Lime8f1f342017-03-19 23:03:14 -0700111.PHONY: force
Mickaël Salaünd498f872017-02-11 23:20:23 +0100112
Mickaël Salaünd498f872017-02-11 23:20:23 +0100113# force a rebuild of BPFOBJ when its dependencies are updated
114force:
115
Andrii Nakryikoe01a75c2019-10-08 10:59:40 -0700116$(BPFOBJ): force
Zi Shen Lime8f1f342017-03-19 23:03:14 -0700117 $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/
Alexei Starovoitov68828042017-03-30 21:45:41 -0700118
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700119BPF_HELPERS := $(BPFDIR)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h)
120$(BPFDIR)/bpf_helper_defs.h:
121 $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ bpf_helper_defs.h
122
Sirio Balmelli167381f2018-05-21 09:00:03 +0200123# Get Clang's default includes on this system, as opposed to those seen by
124# '-target bpf'. This fixes "missing" files on some architectures/distros,
125# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
126#
127# Use '-idirafter': Don't interfere with include mechanics except where the
128# build would have failed anyways.
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200129define get_sys_includes
130$(shell $(1) -v -E - </dev/null 2>&1 \
Sirio Balmelli167381f2018-05-21 09:00:03 +0200131 | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200132endef
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700133
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200134CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG))
Andrii Nakryiko598dc042019-10-11 15:01:46 -0700135BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH) \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700136 -I. -I./include/uapi -I$(APIDIR) \
137 -I$(BPFDIR) -I$(abspath $(OUTPUT)/../usr/include)
Sirio Balmelli167381f2018-05-21 09:00:03 +0200138
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200139CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \
140 -Wno-compare-distinct-pointer-types
Alexei Starovoitov3bc35c62017-12-14 17:55:11 -0800141
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200142$(OUTPUT)/test_l4lb_noinline.o: BPF_CFLAGS += -fno-inline
143$(OUTPUT)/test_xdp_noinline.o: BPF_CFLAGS += -fno-inline
Alexei Starovoitov3bc35c62017-12-14 17:55:11 -0800144
Stanislav Fomichevbf0f0fd2019-01-28 08:53:55 -0800145$(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
Stanislav Fomichevbf0f0fd2019-01-28 08:53:55 -0800146
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700147# Build BPF object using Clang
148# $1 - input .c file
149# $2 - output .o file
150# $3 - CFLAGS
151# $4 - LDFLAGS
152define CLANG_BPF_BUILD_RULE
153 ($(CLANG) $3 -O2 -target bpf -emit-llvm \
154 -c $1 -o - || echo "BPF obj compilation failed") | \
155 $(LLC) -march=bpf -mcpu=probe $4 -filetype=obj -o $2
156endef
157# Similar to CLANG_BPF_BUILD_RULE, but using native Clang and bpf LLC
158define CLANG_NATIVE_BPF_BUILD_RULE
159 ($(CLANG) $3 -O2 -emit-llvm \
160 -c $1 -o - || echo "BPF obj compilation failed") | \
161 $(LLC) -march=bpf -mcpu=probe $4 -filetype=obj -o $2
162endef
163# Build BPF object using GCC
164define GCC_BPF_BUILD_RULE
165 $(BPF_GCC) $3 $4 -O2 -c $1 -o $2
166endef
Stanislav Fomicheve78e00b2019-03-06 11:59:26 -0800167
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700168# Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on
169# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
170# Parameters:
171# $1 - test runner base binary name (e.g., test_progs)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700172# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700173define DEFINE_TEST_RUNNER
Jiong Wang3ef84342019-01-26 12:26:14 -0500174
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700175TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
176TRUNNER_BINARY := $1$(if $2,-)$2
177TRUNNER_TEST_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.test.o, \
178 $$(notdir $$(wildcard $(TRUNNER_TESTS_DIR)/*.c)))
179TRUNNER_EXTRA_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, \
180 $$(filter %.c,$(TRUNNER_EXTRA_SOURCES)))
181TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES))
182TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h
183TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, \
184 $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c)))
Jiong Wang3ef84342019-01-26 12:26:14 -0500185
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700186# Evaluate rules now with extra TRUNNER_XXX variables above already defined
187$$(eval $$(call DEFINE_TEST_RUNNER_RULES,$1,$2))
Stanislav Fomichev3f306582019-03-01 19:42:13 -0800188
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700189endef
Jiong Wang3ef84342019-01-26 12:26:14 -0500190
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700191# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and
192# set up by DEFINE_TEST_RUNNER itself, create test runner build rules with:
193# $1 - test runner base binary name (e.g., test_progs)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700194# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700195define DEFINE_TEST_RUNNER_RULES
196
197ifeq ($($(TRUNNER_OUTPUT)-dir),)
198$(TRUNNER_OUTPUT)-dir := y
199$(TRUNNER_OUTPUT):
200 mkdir -p $$@
Jiong Wang3ef84342019-01-26 12:26:14 -0500201endif
202
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700203# ensure we set up BPF objects generation rule just once for a given
204# input/output directory combination
205ifeq ($($(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs),)
206$(TRUNNER_BPF_PROGS_DIR)$(if $2,-)$2-bpfobjs := y
207$(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.o: \
208 $(TRUNNER_BPF_PROGS_DIR)/%.c \
209 $(TRUNNER_BPF_PROGS_DIR)/*.h \
210 $$(BPF_HELPERS) | $(TRUNNER_OUTPUT)
211 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
212 $(TRUNNER_BPF_CFLAGS), \
213 $(TRUNNER_BPF_LDFLAGS))
214endif
215
216# ensure we set up tests.h header generation rule just once
217ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
218$(TRUNNER_TESTS_DIR)-tests-hdr := y
219$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
220 $$(shell ( cd $(TRUNNER_TESTS_DIR); \
221 echo '/* Generated header, do not edit */'; \
222 ls *.c 2> /dev/null | \
223 sed -e 's@\([^\.]*\)\.c@DEFINE_TEST(\1)@'; \
224 ) > $$@)
225endif
226
227# compile individual test files
228# Note: we cd into output directory to ensure embedded BPF object is found
229$(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
230 $(TRUNNER_TESTS_DIR)/%.c \
231 $(TRUNNER_EXTRA_HDRS) \
232 $(TRUNNER_BPF_OBJS) \
233 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
234 cd $$(@D) && $$(CC) $$(CFLAGS) $$(LDLIBS) -c $(CURDIR)/$$< -o $$(@F)
235
236$(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \
237 %.c \
238 $(TRUNNER_EXTRA_HDRS) \
239 $(TRUNNER_TESTS_HDR) \
240 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
241 $$(CC) $$(CFLAGS) $$(LDLIBS) -c $$< -o $$@
242
243$(TRUNNER_BINARY)-extras: $(TRUNNER_EXTRA_FILES) | $(TRUNNER_OUTPUT)
244ifneq ($2,)
245 # only copy extra resources if in flavored build
246 cp -a $$^ $(TRUNNER_OUTPUT)/
247endif
248
249$(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \
250 $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \
251 | $(TRUNNER_BINARY)-extras
252 $$(CC) $$(CFLAGS) $$(LDLIBS) $$(filter %.a %.o,$$^) -o $$@
253
254endef
255
256# Define test_progs test runner.
257TRUNNER_TESTS_DIR := prog_tests
258TRUNNER_BPF_PROGS_DIR := progs
259TRUNNER_EXTRA_SOURCES := test_progs.c cgroup_helpers.c trace_helpers.c \
260 flow_dissector_load.h
261TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read \
262 $(wildcard progs/btf_dump_test_case_*.c)
263TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
264TRUNNER_BPF_CFLAGS := -I. -I$(OUTPUT) $(BPF_CFLAGS) $(CLANG_CFLAGS)
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700265TRUNNER_BPF_LDFLAGS := -mattr=+alu32
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700266$(eval $(call DEFINE_TEST_RUNNER,test_progs))
267
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700268# Define test_progs-no_alu32 test runner.
269TRUNNER_BPF_LDFLAGS :=
270$(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700271
272# Define test_progs BPF-GCC-flavored test runner.
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200273ifneq ($(BPF_GCC),)
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200274IS_LITTLE_ENDIAN = $(shell $(CC) -dM -E - </dev/null | \
275 grep 'define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__')
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700276MENDIAN=$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-mbig-endian)
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200277
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700278TRUNNER_BPF_BUILD_RULE := GCC_BPF_BUILD_RULE
279TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(call get_sys_includes,gcc) $(MENDIAN)
280TRUNNER_BPF_LDFLAGS :=
281$(eval $(call DEFINE_TEST_RUNNER,test_progs,bpf_gcc))
Ilya Leoshkevich4ce150b2019-09-12 18:05:43 +0200282endif
283
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700284# Define test_maps test runner.
285TRUNNER_TESTS_DIR := map_tests
286TRUNNER_BPF_PROGS_DIR := progs
287TRUNNER_EXTRA_SOURCES := test_maps.c
288TRUNNER_EXTRA_FILES :=
289TRUNNER_BPF_BUILD_RULE := $$(error no BPF objects should be built)
290TRUNNER_BPF_CFLAGS :=
291TRUNNER_BPF_LDFLAGS :=
292$(eval $(call DEFINE_TEST_RUNNER,test_maps))
Martin KaFai Lauc0fa1b62018-04-18 15:56:06 -0700293
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700294# Define test_verifier test runner.
295# It is much simpler than test_maps/test_progs and sufficiently different from
296# them (e.g., test.h is using completely pattern), that it's worth just
297# explicitly defining all the rules explicitly.
298verifier/tests.h: verifier/*.c
Stanislav Fomicheve78e00b2019-03-06 11:59:26 -0800299 $(shell ( cd verifier/; \
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800300 echo '/* Generated header, do not edit */'; \
301 echo '#ifdef FILL_ARRAY'; \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700302 ls *.c 2> /dev/null | sed -e 's@\(.*\)@#include \"\1\"@'; \
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800303 echo '#endif' \
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700304 ) > verifier/tests.h)
305$(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT)
306 $(CC) $(CFLAGS) $(LDLIBS) $(filter %.a %.o %.c,$^) -o $@
Jakub Kicinski2dfb4012019-01-25 15:24:42 -0800307
Andrii Nakryiko74b5a592019-10-15 23:00:49 -0700308EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) \
309 prog_tests/tests.h map_tests/tests.h verifier/tests.h \
Yonghong Songe13a2fe2019-10-21 21:31:19 -0700310 feature $(OUTPUT)/*.o $(OUTPUT)/no_alu32 $(OUTPUT)/bpf_gcc