test: Restore test behaviour on failure
A recent change makes test continue to run after failure. This results in
a lot of useless output and may lead to a segfault. Fix this by adding
back the 'return' statement.
Fixes: fa847bb409d ("test: Wrap assert macros in ({ ... }) and fix")
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/include/test/ut.h b/include/test/ut.h
index dddf9ad..ea6ee95 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -130,7 +130,7 @@
\
if (!(cond)) { \
ut_fail(uts, __FILE__, __LINE__, __func__, #cond); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -142,7 +142,7 @@
if (!(cond)) { \
ut_failf(uts, __FILE__, __LINE__, __func__, #cond, \
fmt, ##args); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -157,7 +157,7 @@
#expr1 " == " #expr2, \
"Expected %#x (%d), got %#x (%d)", \
_val1, _val1, _val2, _val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -175,7 +175,7 @@
(unsigned long long)_val1, \
(unsigned long long)_val2, \
(unsigned long long)_val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -189,7 +189,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr1 " = " #expr2, \
"Expected \"%s\", got \"%s\"", _val1, _val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -208,7 +208,7 @@
#expr1 " = " #expr2, \
"Expected \"%.*s\", got \"%.*s\"", \
_len, _val1, _len, _val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -228,7 +228,7 @@
#expr1 " = " #expr2, \
"Expected \"%s\", got \"%s\"", \
__buf1, __buf2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -242,7 +242,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr1 " = " #expr2, \
"Expected %p, got %p", _val1, _val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -257,7 +257,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr1 " = " #expr2, \
"Expected %lx, got %lx", _val1, _val2); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -271,7 +271,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr " != NULL", \
"Expected NULL, got %p", _val); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -285,7 +285,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
#expr " = NULL", \
"Expected non-null, got NULL"); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -300,7 +300,7 @@
#expr " = NULL", \
"Expected pointer, got error %ld", \
PTR_ERR(_val)); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -316,7 +316,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
"console", "\nExpected '%s',\n got '%s'", \
uts->expect_str, uts->actual_str); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -329,7 +329,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
"console", "\nExpected '%s',\n got '%s'", \
uts->expect_str, uts->actual_str); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -341,7 +341,7 @@
if (ut_check_skipline(uts)) { \
ut_failf(uts, __FILE__, __LINE__, __func__, \
"console", "\nExpected a line, got end"); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -354,7 +354,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
"console", "\nExpected '%s',\n got to '%s'", \
uts->expect_str, uts->actual_str); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -367,7 +367,7 @@
ut_failf(uts, __FILE__, __LINE__, __func__, \
"console", "Expected no more output, got '%s'",\
uts->actual_str); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})
@@ -381,7 +381,7 @@
"console", \
"Expected dump of length %x bytes, got '%s'", \
total_bytes, uts->actual_str); \
- __ret = CMD_RET_FAILURE; \
+ return CMD_RET_FAILURE; \
} \
__ret; \
})