Skip to contentSkip to conversation

io_destroy01: TCONF when unsupported

PATCH New Petr Vorel 4 participants 11 messages Sep 29, 2020 – Sep 30, 2020

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

---
Hi,

simple patch, but can wait after release.
I can move cleanup into separate commit.

Kind regards,
Petr

 testcases/kernel/syscalls/io_destroy/io_destroy01.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/io_destroy/io_destroy01.c +9 -4
index 560d7b3fb..5c5c59335 100644
@@ -32,14 +32,19 @@ static void verify_io_destroy(void)
 		return;
 	}
 
+	if (TST_RET == -ENOSYS) {
+		tst_res(TCONF, "io_destroy() not supported");
+		return;
+	}
+
 	if (TST_RET == -EINVAL) {
 		tst_res(TPASS,
 			"io_destroy() failed as expected, returned -EINVAL");
-	} else {
-		tst_res(TFAIL, "io_destroy() failed unexpectedly, "
-			"returned -%s expected -EINVAL",
-			tst_strerrno(-TST_RET));
+		return;
 	}
+
+	tst_res(TFAIL, "io_destroy() failed unexpectedly, returned -%s expected -EINVAL",
+		tst_strerrno(-TST_RET));
 }
 
 static struct tst_test test = {
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi Petr
Why not using kconfig in tst_test struct.

Best Regards
Yang Xu

Quoted 45 lines

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

---
Hi,

simple patch, but can wait after release.
I can move cleanup into separate commit.

Kind regards,
Petr

  testcases/kernel/syscalls/io_destroy/io_destroy01.c | 13 +++++++++----
  1 file changed, 9 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/io_destroy/io_destroy01.c +9 -4
index 560d7b3fb..5c5c59335 100644
@@ -32,14 +32,19 @@ static void verify_io_destroy(void)
  		return;
  	}
 
+	if (TST_RET == -ENOSYS) {
+		tst_res(TCONF, "io_destroy() not supported");
+		return;
+	}
+
  	if (TST_RET == -EINVAL) {
  		tst_res(TPASS,
  			"io_destroy() failed as expected, returned -EINVAL");
-	} else {
-		tst_res(TFAIL, "io_destroy() failed unexpectedly, "
-			"returned -%s expected -EINVAL",
-			tst_strerrno(-TST_RET));
+		return;
  	}
+
+	tst_res(TFAIL, "io_destroy() failed unexpectedly, returned -%s expected -EINVAL",
+		tst_strerrno(-TST_RET));
  }
 
  static struct tst_test test = {
author
#2 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi Yang,

Quoted 2 lines

Hi Petr
Why not using kconfig in tst_test struct.

We should probably use tst_syscall().
But using kconfig is not 1) needed (tst_syscall() most reliable way) 2) kconfig requires having kernel config available, which is not on some platforms.

(I plan to introduce TWARN_IF_NO_CONFIG to print only warning for platforms which don't have kconfig available, see
https://github.com/linux-test-project/ltp/issues/700).

Kind regards,
Petr

#3 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi Petr

Quoted 8 lines

Hi Yang,

Quoted 2 lines

Hi Petr
Why not using kconfig in tst_test struct.

We should probably use tst_syscall().
But using kconfig is not 1) needed (tst_syscall() most reliable way) 2) kconfig requires having kernel config available, which is not on some platforms.

I see. At the first, I prefer to like to use kconfig because it only tests io_destory one time on kernel without CONFIG_AIO when we use -i parameters, but using libaio wrapper is stable. So it is ok.

Quoted 4 lines

(I plan to introduce TWARN_IF_NO_CONFIG to print only warning for platforms which don't have kconfig available, see
https://github.com/linux-test-project/ltp/issues/700).

I have seen this ticket, if I understand it corretly,

if platform has kernel config without needed kconfig, test cases still will report TCONF

if platform doesn't have kernel config, test cases only reports warning(system doesn't have kernel config file) and continue to run test and it maybe lead to a unexpected stat/failure. And we don't add extra check in tests case such as ENOSYS/EINVAL check because it is redundant against kconfig check.

Best Regards
Yang Xu

Quoted 7 lines

Kind regards,
Petr

.

#4 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hello,

Quoted 7 lines · Yang Xu

Hi Petr

Quoted 5 lines

Hi Yang,

Quoted 2 lines

Hi Petr
Why not using kconfig in tst_test struct.

Quoted 6 lines
Quoted 3 lines

We should probably use tst_syscall().
But using kconfig is not 1) needed (tst_syscall() most reliable way) 2) kconfig requires having kernel config available, which is not on some platforms.

I see. At the first, I prefer to like to use kconfig because it only tests io_destory one time on kernel without CONFIG_AIO when we use -i parameters, but using libaio wrapper is stable. So it is ok.

Kconfig can even be wrong (most likely with out-of-tree patches) or we might look at the wrong option as things are moved around sometimes. This is another instance of us trying to guess if something can be done without trying it.

I guess there are some things where it is not as simple as trying a system call, but in cases where ENOSYS will be returned there is no need to look at the config except maybe for diagnostic purposes. If you are concerned about '-i' then you can even just make in invalid syscall in setup to see what error it returns.

Signature · 2 lines
Thank you,
Richard.
author
#5 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi,

Quoted 21 lines
Quoted 7 lines · Yang Xu

Hi Petr

Quoted 4 lines

Hi Yang,

Quoted 2 lines

Hi Petr
Why not using kconfig in tst_test struct.

Quoted 6 lines
Quoted 3 lines

We should probably use tst_syscall().
But using kconfig is not 1) needed (tst_syscall() most reliable way) 2) kconfig requires having kernel config available, which is not on some platforms.

I see. At the first, I prefer to like to use kconfig because it only tests io_destory one time on kernel without CONFIG_AIO when we use -i parameters, but using libaio wrapper is stable. So it is ok.

Kconfig can even be wrong (most likely with out-of-tree patches) or we might look at the wrong option as things are moved around sometimes. This is another instance of us trying to guess if something can be done without trying it.

Quoted 5 lines

I guess there are some things where it is not as simple as trying a system call, but in cases where ENOSYS will be returned there is no need to look at the config except maybe for diagnostic purposes. If you are concerned about '-i' then you can even just make in invalid syscall in setup to see what error it returns.

@Yang: Yes, have a look at various foo_supported_by_kernel() helper functions in include/lapi/ (added by Viresh Kumar).

Kind regards,
Petr

#6 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

In reply to Yang Xu

Hi!

Quoted 1 line

Why not using kconfig in tst_test struct.

Well because this is much simpler and does the same job.

There is a different case for kconfig, i.e. some people would like to be able to syntetize kconfig for testing by extracting the data from tests, but that is completely different problem and would need a different solution.

Signature · 2 lines
Cyril Hrubis
[email protected]
#7 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

In reply to Petr Vorel

Hi!

Quoted 3 lines

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

This is both obviously ok, but the cleanup should be in a separate patch.

You can add my reviewed-by if you split the patch into two.

Also is this the only io_* test that fails?

Looking at the testcases we have the io_setup01 that looks like it will fail with TBROK if io_setup() returns -ENOSYS.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#8 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi Cyril,

Quoted 7 lines

Hi!

Quoted 3 lines

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

This is both obviously ok, but the cleanup should be in a separate patch.

+1, I'll do.
I suggested to use tst_syscall(), but we probably want here to use libc wrapper I guess, thus I'll merge this (split into 2 commits).

Quoted 6 lines

You can add my reviewed-by if you split the patch into two.

Also is this the only io_* test that fails?

Looking at the testcases we have the io_setup01 that looks like it will fail with TBROK if io_setup() returns -ENOSYS.

Thanks, I'll send a separate patch for this.

Kind regards,
Petr

#9 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi!

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

This is both obviously ok, but the cleanup should be in a separate patch.

+1, I'll do.
I suggested to use tst_syscall(), but we probably want here to use libc wrapper

These are from libaio library, which is why they return negative errors instead of setting errno.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#10 lore raw

PATCH 1/1 io_destroy01: TCONF when unsupported

Hi,

Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

to fix test on kernel built without CONFIG_AIO=y.

Cleanup: use return instead of else, join string.

This is both obviously ok, but the cleanup should be in a separate patch.

+1, I'll do.
I suggested to use tst_syscall(), but we probably want here to use libc wrapper

These are from libaio library, which is why they return negative errors instead of setting errno.

Right, thanks for info.

Merged fixed version (2 commits).

Kind regards,
Petr