On Fri, Nov 5, 2021 at 12:36 AM Dave Marchevsky <davemarchevsky@xxxxxx> wrote: > > On 11/3/21 6:08 PM, Andrii Nakryiko wrote: > > -Dbpf_prog_load_deprecated=bpf_prog_test_load trick is both ugly and > > breaks when deprecation goes into effect due to macro magic. Convert all > > the uses to explicit bpf_prog_test_load() calls which avoid deprecation > > errors and makes everything less magical. > > > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > --- > > [...] > > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > > index 5588c622d266..2016c583ed20 100644 > > --- a/tools/testing/selftests/bpf/Makefile > > +++ b/tools/testing/selftests/bpf/Makefile > > @@ -24,7 +24,6 @@ SAN_CFLAGS ?= > > CFLAGS += -g -O0 -rdynamic -Wall $(GENFLAGS) $(SAN_CFLAGS) \ > > -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ > > -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT) \ > > - -Dbpf_prog_load_deprecated=bpf_prog_test_load \ > > -Dbpf_load_program=bpf_test_load_program > > LDLIBS += -lcap -lelf -lz -lrt -lpthread > > > > I'm glad that this magic is going away, it's very unintuitive. > > That said, I wonder if there's some way to complain loudly if a prog_test uses > bpf_prog_load instead of bpf_prog_test_load. Otherwise will have to manually > guard against it slipping in in some test. This comment applies to patch 12 > as well for bpf_load_program. > bpf_prog_test_load() shouldn't really be used going forward. bpf_object__open() + bpf_object__load() is a way to go. Better yet, stick to skeletons. As for bpf_test_load_program(), the only reason for it is BPF_F_TEST_RND_HI32 flag, and I think we have and have had enough coverage for that, so there is no need to want to keep using it for new code. So I think it's good as is. > > @@ -207,6 +206,7 @@ $(OUTPUT)/test_lirc_mode2_user: testing_helpers.o > > $(OUTPUT)/xdping: testing_helpers.o > > $(OUTPUT)/flow_dissector_load: testing_helpers.o > > $(OUTPUT)/test_maps: testing_helpers.o > > +$(OUTPUT)/test_verifier: testing_helpers.o > > [...] >