Skip to contentSkip to conversation

syscalls/io_submit: Add TTERRNO/TERRNO when test fail

PATCH zhaogongyi via ltp 2 participants 2 messages Apr 19, 2022

lore
Share & tools
lore
#0 lore raw

Hi Cyril,

Quoted 25 lines

Hi!

Quoted 12 lines
---
 testcases/kernel/syscalls/io_submit/io_submit01.c | 2 +-
testcases/kernel/syscalls/io_submit/io_submit02.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/io_submit/io_submit01.c +0 -0
index db541fc01..ba75f6d81 100644

testcases/kernel/syscalls/io_submit/io_submit01.c static void verify_io_submit(unsigned int n) · line 136

Quoted 8 lines
testcases/kernel/syscalls/io_submit/io_submit01.c +2 -1
@@ -130,7 +130,7 @@ static void verify_io_submit(unsigned int n)
 		return;
 	}
 
-	tst_res(TFAIL, "io_submit() returned %i(%s), expected %s(%i)",
+	tst_res(TFAIL | TERRNO, "io_submit() returned %i(%s), expected
+%s(%i)",
 		ret, ret < 0 ? tst_strerrno(-ret) : "SUCCESS",
 		errno_name(t->exp_errno), t->exp_errno);  }

NACK.

Quoted 2 lines

As far as I can tell the io_submit() calls returns negative error instead of setting errno, at least that's what libaio documentation states.

Yes, according to linux manual, libaio interface don't set errno when calling failed, so, do we also need to remove the TREENO here?

80 TEST(io_setup(1, &ctx));
81 if (TST_RET == -ENOSYS)
82 tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
83 else if (TST_RET)
84 tst_brk(TBROK | TRERRNO, "io_setup() failed");

Quoted 12 lines

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 82

Quoted 11 lines
testcases/kernel/syscalls/io_submit/io_submit02.c +0 -1
index 38b8555d8..6ba4d99a5 100644
@@ -79,7 +79,7 @@ static void run(unsigned int i)
 	if (TST_RET == tc[i].nr)
 		tst_res(TPASS, "io_submit() %s", tc[i].desc);
 	else
-		tst_res(TFAIL, "io_submit() returns %ld, expected %ld", TST_RET,

tc[i].nr);

Quoted 6 lines

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 82

Quoted 1 line
testcases/kernel/syscalls/io_submit/io_submit02.c +1 -0
+		tst_res(TFAIL | TTERRNO, "io_submit() returns %ld,

expected %ld",

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 83

Quoted 1 line
testcases/kernel/syscalls/io_submit/io_submit02.c +1 -0
+TST_RET, tc[i].nr);

The best we can do here is to use tst_strerrno() to print the error as we do in the io_submit().

According to linux manual, call io_submit through syscall, it will set errno:
"If the system call is invoked via syscall(2), then the return value follows the usual conventions for indicating an error: -1, with errno set to a
(positive) value that indicates the error."

Quoted 13 lines
Quoted 9 lines
testcases/kernel/syscalls/io_submit/io_submit02.c +0 -1
 	for (j = 0; j < TST_RET; j++) {
 		tst_syscall(__NR_io_getevents, *tc[i].ctx, 1, 1, &evbuf,
--

2.17.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

--
Cyril Hrubis
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 6 lines
Quoted 5 lines

NACK.

As far as I can tell the io_submit() calls returns negative error instead of setting errno, at least that's what libaio documentation states.

Quoted 7 lines

Yes, according to linux manual, libaio interface don't set errno when calling failed, so, do we also need to remove the TREENO here?

80 TEST(io_setup(1, &ctx));
81 if (TST_RET == -ENOSYS)
82 tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
83 else if (TST_RET)
84 tst_brk(TBROK | TRERRNO, "io_setup() failed");

Yes please, this should be replaced by manually printing tst_strerrno(-TST_RET).

Quoted 13 lines
Quoted 13 lines

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 82

Quoted 10 lines
testcases/kernel/syscalls/io_submit/io_submit02.c +0 -1
index 38b8555d8..6ba4d99a5 100644
@@ -79,7 +79,7 @@ static void run(unsigned int i)
 	if (TST_RET == tc[i].nr)
 		tst_res(TPASS, "io_submit() %s", tc[i].desc);
 	else
-		tst_res(TFAIL, "io_submit() returns %ld, expected %ld", TST_RET,

tc[i].nr);

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 82

Quoted 1 line
testcases/kernel/syscalls/io_submit/io_submit02.c +1 -0
+		tst_res(TFAIL | TTERRNO, "io_submit() returns %ld,

expected %ld",

Quoted 8 lines
Quoted 4 lines

testcases/kernel/syscalls/io_submit/io_submit02.c static void run(unsigned int i) · line 83

Quoted 1 line
testcases/kernel/syscalls/io_submit/io_submit02.c +1 -0
+TST_RET, tc[i].nr);

The best we can do here is to use tst_strerrno() to print the error as we do in the io_submit().

According to linux manual, call io_submit through syscall, it will set errno:
"If the system call is invoked via syscall(2), then the return value follows the usual conventions for indicating an error: -1, with errno set to a
(positive) value that indicates the error."

Ah right, as long as we use the syscall() wrapper the negative error return value will be moved to the errno variable by the wrapper, so this part is correct.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp