syscalls/aio: Add testcases for native AIO
v2 cover syscalls/aio: Add testcases for native AIO
1. Split io_submit02 into two, one for negative and one for positive cases.
2. Add .needs_kconfig in this test.
3. Print values not variable names in TST_EXP_PASS/FAIL().
Xie Ziyao (4):
syscalls/io_destroy: Add io_destroy02 test for native AIO syscalls/io_setup: Add io_setup02 test for native AIO syscalls/io_submit: Add io_submit02 test for native AIO syscalls/io_submit: Add io_submit03 test for native AIO
runtest/syscalls | 4 + .../kernel/syscalls/io_destroy/.gitignore | 1 + .../kernel/syscalls/io_destroy/io_destroy02.c | 38 ++++++ testcases/kernel/syscalls/io_setup/.gitignore | 1 + .../kernel/syscalls/io_setup/io_setup02.c | 64 ++++++++++ .../kernel/syscalls/io_submit/.gitignore | 2 + .../kernel/syscalls/io_submit/io_submit02.c | 89 +++++++++++++ .../kernel/syscalls/io_submit/io_submit03.c | 118 ++++++++++++++++++ 8 files changed, 317 insertions(+) create mode 100644 testcases/kernel/syscalls/io_destroy/io_destroy02.c create mode 100644 testcases/kernel/syscalls/io_setup/io_setup02.c create mode 100644 testcases/kernel/syscalls/io_submit/io_submit02.c create mode 100644 testcases/kernel/syscalls/io_submit/io_submit03.c
--
2.17.1
PATCH v2 1/4 syscalls/io_destroy: Add io_destroy02 test for native AIO
Test io_destroy invoked via syscall(2) with an invalid ctx and expects it to return EINVAL.
---v1->v2:
1. Add .needs_kconfig in this test.
2. Print values not variable names in TST_EXP_PASS().
runtest/syscalls | 1 + .../kernel/syscalls/io_destroy/.gitignore | 1 + .../kernel/syscalls/io_destroy/io_destroy02.c | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 testcases/kernel/syscalls/io_destroy/io_destroy02.c
runtest/syscalls +1 -0
@@ -607,6 +607,7 @@ ioprio_set03 ioprio_set03 io_cancel01 io_cancel01 io_destroy01 io_destroy01 +io_destroy02 io_destroy02 io_getevents01 io_getevents01 io_pgetevents01 io_pgetevents01
testcases/kernel/syscalls/io_destroy/.gitignore +1 -0
@@ -1 +1,2 @@ /io_destroy01 +/io_destroy02
testcases/kernel/syscalls/io_destroy/io_destroy02.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) Crackerjack Project., 2007 +* Ported from Crackerjack to LTP by Masatake YAMATO <[email protected]> +* Copyright (c) 2011 Cyril Hrubis <[email protected]> +* Copyright (c) 2017 Xiao Yang <[email protected]> +* Copyright (c) 2021 Xie Ziyao <[email protected]> +*/ + +/*\ +* [Description] +* +* Test io_destroy invoked via syscall(2) with an invalid ctx and expects +* it to return EINVAL. +*/ + +#include <linux/aio_abi.h> + +#include "config.h" +#include "tst_test.h" +#include "lapi/syscalls.h" + +static void run (void ) +{ +aio_context_t ctx; + +memset (&ctx,0xff ,sizeof (ctx)); +TST_EXP_FAIL (tst_syscall (__NR_io_destroy, ctx),EINVAL , +"io_destroy() with an invalid ctx" ); +} + +static struct tst_test test = { + .needs_kconfigs = (const char *[]) { +"CONFIG_AIO=y" , +NULL + }, + .test_all = run, +};
--
2.17.1
PATCH v2 2/4 syscalls/io_setup: Add io_setup02 test for native AIO
In reply to Xie ZiyaoTest io_setup invoked via syscall(2):
1. io_setup fails and returns -EFAULT if ctxp is NULL.
2. io_setup fails and returns -EINVAL if ctxp is not initialized to 0.
3. io_setup fails and returns -EINVAL if nr_events is -1.
4. io_setup fails and returns -EAGAIN if nr_events exceeds the limit.
5. io_setup succeeds if both nr_events and ctxp are valid.
---v1->v2:
1. Add .needs_kconfig in this test.
2. Print values not variable names in TST_EXP_PASS().
3. Use TST_EXP_PASS_SILENT() instead of TST_EXP_PASS() in cleanup.
runtest/syscalls | 1 + testcases/kernel/syscalls/io_setup/.gitignore | 1 + .../kernel/syscalls/io_setup/io_setup02.c | 64 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 testcases/kernel/syscalls/io_setup/io_setup02.c
runtest/syscalls +1 -0
@@ -614,6 +614,7 @@ io_pgetevents01 io_pgetevents01 io_pgetevents02 io_pgetevents02 io_setup01 io_setup01 +io_setup02 io_setup02 io_submit01 io_submit01 keyctl01 keyctl01
testcases/kernel/syscalls/io_setup/.gitignore +1 -0
@@ -1 +1,2 @@ /io_setup01 +/io_setup02
testcases/kernel/syscalls/io_setup/io_setup02.c new file +64 -0
64 lines not on this page · raw message
--
2.17.1
PATCH v2 3/4 syscalls/io_submit: Add io_submit02 test for native AIO
In reply to Xie ZiyaoTest io_submit invoked via syscall(2):
1. io_submit() returns the number of iocbs submitted.
2. io_submit() returns 0 if nr is zero.
---v1->v2:
1. Split io_submit02 into two, one for negative and one for positive cases.
2. Print values not variable names in TST_EXP_PASS().
3. Add .needs_kconfig in this test.
runtest/syscalls | 1 + .../kernel/syscalls/io_submit/.gitignore | 1 + .../kernel/syscalls/io_submit/io_submit02.c | 89 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 testcases/kernel/syscalls/io_submit/io_submit02.c
runtest/syscalls +1 -0
@@ -616,6 +616,7 @@ io_pgetevents02 io_pgetevents02 io_setup01 io_setup01 io_setup02 io_setup02 io_submit01 io_submit01 +io_submit02 io_submit02 keyctl01 keyctl01 keyctl02 keyctl02
testcases/kernel/syscalls/io_submit/.gitignore +1 -0
@@ -1 +1,2 @@ /io_submit01 +/io_submit02
testcases/kernel/syscalls/io_submit/io_submit02.c new file +89 -0
89 lines not on this page · raw message
--
2.17.1
PATCH v2 4/4 syscalls/io_submit: Add io_submit03 test for native AIO
In reply to Xie ZiyaoTest io_submit invoked via syscall(2):
1. io_submit fails and returns EINVAL if ctx is invalid.
2. io_submit fails and returns EINVAL if nr is invalid.
3. io_submit fails and returns EFAULT if iocbpp pointer is invalid.
4. io_submit fails and returns EBADF if fd is invalid.
---v1->v2:
1. Split io_submit02 into two, one for negative and one for positive cases.
2. Print values not variable names in TST_EXP_PASS().
3. Add .needs_kconfig in this test.
runtest/syscalls | 1 +
.../kernel/syscalls/io_submit/.gitignore | 1 + .../kernel/syscalls/io_submit/io_submit03.c | 118 ++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 testcases/kernel/syscalls/io_submit/io_submit03.c
runtest/syscalls +1 -0
@@ -617,6 +617,7 @@ io_setup01 io_setup01 io_setup02 io_setup02 io_submit01 io_submit01 io_submit02 io_submit02 +io_submit03 io_submit03 keyctl01 keyctl01 keyctl02 keyctl02
testcases/kernel/syscalls/io_submit/.gitignore +1 -0
@@ -1,2 +1,3 @@ /io_submit01 /io_submit02 +/io_submit03
testcases/kernel/syscalls/io_submit/io_submit03.c new file +118 -0
118 lines not on this page · raw message
--
2.17.1
PATCH v2 4/4 syscalls/io_submit: Add io_submit03 test for native AIO
Hi!
testcases/kernel/syscalls/io_submit/io_submit03.c line 99
Quoted 7 lines
testcases/kernel/syscalls/io_submit/io_submit03.c new file +7
-0+static void cleanup (void ) +{ +if (rdonly_fd >0 ) +SAFE_CLOSE (rdonly_fd); +if (wronly_fd >0 ) +SAFE_CLOSE (wronly_fd); +TST_EXP_PASS_SILENT (tst_syscall (__NR_io_destroy, ctx));
I've replaced these PASS_SILENT() with plain old tst_brk(TBROK ...) in the last two tests and pushed, thanks.
The TST_EXP_* macros are intended for the actual test and not for setup/cleanup where the test is supposed to report TBROK if something goes wrong.
Signature · 2 lines
Cyril Hrubis [email protected]