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

Message ID ZdepeMsjagbf1ufD@x1
State New
Headers
Series [1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1 |

Commit Message

Arnaldo Carvalho de Melo Feb. 22, 2024, 8:07 p.m. UTC
  Just to make things clearer, return TEST_FAIL (-1) instead of an open
coded -1.

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/tests.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
  

Comments

Ian Rogers Feb. 23, 2024, 12:02 a.m. UTC | #1
On Thu, Feb 22, 2024 at 12:07 PM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> Just to make things clearer, return TEST_FAIL (-1) instead of an open
> coded -1.
>
> 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>

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

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
>
  
Namhyung Kim Feb. 27, 2024, 5:26 p.m. UTC | #2
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,
  

Patch

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