All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
@ 2022-03-28 11:49 Zhao Gongyi via ltp
  2022-04-05 14:07 ` Petr Vorel
  0 siblings, 1 reply; 7+ messages in thread
From: Zhao Gongyi via ltp @ 2022-03-28 11:49 UTC (permalink / raw)
  To: ltp; +Cc: viresh.kumar

For io_submit01, add io_destroy before test return, or the test
would fail and report EAGAIN.
For io_submit02, move the io_destroy to the suitable location, or
the test would fail and report EAGAIN.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 .../kernel/syscalls/io_submit/io_submit01.c    | 18 ++++++++++++------
 .../kernel/syscalls/io_submit/io_submit02.c    |  9 ++++++---
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
index 28d93d7f1..7931c583b 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit01.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
@@ -77,12 +77,6 @@ static struct tcase {

 static void setup(void)
 {
-	TEST(io_setup(1, &ctx));
-	if (TST_RET == -ENOSYS)
-		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
-	else if (TST_RET)
-		tst_brk(TBROK | TRERRNO, "io_setup() failed");
-
 	io_prep_pread(&inv_fd_iocb, -1, buf, sizeof(buf), 0);

 	rdonly_fd = SAFE_OPEN("rdonly_file", O_RDONLY | O_CREAT, 0777);
@@ -116,8 +110,20 @@ static void verify_io_submit(unsigned int n)
 	struct tcase *t = &tcases[n];
 	int ret;

+	memset(&ctx, 0, sizeof(ctx));
+	TEST(io_setup(1, &ctx));
+	if (TST_RET == -ENOSYS)
+		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
+	else if (TST_RET)
+		tst_brk(TBROK | TRERRNO, "io_setup() failed");
+
 	ret = io_submit(*t->ctx, t->nr, t->iocbs);

+	TEST(io_destroy(ctx));
+	if (TST_RET) {
+		tst_brk(TBROK | TRERRNO, "io_destroy() failed");
+	}
+
 	if (ret == t->exp_errno) {
 		tst_res(TPASS, "io_submit() with %s failed with %s",
 			t->desc, errno_name(t->exp_errno));
diff --git a/testcases/kernel/syscalls/io_submit/io_submit02.c b/testcases/kernel/syscalls/io_submit/io_submit02.c
index acb42cb8f..ac32d254e 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit02.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit02.c
@@ -54,7 +54,6 @@ static inline void io_prep_option(struct iocb *cb, int fd, void *buf,

 static void setup(void)
 {
-	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
 	fd = SAFE_OPEN(TEST_FILE, O_RDONLY | O_CREAT, MODE);
 	io_prep_option(&iocb, fd, buf, 0, 0, IOCB_CMD_PREAD);
 }
@@ -64,18 +63,22 @@ static void cleanup(void)
 	if (fd > 0)
 		SAFE_CLOSE(fd);

-	if (tst_syscall(__NR_io_destroy, ctx))
-		tst_brk(TBROK | TERRNO, "io_destroy() failed");
 }

 static void run(unsigned int i)
 {
+	memset(tc[i].ctx, 0, sizeof(aio_context_t));
+	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
+
 	TEST(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs));

 	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);
+
+	if (tst_syscall(__NR_io_destroy, ctx))
+		tst_brk(TBROK | TERRNO, "io_destroy() failed");
 }

 static struct tst_test test = {
--
2.17.1


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
  2022-03-28 11:49 [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i" Zhao Gongyi via ltp
@ 2022-04-05 14:07 ` Petr Vorel
  2022-04-08  3:58   ` Li Wang
  2022-04-08 16:36   ` Martin Doucha
  0 siblings, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2022-04-05 14:07 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: viresh.kumar, Martin Doucha, ltp

Hi all,

> For io_submit01, add io_destroy before test return, or the test
> would fail and report EAGAIN.
> For io_submit02, move the io_destroy to the suitable location, or
> the test would fail and report EAGAIN.

$ ./io_submit01 -i150
...
io_submit01.c:122: TPASS: io_submit() with NULL iocb pointers failed with EFAULT
io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected SUCCESS(1)

$ ./io_submit02 -i150
...
io_submit02.c:76: TPASS: io_submit() returns 0 if nr is zero
io_submit02.c:78: TFAIL: io_submit() returns -1, expected 1

@Cyril, Li, Martin, Viresh: while this fix is valid using memset() (which is required)
slows down testing a lot. Any idea whether this can be avoid to keep the speed?

Kind regards,
Petr

> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
>  .../kernel/syscalls/io_submit/io_submit01.c    | 18 ++++++++++++------
>  .../kernel/syscalls/io_submit/io_submit02.c    |  9 ++++++---
>  2 files changed, 18 insertions(+), 9 deletions(-)

> diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
> index 28d93d7f1..7931c583b 100644
> --- a/testcases/kernel/syscalls/io_submit/io_submit01.c
> +++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
> @@ -77,12 +77,6 @@ static struct tcase {

>  static void setup(void)
>  {
> -	TEST(io_setup(1, &ctx));
> -	if (TST_RET == -ENOSYS)
> -		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
> -	else if (TST_RET)
> -		tst_brk(TBROK | TRERRNO, "io_setup() failed");
> -
>  	io_prep_pread(&inv_fd_iocb, -1, buf, sizeof(buf), 0);

>  	rdonly_fd = SAFE_OPEN("rdonly_file", O_RDONLY | O_CREAT, 0777);
> @@ -116,8 +110,20 @@ static void verify_io_submit(unsigned int n)
>  	struct tcase *t = &tcases[n];
>  	int ret;

> +	memset(&ctx, 0, sizeof(ctx));
> +	TEST(io_setup(1, &ctx));
> +	if (TST_RET == -ENOSYS)
> +		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
> +	else if (TST_RET)
> +		tst_brk(TBROK | TRERRNO, "io_setup() failed");
> +
>  	ret = io_submit(*t->ctx, t->nr, t->iocbs);

> +	TEST(io_destroy(ctx));
> +	if (TST_RET) {
> +		tst_brk(TBROK | TRERRNO, "io_destroy() failed");
> +	}
> +
>  	if (ret == t->exp_errno) {
>  		tst_res(TPASS, "io_submit() with %s failed with %s",
>  			t->desc, errno_name(t->exp_errno));
> diff --git a/testcases/kernel/syscalls/io_submit/io_submit02.c b/testcases/kernel/syscalls/io_submit/io_submit02.c
> index acb42cb8f..ac32d254e 100644
> --- a/testcases/kernel/syscalls/io_submit/io_submit02.c
> +++ b/testcases/kernel/syscalls/io_submit/io_submit02.c
> @@ -54,7 +54,6 @@ static inline void io_prep_option(struct iocb *cb, int fd, void *buf,

>  static void setup(void)
>  {
> -	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
>  	fd = SAFE_OPEN(TEST_FILE, O_RDONLY | O_CREAT, MODE);
>  	io_prep_option(&iocb, fd, buf, 0, 0, IOCB_CMD_PREAD);
>  }
> @@ -64,18 +63,22 @@ static void cleanup(void)
>  	if (fd > 0)
>  		SAFE_CLOSE(fd);

> -	if (tst_syscall(__NR_io_destroy, ctx))
> -		tst_brk(TBROK | TERRNO, "io_destroy() failed");
>  }

>  static void run(unsigned int i)
>  {
> +	memset(tc[i].ctx, 0, sizeof(aio_context_t));
> +	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
> +
>  	TEST(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs));

>  	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);
> +
> +	if (tst_syscall(__NR_io_destroy, ctx))
> +		tst_brk(TBROK | TERRNO, "io_destroy() failed");
>  }

>  static struct tst_test test = {

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
  2022-04-05 14:07 ` Petr Vorel
@ 2022-04-08  3:58   ` Li Wang
  2022-04-08  7:57     ` Petr Vorel
  2022-04-08 16:36   ` Martin Doucha
  1 sibling, 1 reply; 7+ messages in thread
From: Li Wang @ 2022-04-08  3:58 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Viresh Kumar, Martin Doucha, LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1329 bytes --]

On Tue, Apr 5, 2022 at 10:08 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi all,
>
> > For io_submit01, add io_destroy before test return, or the test
> > would fail and report EAGAIN.
> > For io_submit02, move the io_destroy to the suitable location, or
> > the test would fail and report EAGAIN.
>
> $ ./io_submit01 -i150
> ...
> io_submit01.c:122: TPASS: io_submit() with NULL iocb pointers failed with
> EFAULT
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> expected SUCCESS(1)
>
> $ ./io_submit02 -i150
> ...
> io_submit02.c:76: TPASS: io_submit() returns 0 if nr is zero
> io_submit02.c:78: TFAIL: io_submit() returns -1, expected 1
>
> @Cyril, Li, Martin, Viresh: while this fix is valid using memset() (which
> is required)
> slows down testing a lot. Any idea whether this can be avoid to keep the
> speed?
>

It would not be a serious problem if only execute the test once,
I'm wondering if it really necessary to rerun many times(i.e. 150)?

BTW, the patch generally looks good to me.

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2084 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
  2022-04-08  3:58   ` Li Wang
@ 2022-04-08  7:57     ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2022-04-08  7:57 UTC (permalink / raw)
  To: Li Wang; +Cc: Viresh Kumar, Martin Doucha, LTP List

> On Tue, Apr 5, 2022 at 10:08 PM Petr Vorel <pvorel@suse.cz> wrote:

> > Hi all,

> > > For io_submit01, add io_destroy before test return, or the test
> > > would fail and report EAGAIN.
> > > For io_submit02, move the io_destroy to the suitable location, or
> > > the test would fail and report EAGAIN.

> > $ ./io_submit01 -i150
> > ...
> > io_submit01.c:122: TPASS: io_submit() with NULL iocb pointers failed with
> > EFAULT
> > io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> > expected EBADF(-9)
> > io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> > expected EBADF(-9)
> > io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> > expected EBADF(-9)
> > io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK),
> > expected SUCCESS(1)

> > $ ./io_submit02 -i150
> > ...
> > io_submit02.c:76: TPASS: io_submit() returns 0 if nr is zero
> > io_submit02.c:78: TFAIL: io_submit() returns -1, expected 1

> > @Cyril, Li, Martin, Viresh: while this fix is valid using memset() (which
> > is required)
> > slows down testing a lot. Any idea whether this can be avoid to keep the
> > speed?


> It would not be a serious problem if only execute the test once,
> I'm wondering if it really necessary to rerun many times(i.e. 150)?
Hi Li,

I guess for stressing particular subsystem can be useful to run some test many
times (but I don't personally do it).

Sure, we could limit test to run only few times (e.g. < 50).

> BTW, the patch generally looks good to me.
+1

Let's wait for other input.

Kind regards,
Petr

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
  2022-04-05 14:07 ` Petr Vorel
  2022-04-08  3:58   ` Li Wang
@ 2022-04-08 16:36   ` Martin Doucha
  1 sibling, 0 replies; 7+ messages in thread
From: Martin Doucha @ 2022-04-08 16:36 UTC (permalink / raw)
  To: Petr Vorel, Zhao Gongyi; +Cc: viresh.kumar, Martin Doucha, ltp

On 05. 04. 22 16:07, Petr Vorel wrote:
> Hi all,
> 
>> For io_submit01, add io_destroy before test return, or the test
>> would fail and report EAGAIN.
>> For io_submit02, move the io_destroy to the suitable location, or
>> the test would fail and report EAGAIN.
> 
> $ ./io_submit01 -i150
> ...
> io_submit01.c:122: TPASS: io_submit() with NULL iocb pointers failed with EFAULT
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected EBADF(-9)
> io_submit01.c:127: TFAIL: io_submit() returned -11(EAGAIN/EWOULDBLOCK), expected SUCCESS(1)
> 
> $ ./io_submit02 -i150
> ...
> io_submit02.c:76: TPASS: io_submit() returns 0 if nr is zero
> io_submit02.c:78: TFAIL: io_submit() returns -1, expected 1
> 
> @Cyril, Li, Martin, Viresh: while this fix is valid using memset() (which is required)
> slows down testing a lot. Any idea whether this can be avoid to keep the speed?

It's slow because the "fix" keeps destroying and recreating the IO
context. You don't need to do that, you just need to flush the finished
events from kernel buffer using io_getevents(), otherwise it'll get full
and io_submit() will start returning EAGAIN. I'll submit a patch on Monday.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
@ 2022-03-28 11:55 zhaogongyi via ltp
  0 siblings, 0 replies; 7+ messages in thread
From: zhaogongyi via ltp @ 2022-03-28 11:55 UTC (permalink / raw)
  To: ltp; +Cc: viresh.kumar

Hi, 

I am so sorry, the patch is submitted by mistake, please ignore it.

Best regards!

GONGYI

> 
> For io_submit01, add io_destroy before test return, or the test would fail
> and report EAGAIN.
> For io_submit02, move the io_destroy to the suitable location, or the test
> would fail and report EAGAIN.
> 
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
>  .../kernel/syscalls/io_submit/io_submit01.c    | 18 ++++++++++++------
>  .../kernel/syscalls/io_submit/io_submit02.c    |  9 ++++++---
>  2 files changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c
> b/testcases/kernel/syscalls/io_submit/io_submit01.c
> index 28d93d7f1..7931c583b 100644
> --- a/testcases/kernel/syscalls/io_submit/io_submit01.c
> +++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
> @@ -77,12 +77,6 @@ static struct tcase {
> 
>  static void setup(void)
>  {
> -	TEST(io_setup(1, &ctx));
> -	if (TST_RET == -ENOSYS)
> -		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by
> kernel");
> -	else if (TST_RET)
> -		tst_brk(TBROK | TRERRNO, "io_setup() failed");
> -
>  	io_prep_pread(&inv_fd_iocb, -1, buf, sizeof(buf), 0);
> 
>  	rdonly_fd = SAFE_OPEN("rdonly_file", O_RDONLY | O_CREAT, 0777);
> @@ -116,8 +110,20 @@ static void verify_io_submit(unsigned int n)
>  	struct tcase *t = &tcases[n];
>  	int ret;
> 
> +	memset(&ctx, 0, sizeof(ctx));
> +	TEST(io_setup(1, &ctx));
> +	if (TST_RET == -ENOSYS)
> +		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by
> kernel");
> +	else if (TST_RET)
> +		tst_brk(TBROK | TRERRNO, "io_setup() failed");
> +
>  	ret = io_submit(*t->ctx, t->nr, t->iocbs);
> 
> +	TEST(io_destroy(ctx));
> +	if (TST_RET) {
> +		tst_brk(TBROK | TRERRNO, "io_destroy() failed");
> +	}
> +
>  	if (ret == t->exp_errno) {
>  		tst_res(TPASS, "io_submit() with %s failed with %s",
>  			t->desc, errno_name(t->exp_errno));
> diff --git a/testcases/kernel/syscalls/io_submit/io_submit02.c
> b/testcases/kernel/syscalls/io_submit/io_submit02.c
> index acb42cb8f..ac32d254e 100644
> --- a/testcases/kernel/syscalls/io_submit/io_submit02.c
> +++ b/testcases/kernel/syscalls/io_submit/io_submit02.c
> @@ -54,7 +54,6 @@ static inline void io_prep_option(struct iocb *cb, int
> fd, void *buf,
> 
>  static void setup(void)
>  {
> -	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
>  	fd = SAFE_OPEN(TEST_FILE, O_RDONLY | O_CREAT, MODE);
>  	io_prep_option(&iocb, fd, buf, 0, 0, IOCB_CMD_PREAD);  } @@
> -64,18 +63,22 @@ static void cleanup(void)
>  	if (fd > 0)
>  		SAFE_CLOSE(fd);
> 
> -	if (tst_syscall(__NR_io_destroy, ctx))
> -		tst_brk(TBROK | TERRNO, "io_destroy() failed");
>  }
> 
>  static void run(unsigned int i)
>  {
> +	memset(tc[i].ctx, 0, sizeof(aio_context_t));
> +	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
> +
>  	TEST(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs));
> 
>  	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);
> +
> +	if (tst_syscall(__NR_io_destroy, ctx))
> +		tst_brk(TBROK | TERRNO, "io_destroy() failed");
>  }
> 
>  static struct tst_test test = {
> --
> 2.17.1


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i"
@ 2022-03-26 10:00 Zhao Gongyi via ltp
  0 siblings, 0 replies; 7+ messages in thread
From: Zhao Gongyi via ltp @ 2022-03-26 10:00 UTC (permalink / raw)
  To: ltp

For io_submit01, add io_destroy before test return, or the test
would fail and report EAGAIN.
For io_submit02, move the io_destroy to the suitable location, or
the test would fail and report EAGAIN.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 .../kernel/syscalls/io_submit/io_submit01.c    | 18 ++++++++++++------
 .../kernel/syscalls/io_submit/io_submit02.c    |  9 ++++++---
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/io_submit/io_submit01.c b/testcases/kernel/syscalls/io_submit/io_submit01.c
index 28d93d7f1..7931c583b 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit01.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit01.c
@@ -77,12 +77,6 @@ static struct tcase {

 static void setup(void)
 {
-	TEST(io_setup(1, &ctx));
-	if (TST_RET == -ENOSYS)
-		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
-	else if (TST_RET)
-		tst_brk(TBROK | TRERRNO, "io_setup() failed");
-
 	io_prep_pread(&inv_fd_iocb, -1, buf, sizeof(buf), 0);

 	rdonly_fd = SAFE_OPEN("rdonly_file", O_RDONLY | O_CREAT, 0777);
@@ -116,8 +110,20 @@ static void verify_io_submit(unsigned int n)
 	struct tcase *t = &tcases[n];
 	int ret;

+	memset(&ctx, 0, sizeof(ctx));
+	TEST(io_setup(1, &ctx));
+	if (TST_RET == -ENOSYS)
+		tst_brk(TCONF | TRERRNO, "io_setup(): AIO not supported by kernel");
+	else if (TST_RET)
+		tst_brk(TBROK | TRERRNO, "io_setup() failed");
+
 	ret = io_submit(*t->ctx, t->nr, t->iocbs);

+	TEST(io_destroy(ctx));
+	if (TST_RET) {
+		tst_brk(TBROK | TRERRNO, "io_destroy() failed");
+	}
+
 	if (ret == t->exp_errno) {
 		tst_res(TPASS, "io_submit() with %s failed with %s",
 			t->desc, errno_name(t->exp_errno));
diff --git a/testcases/kernel/syscalls/io_submit/io_submit02.c b/testcases/kernel/syscalls/io_submit/io_submit02.c
index acb42cb8f..ac32d254e 100644
--- a/testcases/kernel/syscalls/io_submit/io_submit02.c
+++ b/testcases/kernel/syscalls/io_submit/io_submit02.c
@@ -54,7 +54,6 @@ static inline void io_prep_option(struct iocb *cb, int fd, void *buf,

 static void setup(void)
 {
-	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
 	fd = SAFE_OPEN(TEST_FILE, O_RDONLY | O_CREAT, MODE);
 	io_prep_option(&iocb, fd, buf, 0, 0, IOCB_CMD_PREAD);
 }
@@ -64,18 +63,22 @@ static void cleanup(void)
 	if (fd > 0)
 		SAFE_CLOSE(fd);

-	if (tst_syscall(__NR_io_destroy, ctx))
-		tst_brk(TBROK | TERRNO, "io_destroy() failed");
 }

 static void run(unsigned int i)
 {
+	memset(tc[i].ctx, 0, sizeof(aio_context_t));
+	TST_EXP_PASS_SILENT(tst_syscall(__NR_io_setup, 1, &ctx));
+
 	TEST(tst_syscall(__NR_io_submit, *tc[i].ctx, tc[i].nr, tc[i].iocbs));

 	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);
+
+	if (tst_syscall(__NR_io_destroy, ctx))
+		tst_brk(TBROK | TERRNO, "io_destroy() failed");
 }

 static struct tst_test test = {
--
2.17.1


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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-08 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 11:49 [LTP] [PATCH] io_submit01/io_submit02: Bugfix for running with the option "-i" Zhao Gongyi via ltp
2022-04-05 14:07 ` Petr Vorel
2022-04-08  3:58   ` Li Wang
2022-04-08  7:57     ` Petr Vorel
2022-04-08 16:36   ` Martin Doucha
  -- strict thread matches above, loose matches on Subject: below --
2022-03-28 11:55 zhaogongyi via ltp
2022-03-26 10:00 Zhao Gongyi via ltp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.