On 03/10/2023 07:41, Chaitanya S Prakash wrote:
VERIFY_ERRNO() macro is added to perform error handling. It is used to print the return value if the syscall fails with an error code other than what is expected.
Signed-off-by: Chaitanya S Prakash chaitanyas.prakash@arm.com
tools/testing/selftests/arm64/morello/mmap.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/arm64/morello/mmap.c b/tools/testing/selftests/arm64/morello/mmap.c index 18b0cc6b3549..b04c754369b6 100644 --- a/tools/testing/selftests/arm64/morello/mmap.c +++ b/tools/testing/selftests/arm64/morello/mmap.c @@ -19,6 +19,13 @@ #define PROBE_MODE_TOUCH 0x01 #define PROBE_MODE_VERIFY 0x02 +#define VERIFY_ERRNO(ret_val, expected_errno) \
- do { \
if (ret_val != expected_errno) { \
TH_LOG("Syscall failed with: %ld", (unsigned long)ret_val); \
} \
- } while (0)
I'm not sure I see much value in this macro, compared to simply using EXPECT_EQ() or ASSERT_EQ() as appropriate, depending on whether we want to abort or not. They will print both the expected and actual value, as well as the current line; together these allow understanding what happened and where. For unexpected error messages, this is what matters most.
On closer inspection, it looks like our current implementation of __EXPECT() does not print the actual values, just the argument names. I'll make a note to fix that (making it closer to tools/testing/selftests/kselftest_harness.h).
Kevin
static struct initial_data reg_data; static unsigned long pagesize;