bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests
@ 2020-08-21 15:08 Jesper Dangaard Brouer
  2020-08-21 19:18 ` Andrii Nakryiko
  2020-08-21 19:45 ` Alexei Starovoitov
  0 siblings, 2 replies; 4+ messages in thread
From: Jesper Dangaard Brouer @ 2020-08-21 15:08 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, bpf; +Cc: Daniel Borkmann, Alexei Starovoitov, yhs

Commit 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of
tests") introduced ability to getting number of tests, which is targeted
towards scripting.  As demonstrate in the commit the number can be use as a
shell variable for further scripting.

The test_progs program support "flavor", which is detected by the binary
have a "-flavor" in the executable name. One example is test_progs-no_alu32,
which load bpf-progs compiled with disabled alu32, located in dir 'no_alu32/'.

The problem is that invoking a "flavor" binary prints to stdout e.g.:
 "Switching to flavor 'no_alu32' subdirectory..."
Thus, intermixing with the number of tests, making it unusable for scripting.

Fix the issue by printing "flavor" info to stderr instead of stdout.

Fixes: 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of tests")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 tools/testing/selftests/bpf/test_progs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index b1e4dadacd9b..d858e883bd75 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -618,7 +618,7 @@ int cd_flavor_subdir(const char *exec_name)
 	if (!flavor)
 		return 0;
 	flavor++;
-	fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
+	fprintf(stderr, "Switching to flavor '%s' subdirectory...\n", flavor);
 	return chdir(flavor);
 }
 



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

* Re: [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests
  2020-08-21 15:08 [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests Jesper Dangaard Brouer
@ 2020-08-21 19:18 ` Andrii Nakryiko
  2020-08-21 19:45 ` Alexei Starovoitov
  1 sibling, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2020-08-21 19:18 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: bpf, Daniel Borkmann, Alexei Starovoitov, Yonghong Song

On Fri, Aug 21, 2020 at 8:09 AM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> Commit 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of
> tests") introduced ability to getting number of tests, which is targeted
> towards scripting.  As demonstrate in the commit the number can be use as a
> shell variable for further scripting.
>
> The test_progs program support "flavor", which is detected by the binary
> have a "-flavor" in the executable name. One example is test_progs-no_alu32,
> which load bpf-progs compiled with disabled alu32, located in dir 'no_alu32/'.
>
> The problem is that invoking a "flavor" binary prints to stdout e.g.:
>  "Switching to flavor 'no_alu32' subdirectory..."
> Thus, intermixing with the number of tests, making it unusable for scripting.
>
> Fix the issue by printing "flavor" info to stderr instead of stdout.
>
> Fixes: 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of tests")
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  tools/testing/selftests/bpf/test_progs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index b1e4dadacd9b..d858e883bd75 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -618,7 +618,7 @@ int cd_flavor_subdir(const char *exec_name)
>         if (!flavor)
>                 return 0;
>         flavor++;
> -       fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
> +       fprintf(stderr, "Switching to flavor '%s' subdirectory...\n", flavor);
>         return chdir(flavor);
>  }
>
>
>

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

* Re: [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests
  2020-08-21 15:08 [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests Jesper Dangaard Brouer
  2020-08-21 19:18 ` Andrii Nakryiko
@ 2020-08-21 19:45 ` Alexei Starovoitov
  2020-08-24 11:57   ` Jesper Dangaard Brouer
  1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2020-08-21 19:45 UTC (permalink / raw)
  To: Jesper Dangaard Brouer; +Cc: bpf, Daniel Borkmann, Yonghong Song

On Fri, Aug 21, 2020 at 8:08 AM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> Commit 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of
> tests") introduced ability to getting number of tests, which is targeted
> towards scripting.  As demonstrate in the commit the number can be use as a
> shell variable for further scripting.
>
> The test_progs program support "flavor", which is detected by the binary
> have a "-flavor" in the executable name. One example is test_progs-no_alu32,
> which load bpf-progs compiled with disabled alu32, located in dir 'no_alu32/'.
>
> The problem is that invoking a "flavor" binary prints to stdout e.g.:
>  "Switching to flavor 'no_alu32' subdirectory..."
> Thus, intermixing with the number of tests, making it unusable for scripting.
>
> Fix the issue by printing "flavor" info to stderr instead of stdout.
>
> Fixes: 643e7233aa94 ("selftests/bpf: Test_progs option for getting number of tests")
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index b1e4dadacd9b..d858e883bd75 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -618,7 +618,7 @@ int cd_flavor_subdir(const char *exec_name)
>         if (!flavor)
>                 return 0;
>         flavor++;
> -       fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
> +       fprintf(stderr, "Switching to flavor '%s' subdirectory...\n", flavor);

Hmm. May be move it under -v flag instead?
The person or script that runs test_progs-no_alu32 knows what's happening.
That message either to stdout or stderr will be fine under extra verbose flag.

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

* Re: [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests
  2020-08-21 19:45 ` Alexei Starovoitov
@ 2020-08-24 11:57   ` Jesper Dangaard Brouer
  0 siblings, 0 replies; 4+ messages in thread
From: Jesper Dangaard Brouer @ 2020-08-24 11:57 UTC (permalink / raw)
  To: Alexei Starovoitov; +Cc: bpf, Daniel Borkmann, Yonghong Song, brouer

On Fri, 21 Aug 2020 12:45:08 -0700
Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote:

> > diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> > index b1e4dadacd9b..d858e883bd75 100644
> > --- a/tools/testing/selftests/bpf/test_progs.c
> > +++ b/tools/testing/selftests/bpf/test_progs.c
> > @@ -618,7 +618,7 @@ int cd_flavor_subdir(const char *exec_name)
> >         if (!flavor)
> >                 return 0;
> >         flavor++;
> > -       fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
> > +       fprintf(stderr, "Switching to flavor '%s' subdirectory...\n", flavor);  
> 
> Hmm. May be move it under -v flag instead?
> The person or script that runs test_progs-no_alu32 knows what's happening.
> That message either to stdout or stderr will be fine under extra verbose flag.

Sounds good to me with a -v flag, sending V2

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


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

end of thread, other threads:[~2020-08-24 11:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 15:08 [PATCH bpf] selftests/bpf: Fix test_progs-flavor run getting number of tests Jesper Dangaard Brouer
2020-08-21 19:18 ` Andrii Nakryiko
2020-08-21 19:45 ` Alexei Starovoitov
2020-08-24 11:57   ` Jesper Dangaard Brouer

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