On 13/10/2023 10:02, Kevin Brodsky wrote:
__EXPECT() currently prints the stringified arguments on failure but not their value, which is not very helpful.
Let's use the same message as the original macro in kselftest_harness.h, printing the values too. For simplicity's sake they are always printed as signed, which is generally appropriate (only 64-bit unsigned values with the top bit set are an issue, and these are rarely encountered).
I guess that will be pretty rare. Although since the code to output the correct signedness is already there[1] it's not *that* much more complicated. Maybe it will save some confusion in future and always correct seems better than mostly correct :)
1: i.e. the switch case in kselftest_harness.h __EXPECT def: switch (is_signed_type(__exp) * 2 + is_signed_type(__seen)) { [...]
Best, Zach
Signed-off-by: Kevin Brodsky kevin.brodsky@arm.com
tools/testing/selftests/arm64/morello/freestanding.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/freestanding.h b/tools/testing/selftests/arm64/morello/freestanding.h index 2beb52eafae1..8dab905d2b54 100644 --- a/tools/testing/selftests/arm64/morello/freestanding.h +++ b/tools/testing/selftests/arm64/morello/freestanding.h @@ -91,8 +91,12 @@ int __attribute__ ((format(printf, 1, 2))) printf(const char *fmt, ...); /* this macro emulates its harness counterpart but is not API compatible */ #define __EXPECT(exp, seen, op, exit_on_fail) \ do { \
if (!((exp) op (seen))) { \
__TH_LOG_ERROR("'(%s) %s (%s)' was false", #exp, #op, #seen); \
__typeof__(exp) __exp = (exp); \
__typeof__(seen) __seen = (seen); \
if (!((__exp) op (__seen))) { \
__TH_LOG_ERROR("Expected %s (%lld) %s %s (%lld)", \
#exp, (long long)__exp, #op, \
} \ } while (0); \#seen, (long long)__seen); \ __cur_test->message = 1; \