On Mon, Dec 2, 2019 at 12:28 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > Commit 5c26f9a78358 ("libbpf: Don't use cxx to test_libpf target") > converted existing c++ test to c. We still want to include and > link against libbpf from c++ code, so reinstate this test back, > this time in a form of a selftest with a clear comment about > its purpose. > > Fixes: 5c26f9a78358 ("libbpf: Don't use cxx to test_libpf target") > Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx> > --- thanks for clean up! Looks good except for explicit -lelf below. > tools/lib/bpf/.gitignore | 1 - > tools/lib/bpf/Makefile | 5 +---- > tools/testing/selftests/bpf/.gitignore | 1 + > tools/testing/selftests/bpf/Makefile | 6 +++++- > .../test_libbpf.c => testing/selftests/bpf/test_cpp.cpp} | 0 > 5 files changed, 7 insertions(+), 6 deletions(-) > rename tools/{lib/bpf/test_libbpf.c => testing/selftests/bpf/test_cpp.cpp} (100%) > [...] > > @@ -317,6 +317,10 @@ verifier/tests.h: verifier/*.c > $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) > $(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ > > +# Make sure we are able to include and link libbpf against c++. > +$(OUTPUT)/test_cpp: test_cpp.cpp $(BPFOBJ) > + $(CXX) $(CFLAGS) $^ -lelf -o $@ let's use $(LDLIBS) instead here > + > EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) \ > prog_tests/tests.h map_tests/tests.h verifier/tests.h \ > feature $(OUTPUT)/*.o $(OUTPUT)/no_alu32 $(OUTPUT)/bpf_gcc > diff --git a/tools/lib/bpf/test_libbpf.c b/tools/testing/selftests/bpf/test_cpp.cpp > similarity index 100% > rename from tools/lib/bpf/test_libbpf.c > rename to tools/testing/selftests/bpf/test_cpp.cpp > -- > 2.24.0.393.g34dc348eaf-goog >