Makefile (14137f3c62186799b01eea8a338f90c9cbc57f00) Makefile (a0964f526df6facd4e12a4c416185013026eecf9)
1# SPDX-License-Identifier: GPL-2.0
2include ../../../../scripts/Kbuild.include
3include ../../../scripts/Makefile.arch
4include ../../../scripts/Makefile.include
5
6CXX ?= $(CROSS_COMPILE)g++
7
8CURDIR := $(abspath .)

--- 289 unchanged lines hidden (view full) ---

298# Build BPF object using GCC
299define GCC_BPF_BUILD_RULE
300 $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
301 $(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2
302endef
303
304SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
305
1# SPDX-License-Identifier: GPL-2.0
2include ../../../../scripts/Kbuild.include
3include ../../../scripts/Makefile.arch
4include ../../../scripts/Makefile.include
5
6CXX ?= $(CROSS_COMPILE)g++
7
8CURDIR := $(abspath .)

--- 289 unchanged lines hidden (view full) ---

298# Build BPF object using GCC
299define GCC_BPF_BUILD_RULE
300 $(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
301 $(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2
302endef
303
304SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c
305
306LINKED_SKELS := test_static_linked.skel.h
307
308test_static_linked.skel.h-deps := test_static_linked1.o test_static_linked2.o
309
306# Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on
307# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
308# Parameters:
309# $1 - test runner base binary name (e.g., test_progs)
310# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
311define DEFINE_TEST_RUNNER
312
313TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2

--- 4 unchanged lines hidden (view full) ---

318 $$(filter %.c,$(TRUNNER_EXTRA_SOURCES)))
319TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES))
320TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h
321TRUNNER_BPF_SRCS := $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c))
322TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, $$(TRUNNER_BPF_SRCS))
323TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \
324 $$(filter-out $(SKEL_BLACKLIST), \
325 $$(TRUNNER_BPF_SRCS)))
310# Set up extra TRUNNER_XXX "temporary" variables in the environment (relies on
311# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
312# Parameters:
313# $1 - test runner base binary name (e.g., test_progs)
314# $2 - test runner extra "flavor" (e.g., no_alu32, gcc-bpf, etc)
315define DEFINE_TEST_RUNNER
316
317TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2

--- 4 unchanged lines hidden (view full) ---

322 $$(filter %.c,$(TRUNNER_EXTRA_SOURCES)))
323TRUNNER_EXTRA_HDRS := $$(filter %.h,$(TRUNNER_EXTRA_SOURCES))
324TRUNNER_TESTS_HDR := $(TRUNNER_TESTS_DIR)/tests.h
325TRUNNER_BPF_SRCS := $$(notdir $$(wildcard $(TRUNNER_BPF_PROGS_DIR)/*.c))
326TRUNNER_BPF_OBJS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.o, $$(TRUNNER_BPF_SRCS))
327TRUNNER_BPF_SKELS := $$(patsubst %.c,$$(TRUNNER_OUTPUT)/%.skel.h, \
328 $$(filter-out $(SKEL_BLACKLIST), \
329 $$(TRUNNER_BPF_SRCS)))
330TRUNNER_BPF_SKELS_LINKED := $$(addprefix $$(TRUNNER_OUTPUT)/,$(LINKED_SKELS))
326TEST_GEN_FILES += $$(TRUNNER_BPF_OBJS)
327
328# Evaluate rules now with extra TRUNNER_XXX variables above already defined
329$$(eval $$(call DEFINE_TEST_RUNNER_RULES,$1,$2))
330
331endef
332
333# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and

--- 18 unchanged lines hidden (view full) ---

352 $(TRUNNER_BPF_PROGS_DIR)/*.h \
353 $$(INCLUDE_DIR)/vmlinux.h \
354 $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
355 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
356 $(TRUNNER_BPF_CFLAGS))
357
358$(TRUNNER_BPF_SKELS): %.skel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
359 $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
331TEST_GEN_FILES += $$(TRUNNER_BPF_OBJS)
332
333# Evaluate rules now with extra TRUNNER_XXX variables above already defined
334$$(eval $$(call DEFINE_TEST_RUNNER_RULES,$1,$2))
335
336endef
337
338# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and

--- 18 unchanged lines hidden (view full) ---

357 $(TRUNNER_BPF_PROGS_DIR)/*.h \
358 $$(INCLUDE_DIR)/vmlinux.h \
359 $(wildcard $(BPFDIR)/bpf_*.h) | $(TRUNNER_OUTPUT)
360 $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
361 $(TRUNNER_BPF_CFLAGS))
362
363$(TRUNNER_BPF_SKELS): %.skel.h: %.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
364 $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
360 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked.o) $$<
361 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked.o)
365 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked1.o) $$<
366 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked2.o) $$(<:.o=.linked1.o)
362 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o)
363 $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
367 $(Q)$$(BPFTOOL) gen object $$(<:.o=.linked3.o) $$(<:.o=.linked2.o)
368 $(Q)diff $$(<:.o=.linked2.o) $$(<:.o=.linked3.o)
364 $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked.o) name $$(notdir $$(<:.o=)) > $$@
369 $(Q)$$(BPFTOOL) gen skeleton $$(<:.o=.linked3.o) name $$(notdir $$(<:.o=)) > $$@
370
371$(TRUNNER_BPF_SKELS_LINKED): $(TRUNNER_BPF_OBJS) $(BPFTOOL) | $(TRUNNER_OUTPUT)
372 $$(call msg,LINK-BPF,$(TRUNNER_BINARY),$$(@:.skel.h=.o))
373 $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked1.o) $$(addprefix $(TRUNNER_OUTPUT)/,$$($$(@F)-deps))
374 $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked1.o)
375 $(Q)$$(BPFTOOL) gen object $$(@:.skel.h=.linked3.o) $$(@:.skel.h=.linked2.o)
376 $(Q)diff $$(@:.skel.h=.linked2.o) $$(@:.skel.h=.linked3.o)
377 $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
378 $(Q)$$(BPFTOOL) gen skeleton $$(@:.skel.h=.linked3.o) name $$(notdir $$(@:.skel.h=)) > $$@
365endif
366
367# ensure we set up tests.h header generation rule just once
368ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
369$(TRUNNER_TESTS_DIR)-tests-hdr := y
370$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
371 $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@)
372 $$(shell ( cd $(TRUNNER_TESTS_DIR); \

--- 5 unchanged lines hidden (view full) ---

378
379# compile individual test files
380# Note: we cd into output directory to ensure embedded BPF object is found
381$(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
382 $(TRUNNER_TESTS_DIR)/%.c \
383 $(TRUNNER_EXTRA_HDRS) \
384 $(TRUNNER_BPF_OBJS) \
385 $(TRUNNER_BPF_SKELS) \
379endif
380
381# ensure we set up tests.h header generation rule just once
382ifeq ($($(TRUNNER_TESTS_DIR)-tests-hdr),)
383$(TRUNNER_TESTS_DIR)-tests-hdr := y
384$(TRUNNER_TESTS_HDR): $(TRUNNER_TESTS_DIR)/*.c
385 $$(call msg,TEST-HDR,$(TRUNNER_BINARY),$$@)
386 $$(shell ( cd $(TRUNNER_TESTS_DIR); \

--- 5 unchanged lines hidden (view full) ---

392
393# compile individual test files
394# Note: we cd into output directory to ensure embedded BPF object is found
395$(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \
396 $(TRUNNER_TESTS_DIR)/%.c \
397 $(TRUNNER_EXTRA_HDRS) \
398 $(TRUNNER_BPF_OBJS) \
399 $(TRUNNER_BPF_SKELS) \
400 $(TRUNNER_BPF_SKELS_LINKED) \
386 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
387 $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@)
388 $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)
389
390$(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \
391 %.c \
392 $(TRUNNER_EXTRA_HDRS) \
393 $(TRUNNER_TESTS_HDR) \

--- 101 unchanged lines hidden ---
401 $$(BPFOBJ) | $(TRUNNER_OUTPUT)
402 $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@)
403 $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F)
404
405$(TRUNNER_EXTRA_OBJS): $(TRUNNER_OUTPUT)/%.o: \
406 %.c \
407 $(TRUNNER_EXTRA_HDRS) \
408 $(TRUNNER_TESTS_HDR) \

--- 101 unchanged lines hidden ---