[PATCH 01/18] test: Restore test behaviour on failure
Bin Meng
bmeng.cn at gmail.com
Mon May 15 09:22:56 CEST 2023
On Sat, Apr 29, 2023 at 3:18 AM Simon Glass <sjg at chromium.org> wrote:
>
> 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")
Shouldn't this be a "git revert fa847bb409d "?
@Marek Vasut
Please comment on as this commit invalidates fa847bb409d .
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> include/test/ut.h | 36 ++++++++++++++++++------------------
> 1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/include/test/ut.h b/include/test/ut.h
> index dddf9ad241f..ea6ee95d734 100644
> --- a/include/test/ut.h
> +++ b/include/test/ut.h
> @@ -130,7 +130,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> \
> if (!(cond)) { \
> ut_fail(uts, __FILE__, __LINE__, __func__, #cond); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
> @@ -142,7 +142,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> if (!(cond)) { \
> ut_failf(uts, __FILE__, __LINE__, __func__, #cond, \
> fmt, ##args); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
> @@ -157,7 +157,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> #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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> (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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> #expr1 " = " #expr2, \
> "Expected \"%.*s\", got \"%.*s\"", \
> _len, _val1, _len, _val2); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
> @@ -228,7 +228,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> #expr1 " = " #expr2, \
> "Expected \"%s\", got \"%s\"", \
> __buf1, __buf2); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
> @@ -242,7 +242,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> #expr " = NULL", \
> "Expected pointer, got error %ld", \
> PTR_ERR(_val)); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
> @@ -316,7 +316,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> 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 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
> "console", \
> "Expected dump of length %x bytes, got '%s'", \
> total_bytes, uts->actual_str); \
> - __ret = CMD_RET_FAILURE; \
> + return CMD_RET_FAILURE; \
> } \
> __ret; \
> })
Regards,
Bin
More information about the U-Boot
mailing list