2024-02-22 20:07:31

by Arnaldo Carvalho de Melo

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

Just to make things clearer, return TEST_FAIL (-1) instead of an open
coded -1.

Cc: Adrian Hunter <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
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



2024-02-23 00:02:33

by Ian Rogers

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

On Thu, Feb 22, 2024 at 12:07 PM Arnaldo Carvalho de Melo
<[email protected]> wrote:
>
> Just to make things clearer, return TEST_FAIL (-1) instead of an open
> coded -1.
>
> Cc: Adrian Hunter <[email protected]>
> Cc: Ian Rogers <[email protected]>
> Cc: Jiri Olsa <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

Reviewed-by: Ian Rogers <[email protected]>

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
>

2024-02-27 18:07:35

by Namhyung Kim

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

On Thu, 22 Feb 2024 17:07:20 -0300, Arnaldo Carvalho de Melo wrote:
> Just to make things clearer, return TEST_FAIL (-1) instead of an open
> coded -1.
>
>

Applied to perf-tools-next, thanks!

Best regards,
--
Namhyung Kim <[email protected]>