bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
@ 2020-09-29 12:30 Toke Høiland-Jørgensen
  2020-09-29 12:35 ` Alan Maguire
  2020-09-29 18:30 ` patchwork-bot+bpf
  0 siblings, 2 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-09-29 12:30 UTC (permalink / raw)
  To: daniel, ast; +Cc: Toke Høiland-Jørgensen, bpf, netdev, Alan Maguire

The new test for task iteration in bpf_iter checks (in do_btf_read()) if it
should be skipped due to missing __builtin_btf_type_id. However, this
'skip' verdict is not propagated to the caller, so the parent test will
still fail. Fix this by also skipping the rest of the parent test if the
skip condition was reached.

Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
index af15630a24dd..448885b95eed 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -172,17 +172,18 @@ static void test_task_file(void)
 
 static char taskbuf[TASKBUFSZ];
 
-static void do_btf_read(struct bpf_iter_task_btf *skel)
+static int do_btf_read(struct bpf_iter_task_btf *skel)
 {
 	struct bpf_program *prog = skel->progs.dump_task_struct;
 	struct bpf_iter_task_btf__bss *bss = skel->bss;
 	int iter_fd = -1, len = 0, bufleft = TASKBUFSZ;
 	struct bpf_link *link;
 	char *buf = taskbuf;
+	int ret = 0;
 
 	link = bpf_program__attach_iter(prog, NULL);
 	if (CHECK(IS_ERR(link), "attach_iter", "attach_iter failed\n"))
-		return;
+		return ret;
 
 	iter_fd = bpf_iter_create(bpf_link__fd(link));
 	if (CHECK(iter_fd < 0, "create_iter", "create_iter failed\n"))
@@ -198,6 +199,7 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
 
 	if (bss->skip) {
 		printf("%s:SKIP:no __builtin_btf_type_id\n", __func__);
+		ret = 1;
 		test__skip();
 		goto free_link;
 	}
@@ -212,12 +214,14 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
 	if (iter_fd > 0)
 		close(iter_fd);
 	bpf_link__destroy(link);
+	return ret;
 }
 
 static void test_task_btf(void)
 {
 	struct bpf_iter_task_btf__bss *bss;
 	struct bpf_iter_task_btf *skel;
+	int ret;
 
 	skel = bpf_iter_task_btf__open_and_load();
 	if (CHECK(!skel, "bpf_iter_task_btf__open_and_load",
@@ -226,7 +230,9 @@ static void test_task_btf(void)
 
 	bss = skel->bss;
 
-	do_btf_read(skel);
+	ret = do_btf_read(skel);
+	if (ret)
+		goto cleanup;
 
 	if (CHECK(bss->tasks == 0, "check if iterated over tasks",
 		  "no task iteration, did BPF program run?\n"))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
  2020-09-29 12:30 [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id Toke Høiland-Jørgensen
@ 2020-09-29 12:35 ` Alan Maguire
  2020-09-29 12:50   ` Toke Høiland-Jørgensen
  2020-09-29 18:30 ` patchwork-bot+bpf
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Maguire @ 2020-09-29 12:35 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen; +Cc: daniel, ast, bpf, netdev, Alan Maguire

[-- Attachment #1: Type: text/plain, Size: 2770 bytes --]

On Tue, 29 Sep 2020, Toke Høiland-Jørgensen wrote:

> The new test for task iteration in bpf_iter checks (in do_btf_read()) if it
> should be skipped due to missing __builtin_btf_type_id. However, this
> 'skip' verdict is not propagated to the caller, so the parent test will
> still fail. Fix this by also skipping the rest of the parent test if the
> skip condition was reached.
> 
> Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>

Thanks for fixing this Toke!

> ---
>  tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> index af15630a24dd..448885b95eed 100644
> --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> @@ -172,17 +172,18 @@ static void test_task_file(void)
>  
>  static char taskbuf[TASKBUFSZ];
>  
> -static void do_btf_read(struct bpf_iter_task_btf *skel)
> +static int do_btf_read(struct bpf_iter_task_btf *skel)
>  {
>  	struct bpf_program *prog = skel->progs.dump_task_struct;
>  	struct bpf_iter_task_btf__bss *bss = skel->bss;
>  	int iter_fd = -1, len = 0, bufleft = TASKBUFSZ;
>  	struct bpf_link *link;
>  	char *buf = taskbuf;
> +	int ret = 0;
>  
>  	link = bpf_program__attach_iter(prog, NULL);
>  	if (CHECK(IS_ERR(link), "attach_iter", "attach_iter failed\n"))
> -		return;
> +		return ret;
>  
>  	iter_fd = bpf_iter_create(bpf_link__fd(link));
>  	if (CHECK(iter_fd < 0, "create_iter", "create_iter failed\n"))
> @@ -198,6 +199,7 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
>  
>  	if (bss->skip) {
>  		printf("%s:SKIP:no __builtin_btf_type_id\n", __func__);
> +		ret = 1;
>  		test__skip();
>  		goto free_link;
>  	}
> @@ -212,12 +214,14 @@ static void do_btf_read(struct bpf_iter_task_btf *skel)
>  	if (iter_fd > 0)
>  		close(iter_fd);
>  	bpf_link__destroy(link);
> +	return ret;
>  }
>  
>  static void test_task_btf(void)
>  {
>  	struct bpf_iter_task_btf__bss *bss;
>  	struct bpf_iter_task_btf *skel;
> +	int ret;
>  
>  	skel = bpf_iter_task_btf__open_and_load();
>  	if (CHECK(!skel, "bpf_iter_task_btf__open_and_load",
> @@ -226,7 +230,9 @@ static void test_task_btf(void)
>  
>  	bss = skel->bss;
>  
> -	do_btf_read(skel);
> +	ret = do_btf_read(skel);
> +	if (ret)
> +		goto cleanup;
>  
>  	if (CHECK(bss->tasks == 0, "check if iterated over tasks",
>  		  "no task iteration, did BPF program run?\n"))
> -- 
> 2.28.0
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
  2020-09-29 12:35 ` Alan Maguire
@ 2020-09-29 12:50   ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-09-29 12:50 UTC (permalink / raw)
  To: Alan Maguire; +Cc: daniel, ast, bpf, netdev, Alan Maguire

Alan Maguire <alan.maguire@oracle.com> writes:

> On Tue, 29 Sep 2020, Toke Høiland-Jørgensen wrote:
>
>> The new test for task iteration in bpf_iter checks (in do_btf_read()) if it
>> should be skipped due to missing __builtin_btf_type_id. However, this
>> 'skip' verdict is not propagated to the caller, so the parent test will
>> still fail. Fix this by also skipping the rest of the parent test if the
>> skip condition was reached.
>> 
>> Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
>
> Thanks for fixing this Toke!

You're welcome! :)

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
  2020-09-29 12:30 [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id Toke Høiland-Jørgensen
  2020-09-29 12:35 ` Alan Maguire
@ 2020-09-29 18:30 ` patchwork-bot+bpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+bpf @ 2020-09-29 18:30 UTC (permalink / raw)
  To: =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2VuIDx0b2tlQHJlZGhhdC5jb20+?=; +Cc: bpf

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 29 Sep 2020 14:30:04 +0200 you wrote:
> The new test for task iteration in bpf_iter checks (in do_btf_read()) if it
> should be skipped due to missing __builtin_btf_type_id. However, this
> 'skip' verdict is not propagated to the caller, so the parent test will
> still fail. Fix this by also skipping the rest of the parent test if the
> skip condition was reached.
> 
> Fixes: b72091bd4ee4 ("selftests/bpf: Add test for bpf_seq_printf_btf helper")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id
    https://git.kernel.org/bpf/bpf-next/c/d2197c7ff171

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-29 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 12:30 [PATCH bpf-next] selftests/bpf_iter: don't fail test due to missing __builtin_btf_type_id Toke Høiland-Jørgensen
2020-09-29 12:35 ` Alan Maguire
2020-09-29 12:50   ` Toke Høiland-Jørgensen
2020-09-29 18:30 ` patchwork-bot+bpf

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).