linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1
@ 2024-02-22 20:07 Arnaldo Carvalho de Melo
  2024-02-23  0:02 ` Ian Rogers
  2024-02-27 17:26 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2024-02-22 20:07 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Adrian Hunter, Ian Rogers, Jiri Olsa, Linux Kernel Mailing List,
	linux-perf-users

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

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


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

* Re: [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1
  2024-02-22 20:07 [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1 Arnaldo Carvalho de Melo
@ 2024-02-23  0:02 ` Ian Rogers
  2024-02-27 17:26 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2024-02-23  0:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Adrian Hunter, Jiri Olsa, Linux Kernel Mailing List,
	linux-perf-users

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
>

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

* Re: [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1
  2024-02-22 20:07 [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1 Arnaldo Carvalho de Melo
  2024-02-23  0:02 ` Ian Rogers
@ 2024-02-27 17:26 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2024-02-27 17:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Linux Kernel Mailing List, linux-perf-users, Jiri Olsa,
	Adrian Hunter, Ian Rogers

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 <namhyung@kernel.org>

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

end of thread, other threads:[~2024-02-27 17:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 20:07 [PATCH 1/1] perf test: Use TEST_FAIL in the TEST_ASSERT macros instead of -1 Arnaldo Carvalho de Melo
2024-02-23  0:02 ` Ian Rogers
2024-02-27 17:26 ` Namhyung Kim

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