Skip to content

Commit e051cdf

Browse files
cris-mashuahkh
authored andcommitted
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>
1 parent b919918 commit e051cdf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/testing/selftests/openat2/helpers.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ bool needs_openat2(const struct open_how *how);
6262
(similar to chroot(2)). */
6363
#endif /* RESOLVE_IN_ROOT */
6464

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); \
7071
} while (0)
7172

7273
#define E_asprintf(...) E_func(asprintf, __VA_ARGS__)

0 commit comments

Comments
 (0)