Skip to contentSkip to conversation

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

PATCH Applied Arnaldo Carvalho de Melo 3 participants 3 messages Feb 22, 2024 – Feb 27, 2024 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

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]>
---
 tools/perf/tests/tests.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/tests/tests.h +8 -8
index dad3d7414142d1be..3aa7701ee0e939f7 100644
@@ -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);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnaldo Carvalho de Melo

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]>

Thanks,
Ian

Quoted 48 lines
---
 tools/perf/tests/tests.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tools/perf/tests/tests.h +8 -9
index dad3d7414142d1be..3aa7701ee0e939f7 100644
@@ -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