Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: openat2: Print also errno in failure messages

In E_func() macro, on error, print also errno in order to aid debugging.

Cc: Aleksa Sarai <cyphar@cyphar.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Cristian Marussi and committed by
Shuah Khan
e051cdf6 b9199181

+6 -5
+6 -5
tools/testing/selftests/openat2/helpers.h
··· 62 62 (similar to chroot(2)). */ 63 63 #endif /* RESOLVE_IN_ROOT */ 64 64 65 - #define E_func(func, ...) \ 66 - do { \ 67 - if (func(__VA_ARGS__) < 0) \ 68 - ksft_exit_fail_msg("%s:%d %s failed\n", \ 69 - __FILE__, __LINE__, #func);\ 65 + #define E_func(func, ...) \ 66 + do { \ 67 + errno = 0; \ 68 + if (func(__VA_ARGS__) < 0) \ 69 + ksft_exit_fail_msg("%s:%d %s failed - errno:%d\n", \ 70 + __FILE__, __LINE__, #func, errno); \ 70 71 } while (0) 71 72 72 73 #define E_asprintf(...) E_func(asprintf, __VA_ARGS__)