On 4/1/22 8:29 PM, Andrii Nakryiko wrote: > Add semaphore-based USDT to test_progs itself and write basic tests to > valicate both auto-attachment and manual attachment logic, as well as > BPF-side functionality. > > Also add subtests to validate that libbpf properly deduplicates USDT > specs and handles spec overflow situations correctly, as well as proper > "rollback" of partially-attached multi-spec USDT. > > BPF-side of selftest intentionally consists of two files to validate > that usdt.bpf.h header can be included from multiple source code files > that are subsequently linked into final BPF object file without causing > any symbol duplication or other issues. We are validating that __weak > maps and bpf_usdt_xxx() API functions defined in usdt.bpf.h do work as > intended. > > USDT selftests use sys/sdt.h header provided by systemtap-sdt-devel, so > document that build-time dependency in Documentation/bpf/bpf_devel_QA.rst. > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- > Documentation/bpf/bpf_devel_QA.rst | 3 + > tools/testing/selftests/bpf/Makefile | 14 +- > tools/testing/selftests/bpf/prog_tests/usdt.c | 313 ++++++++++++++++++ > tools/testing/selftests/bpf/progs/test_usdt.c | 96 ++++++ > .../selftests/bpf/progs/test_usdt_multispec.c | 34 ++ > 5 files changed, 454 insertions(+), 6 deletions(-) > create mode 100644 tools/testing/selftests/bpf/prog_tests/usdt.c > create mode 100644 tools/testing/selftests/bpf/progs/test_usdt.c > create mode 100644 tools/testing/selftests/bpf/progs/test_usdt_multispec.c [...] > diff --git a/tools/testing/selftests/bpf/progs/test_usdt_multispec.c b/tools/testing/selftests/bpf/progs/test_usdt_multispec.c > new file mode 100644 > index 000000000000..96fe128790d1 > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/test_usdt_multispec.c > @@ -0,0 +1,34 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ > + > +#include "vmlinux.h" > +#include <bpf/bpf_helpers.h> > +#include <bpf/usdt.bpf.h> > + > +/* this file is linked together with test_usdt.c to validate that ust.bpf.h nit: usdt.bpf.h in above comment > + * can be included in multiple .bpf.c files forming single final BPF object > + * file > + */ Acked-by: Dave Marchevsky <davemarchevsky@xxxxxx>