All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] perf tests record: Fail the test if the errs counter is not zero
@ 2022-09-28 16:22 Arnaldo Carvalho de Melo
  2022-09-28 16:41 ` Ian Rogers
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2022-09-28 16:22 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Adrian Hunter, Jiri Olsa, Namhyung Kim, Linux Kernel Mailing List

We were just checking for the 'err' variable, when we should really see
if there was some of the many checked errors that don't stop the test
right away.

Detected with clang 15.0.0:

  44    75.23 fedora:37                     : FAIL clang version 15.0.0 (Fedora 15.0.0-2.fc37)

    tests/perf-record.c:68:16: error: variable 'errs' set but not used [-Werror,-Wunused-but-set-variable]
            int err = -1, errs = 0, i, wakeups = 0;
                          ^
    1 error generated.

The patch introducing this 'perf test' entry had that check:

  +       return (err < 0 || errs > 0) ? -1 : 0;

But at some point we lost that:

  -       return (err < 0 || errs > 0) ? -1 : 0;
  +       if (err == -EACCES)
  +               return TEST_SKIP;
  +       if (err < 0)
  +               return TEST_FAIL;
  +       return TEST_OK

Put it back.

Fixes: 2cf88f4614c996e5 ("perf test: Use skip in PERF_RECORD_*")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/perf-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 6a001fcfed68e517..4952abe716f318b0 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -332,7 +332,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 out:
 	if (err == -EACCES)
 		return TEST_SKIP;
-	if (err < 0)
+	if (err < 0 || errs != 0)
 		return TEST_FAIL;
 	return TEST_OK;
 }
-- 
2.37.3


----- End forwarded message -----

-- 

- Arnaldo

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

* Re: [PATCH 1/1] perf tests record: Fail the test if the errs counter is not zero
  2022-09-28 16:22 [PATCH 1/1] perf tests record: Fail the test if the errs counter is not zero Arnaldo Carvalho de Melo
@ 2022-09-28 16:41 ` Ian Rogers
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2022-09-28 16:41 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Adrian Hunter, Jiri Olsa, Namhyung Kim, Linux Kernel Mailing List

On Wed, Sep 28, 2022 at 9:22 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> We were just checking for the 'err' variable, when we should really see
> if there was some of the many checked errors that don't stop the test
> right away.
>
> Detected with clang 15.0.0:
>
>   44    75.23 fedora:37                     : FAIL clang version 15.0.0 (Fedora 15.0.0-2.fc37)
>
>     tests/perf-record.c:68:16: error: variable 'errs' set but not used [-Werror,-Wunused-but-set-variable]
>             int err = -1, errs = 0, i, wakeups = 0;
>                           ^
>     1 error generated.
>
> The patch introducing this 'perf test' entry had that check:
>
>   +       return (err < 0 || errs > 0) ? -1 : 0;
>
> But at some point we lost that:
>
>   -       return (err < 0 || errs > 0) ? -1 : 0;
>   +       if (err == -EACCES)
>   +               return TEST_SKIP;
>   +       if (err < 0)
>   +               return TEST_FAIL;
>   +       return TEST_OK
>
> Put it back.
>
> Fixes: 2cf88f4614c996e5 ("perf test: Use skip in PERF_RECORD_*")
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Apologies for that.

Acked-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/perf-record.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
> index 6a001fcfed68e517..4952abe716f318b0 100644
> --- a/tools/perf/tests/perf-record.c
> +++ b/tools/perf/tests/perf-record.c
> @@ -332,7 +332,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
>  out:
>         if (err == -EACCES)
>                 return TEST_SKIP;
> -       if (err < 0)
> +       if (err < 0 || errs != 0)
>                 return TEST_FAIL;
>         return TEST_OK;
>  }
> --
> 2.37.3
>
>
> ----- End forwarded message -----
>
> --
>
> - Arnaldo

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

end of thread, other threads:[~2022-09-28 16:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 16:22 [PATCH 1/1] perf tests record: Fail the test if the errs counter is not zero Arnaldo Carvalho de Melo
2022-09-28 16:41 ` Ian Rogers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.