@@ -346,10 +346,10 @@ static void tst_print(const char *tcid, int tnum, int ttype, const char *tmesg)
}
if (ttype & TRERRNO) {
+ err = TEST_RETURN < 0 ? -(int)TEST_RETURN : (int)TEST_RETURN;
size += snprintf(message + size, sizeof(message) - size,
": TEST_RETURN=%s(%i): %s",
- tst_strerrno(TEST_RETURN), (int)TEST_RETURN,
- strerror(TEST_RETURN));
+ tst_strerrno(err), err, strerror(err));
}
if (size + 1 >= sizeof(message)) {
@@ -215,6 +215,11 @@ static void print_result(const char *file, const int lineno, int ttype,
if (ttype & TTERRNO)
str_errno = tst_strerrno(TEST_ERRNO);
+ if (ttype & TRERRNO) {
+ ret = TEST_RETURN < 0 ? -(int)TEST_RETURN : (int)TEST_RETURN;
+ str_errno = tst_strerrno(ret);
+ }
+
ret = snprintf(str, size, "%s:%i: ", file, lineno);
str += ret;
size -= ret;
Some system calls and libraries pass the error code back to the user in the return value. Sometimes it is inverted, sometimes not. This allows TRERRNO to be passed to tst_res which then causes it to print the error code in TEST_RETURN. Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> --- I think we have to branch on TEST_RETURN < 0 because of two's complement integer representation, but I could be missing a trick here. lib/tst_res.c | 4 ++-- lib/tst_test.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-)