* [PATCH] tools/perf/tests: Fix Basic BPF llvm compile to check for libbpf support
@ 2023-07-04 5:03 Athira Rajeev
2023-07-05 18:09 ` Namhyung Kim
0 siblings, 1 reply; 2+ messages in thread
From: Athira Rajeev @ 2023-07-04 5:03 UTC (permalink / raw)
To: acme, jolsa, ak
Cc: namhyung, irogers, james.clark, mpe, linux-perf-users,
linuxppc-dev, maddy, rnsastry, kjain, disgoel, Athira Rajeev
Basic BPF llvm compile fails in systems with libbpf
that doesn't support BTF. Log shows below information.
libbpf: BTF is required, but is missing or corrupted.
Failed to parse test case 'Basic BPF llvm compile'
test child finished with -2
---- end ----
Here BPF llvm compile fails due to missing BTF support.
Fix the llvm test to skip the test incase BTF support is
missing.
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
tools/perf/tests/llvm.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 0bc25a56cfef..4c73c9eab0bb 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -4,6 +4,7 @@
#include <string.h>
#include "tests.h"
#include "debug.h"
+#include <errno.h>
#ifdef HAVE_LIBBPF_SUPPORT
#include <bpf/libbpf.h>
@@ -14,8 +15,12 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
struct bpf_object *obj;
obj = bpf_object__open_mem(obj_buf, obj_buf_sz, NULL);
- if (libbpf_get_error(obj))
+ if (libbpf_get_error(obj)) {
+ /* Skip if there is no BTF support */
+ if (errno == ENOENT)
+ return TEST_SKIP;
return TEST_FAIL;
+ }
bpf_object__close(obj);
return TEST_OK;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/perf/tests: Fix Basic BPF llvm compile to check for libbpf support
2023-07-04 5:03 [PATCH] tools/perf/tests: Fix Basic BPF llvm compile to check for libbpf support Athira Rajeev
@ 2023-07-05 18:09 ` Namhyung Kim
0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2023-07-05 18:09 UTC (permalink / raw)
To: Athira Rajeev
Cc: acme, jolsa, ak, irogers, james.clark, mpe, linux-perf-users,
linuxppc-dev, maddy, rnsastry, kjain, disgoel
Hello,
On Mon, Jul 3, 2023 at 10:03 PM Athira Rajeev
<atrajeev@linux.vnet.ibm.com> wrote:
>
> Basic BPF llvm compile fails in systems with libbpf
> that doesn't support BTF. Log shows below information.
>
> libbpf: BTF is required, but is missing or corrupted.
> Failed to parse test case 'Basic BPF llvm compile'
> test child finished with -2
> ---- end ----
>
> Here BPF llvm compile fails due to missing BTF support.
> Fix the llvm test to skip the test incase BTF support is
> missing.
>
> Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> ---
> tools/perf/tests/llvm.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
> index 0bc25a56cfef..4c73c9eab0bb 100644
> --- a/tools/perf/tests/llvm.c
> +++ b/tools/perf/tests/llvm.c
> @@ -4,6 +4,7 @@
> #include <string.h>
> #include "tests.h"
> #include "debug.h"
> +#include <errno.h>
>
> #ifdef HAVE_LIBBPF_SUPPORT
> #include <bpf/libbpf.h>
> @@ -14,8 +15,12 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
> struct bpf_object *obj;
>
> obj = bpf_object__open_mem(obj_buf, obj_buf_sz, NULL);
> - if (libbpf_get_error(obj))
> + if (libbpf_get_error(obj)) {
> + /* Skip if there is no BTF support */
> + if (errno == ENOENT)
Can we use the return value of libbpf_get_error() instead of
using the errno?
Also I'm curious why it requires BTF even if the BPF program
doesn't use it. Is there an option or something for that?
Thanks,
Namhyung
> + return TEST_SKIP;
> return TEST_FAIL;
> + }
> bpf_object__close(obj);
> return TEST_OK;
> }
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-05 18:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-04 5:03 [PATCH] tools/perf/tests: Fix Basic BPF llvm compile to check for libbpf support Athira Rajeev
2023-07-05 18:09 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).