Re: [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1

From: Ian Rogers
Date: Thu Feb 22 2024 - 19:02:32 EST


On Thu, Feb 22, 2024 at 12:07 PM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> Just to make things clearer, return TEST_FAIL (-1) instead of an open
> coded -1.
>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Ian Rogers <irogers@xxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>

Thanks,
Ian

> ---
> tools/perf/tests/tests.h | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
> index dad3d7414142d1be..3aa7701ee0e939f7 100644
> --- a/tools/perf/tests/tests.h
> +++ b/tools/perf/tests/tests.h
> @@ -4,11 +4,17 @@
>
> #include <stdbool.h>
>
> +enum {
> + TEST_OK = 0,
> + TEST_FAIL = -1,
> + TEST_SKIP = -2,
> +};
> +
> #define TEST_ASSERT_VAL(text, cond) \
> do { \
> if (!(cond)) { \
> pr_debug("FAILED %s:%d %s\n", __FILE__, __LINE__, text); \
> - return -1; \
> + return TEST_FAIL; \
> } \
> } while (0)
>
> @@ -17,16 +23,10 @@ do { \
> if (val != expected) { \
> pr_debug("FAILED %s:%d %s (%d != %d)\n", \
> __FILE__, __LINE__, text, val, expected); \
> - return -1; \
> + return TEST_FAIL; \
> } \
> } while (0)
>
> -enum {
> - TEST_OK = 0,
> - TEST_FAIL = -1,
> - TEST_SKIP = -2,
> -};
> -
> struct test_suite;
>
> typedef int (*test_fnptr)(struct test_suite *, int);
> --
> 2.43.0
>