syscalls/aio: Add tests for libaio and docparse formatting
cover syscalls/aio: Add tests for libaio and docparse formatting
Xie Ziyao (7):
io_cancel02: Add io_cancel02 test for libaio
io_cancel01: Add .needs_kconfigs and more detailed description
io_destroy01: Add docparse formatting and more detailed description
io_getevents01: Add .needs_kconfigs and more detailed description
io_getevents02: Add io_getevents02 test for libaio
io_setup: Add docparse formatting and more detailed description
io_submit01: Add docparse formatting and more detailed description
runtest/syscalls | 2 + .../kernel/syscalls/io_cancel/.gitignore | 1 + .../kernel/syscalls/io_cancel/io_cancel01.c | 9 +++- .../kernel/syscalls/io_cancel/io_cancel02.c | 51 +++++++++++++++++++ .../kernel/syscalls/io_destroy/io_destroy01.c | 15 +++--- .../kernel/syscalls/io_getevents/.gitignore | 1 + .../syscalls/io_getevents/io_getevents01.c | 8 ++- .../syscalls/io_getevents/io_getevents02.c | 51 +++++++++++++++++++ .../kernel/syscalls/io_setup/io_setup01.c | 24 +++++---- .../kernel/syscalls/io_setup/io_setup02.c | 8 +-- .../kernel/syscalls/io_submit/io_submit01.c | 15 +++++- 11 files changed, 158 insertions(+), 27 deletions(-) create mode 100644 testcases/kernel/syscalls/io_cancel/io_cancel02.c create mode 100644 testcases/kernel/syscalls/io_getevents/io_getevents02.c
--
2.17.1
PATCH 1/7 io_cancel02: Add io_cancel02 test for libaio
Test io_cancel invoked via libaio with one of the data structures points to invalid data and expects it to return -EFAULT.
--- runtest/syscalls | 1 + .../kernel/syscalls/io_cancel/.gitignore | 1 + .../kernel/syscalls/io_cancel/io_cancel02.c | 51 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 testcases/kernel/syscalls/io_cancel/io_cancel02.c
runtest/syscalls +1 -0
@@ -606,6 +606,7 @@ ioprio_set02 ioprio_set02 ioprio_set03 ioprio_set03 io_cancel01 io_cancel01 +io_cancel02 io_cancel02 io_destroy01 io_destroy01 io_destroy02 io_destroy02 io_getevents01 io_getevents01
testcases/kernel/syscalls/io_cancel/.gitignore +1 -0
@@ -1 +1,2 @@ /io_cancel01 +/io_cancel02
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +51 -0
51 lines not on this page · raw message
--
2.17.1
PATCH 1/7 io_cancel02: Add io_cancel02 test for libaio
Hi!
Quoted 13 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +13
-0+#include "config.h" +#include "tst_test.h" + +#ifdef HAVE_LIBAIO +#define EXP_RET (-EFAULT) + +#include <libaio.h> + +static void run (void ) +{ +io_context_t ctx; + +memset (&ctx,0 ,sizeof (ctx));
testcases/kernel/syscalls/io_cancel/io_cancel02.c line 38
Quoted 10 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +10
-0+TEST (io_cancel (ctx,NULL ,NULL )); + +if (TST_RET ==0 ) +tst_res (TFAIL ,"call succeeded unexpectedly" ); +else if (TST_RET ==EXP_RET ) +tst_res (TPASS ,"io_cancel(ctx, NULL, NULL) returns %ld : %s" , +TST_RET ,strerror (-TST_RET )); +else +tst_res (TFAIL ,"io_cancel(ctx, NULL, NULL) returns %ld : %s, expected %d : %s" , +TST_RET ,strerror (-TST_RET ),EXP_RET ,strerror (-EXP_RET ));
Please use TST_EXP_FAIL() instead.
Quoted 19 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +13
-1+} + +static struct tst_test test = { + .needs_kconfigs = (const char *[]) { +"CONFIG_AIO=y" , +NULL + }, + .test_all = run, +}; + +#else +TST_TEST_TCONF ("test requires libaio and it's development packages" ); +#endif --2.17.1
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/7 io_cancel02: Add io_cancel02 test for libaio
Hi!
Quoted 9 lines
Quoted 9 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +9
-0+#include "config.h" +#include "tst_test.h" + +#ifdef HAVE_LIBAIO +#define EXP_RET (-EFAULT) + +#include <libaio.h> + +static void run (void )
Quoted 8 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c line 32
Quoted 8 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +8
-0+{ +io_context_t ctx; + +memset (&ctx,0 ,sizeof (ctx)); +TEST (io_cancel (ctx,NULL ,NULL )); + +if (TST_RET ==0 ) +tst_res (TFAIL ,"call succeeded unexpectedly" );
It's usually easier to read to use return instead of else if branches:
if (TST_RET == 0) {
tst_res(TFAIL, "io_cancel() succeeded unexpectedly");
return;
}Also you should never use strerror() in tests, we do have tst_strerrno() for that purpose, also if you have checked that TST_RET == EFAULT there is no point in converting the value into a string and you can do:
if (TST_RET == -EFAULT) {
tst_res(TPASS, "io_cancel() failed with EFAULT");
return;
}Followed by:
tst_res(TFAIL, "io_cancel() failed unexpectedly %s (%d) expected EFAULT", tst_strerrno(-TST_RET), -TST_RET);
Quoted 8 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c line 38
Quoted 6 lines
testcases/kernel/syscalls/io_cancel/io_cancel02.c new file +6
-0+else if (TST_RET ==EXP_RET ) +tst_res (TPASS ,"io_cancel(ctx, NULL, NULL) returns %ld : %s" , +TST_RET ,strerror (-TST_RET )); +else +tst_res (TFAIL ,"io_cancel(ctx, NULL, NULL) returns %ld : %s, expected %d : %s" , +TST_RET ,strerror (-TST_RET ),EXP_RET ,strerror (-EXP_RET ));Please use
TST_EXP_FAIL()instead.
Looking again, these calls do return -error on failure, we can't use TST_EXP_FAIL() here.
But even then there are a couple of problems to fix (commented above).
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/7 io_cancel01: Add .needs_kconfigs and more detailed description
In reply to Xie ZiyaoAdd .needs_kconfigs and more detailed description to distinguish it from io_cancel02.
--- testcases/kernel/syscalls/io_cancel/io_cancel01.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/io_cancel/io_cancel01.c +7 -2
@@ -8,8 +8,8 @@/*\ * [Description] * -* Calls io_cancel() with one of the data structures points to invalid data and -* expects it to return EFAULT. +* Test io_cancel invoked via syscall(2) with one of the data structures +* points to invalid data and expects it to return EFAULT. */ #include <linux/aio_abi.h>
@@ -21,10 +21,15 @@static void run (void ) {aio_context_t ctx; +memset (&ctx,0 ,sizeof (ctx));TST_EXP_FAIL (tst_syscall (__NR_io_cancel, ctx,NULL ,NULL ),EFAULT ); }static struct tst_test test = { + .needs_kconfigs = (const char *[]) { +"CONFIG_AIO=y" , +NULL + }, .test_all = run, };
--
2.17.1
PATCH 2/7 io_cancel01: Add .needs_kconfigs and more detailed description
Hi!
I've adjusted the documentation comment a bit and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 3/7 io_destroy01: Add docparse formatting and more detailed description
In reply to Xie ZiyaoAdd docparse formatting and more detailed description to distinguish it from io_destroy02.
--- .../kernel/syscalls/io_destroy/io_destroy01.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/io_destroy/io_destroy01.c +8 -7
@@ -1,15 +1,16 @@// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) Crackerjack Project., 2007 -* Copyright (c) 2011 Cyril Hrubis <[email protected]> -* Copyright (c) 2017 Xiao Yang <[email protected]> +* 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]> */ -/* Porting from Crackerjack to LTP is done -* by Masatake YAMATO <[email protected]> +/*\ +* [Description] * -* Description: -* io_destroy(2) fails and returns -EINVAL if ctx is invalid. +* Test io_destroy invoked via libaio with invalid ctx and expects it to +* return -EINVAL. */ #include <errno.h>
--
2.17.1
PATCH 3/7 io_destroy01: Add docparse formatting and more detailed description
Hi!
Applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 4/7 io_getevents01: Add .needs_kconfigs and more detailed description
In reply to Xie ZiyaoAdd .needs_kconfigs and more detailed description to distinguish it from io_getevents02.
--- testcases/kernel/syscalls/io_getevents/io_getevents01.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/io_getevents/io_getevents01.c +7 -1
@@ -8,7 +8,8 @@/*\ * [Description] * -* Calls io_getevents() when ctx is invalid and expects it to return EINVAL. +* Test io_getevents invoked via syscall(2) with invalid ctx and expects it to +* return EINVAL. */ #include <linux/aio_abi.h>
@@ -20,10 +21,15 @@static void run (void ) {aio_context_t ctx; +memset (&ctx,0 ,sizeof (ctx));TST_EXP_FAIL (tst_syscall (__NR_io_getevents, ctx,0 ,0 ,NULL ,NULL ),EINVAL ); }static struct tst_test test = { + .needs_kconfigs = (const char *[]) { +"CONFIG_AIO=y" , +NULL + }, .test_all = run, };
--
2.17.1
PATCH 4/7 io_getevents01: Add .needs_kconfigs and more detailed description
Hi!
Applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 5/7 io_getevents02: Add io_getevents02 test for libaio
In reply to Xie ZiyaoTest io_getevents invoked via libaio with invalid ctx and expects it to return -EINVAL.
--- runtest/syscalls | 1 + .../kernel/syscalls/io_getevents/.gitignore | 1 + .../syscalls/io_getevents/io_getevents02.c | 51 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 testcases/kernel/syscalls/io_getevents/io_getevents02.c
runtest/syscalls +1 -0
@@ -610,6 +610,7 @@ io_cancel02 io_cancel02 io_destroy01 io_destroy01 io_destroy02 io_destroy02 io_getevents01 io_getevents01 +io_getevents02 io_getevents02 io_pgetevents01 io_pgetevents01 io_pgetevents02 io_pgetevents02
testcases/kernel/syscalls/io_getevents/.gitignore +1 -0
@@ -1 +1,2 @@ /io_getevents01 +/io_getevents02
testcases/kernel/syscalls/io_getevents/io_getevents02.c new file +51 -0
51 lines not on this page · raw message
--
2.17.1
PATCH 5/7 io_getevents02: Add io_getevents02 test for libaio
Hi!
The comments for io_cancel02 apply here as well.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 5/7 io_getevents02: Add io_getevents02 test for libaio
Hi, Cyril,
Quoted 3 lines
Hi!
The comments forio_cancel02apply here as well.
Both have been modified in the v2 patchset. Thx.
Kind Regards,
Ziyao
PATCH 6/7 io_setup: Add docparse formatting and more detailed description
In reply to Xie ZiyaoAdd docparse formatting and more detailed description to distinguish io_setup01 from io_setup02.
--- .../kernel/syscalls/io_setup/io_setup01.c | 24 ++++++++++--------- .../kernel/syscalls/io_setup/io_setup02.c | 8 +++---- 2 files changed, 17 insertions(+), 15 deletions(-)
testcases/kernel/syscalls/io_setup/io_setup01.c +13 -11
@@ -1,19 +1,21 @@// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) Crackerjack Project., 2007 -* Copyright (c) 2011 Cyril Hrubis <[email protected]> -* Copyright (c) 2017 Xiao Yang <[email protected]> +* 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]> */ -/* Porting from Crackerjack to LTP is done -* by Masatake YAMATO <[email protected]> +/*\ +* [Description] * -* Description: -* 1) io_setup(2) succeeds if both nr_events and ctxp are valid. -* 2) io_setup(2) fails and returns -EINVAL if ctxp is not initialized to 0. -* 3) io_setup(2) fails and returns -EINVAL if nr_events is invalid. -* 4) io_setup(2) fails and returns -EFAULT if ctxp is NULL. -* 5) io_setup(2) fails and returns -EAGAIN if nr_events exceeds the limit +* Test io_setup invoked via libaio: +* +* 1. io_setup succeeds if both nr_events and ctxp are valid. +* 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 invalid. +* 4. io_setup fails and returns -EFAULT if ctxp is NULL. +* 5. io_setup fails and returns -EAGAIN if nr_events exceeds the limit * of available events. */
testcases/kernel/syscalls/io_setup/io_setup02.c +4 -4
@@ -12,10 +12,10 @@* * Test 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 +* 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 * of available events. * 5. io_setup succeeds if both nr_events and ctxp are valid. */
--
2.17.1
PATCH 6/7 io_setup: Add docparse formatting and more detailed description
Hi!
Quoted 6 lines
+ * 1.
io_setupsucceeds if bothnr_eventsand ctxp are valid.
+ * 2.io_setupfails and returns-EINVALif ctxp is not initialized to 0.
+ * 3.io_setupfails and returns-EINVALifnr_eventsis invalid.
+ * 4.io_setupfails and returns-EFAULTif ctxp is NULL.
+ * 5.io_setupfails and returns-EAGAINifnr_eventsexceeds the limit
* of available events.
I've changed the numbered list to a asciidoc list (items start with -) so that it renders nicely and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 7/7 io_submit01: Add docparse formatting and more detailed description
In reply to Xie ZiyaoAdd docparse formatting and more detailed description to distinguish it from io_submit{02, 03}.
--- testcases/kernel/syscalls/io_submit/io_submit01.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/io_submit/io_submit01.c +13 -2
@@ -1,11 +1,22 @@// 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-2017 Cyril Hrubis <[email protected]> */ -/* Porting from Crackerjack to LTP is done -by Masatake YAMATO <[email protected]> */ +/*\ +* [Description] +* +* Test io_submit invoked via libaio: +* +* 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. +* 5. io_submit() succeeds and returns the number of iocbs submitted. +* 6. io_submit() succeeds and returns 0 if nr is zero. +*/ #include <errno.h> #include <string.h>
--
2.17.1
PATCH 7/7 io_submit01: Add docparse formatting and more detailed description
Hi!
Quoted 6 lines
+ * 1.
io_submitfails and returns-EINVALif ctx is invalid.
+ * 2.io_submitfails and returns-EINVALif nr is invalid.
+ * 3.io_submitfails and returns-EFAULTif iocbpp pointer is invalid.
+ * 4.io_submitfails and returns-EBADFif fd is invalid.
+ * 5.io_submit()succeeds and returns the number of iocbs submitted.
+ * 6.io_submit()succeeds and returns 0 if nr is zero.
Did the same change here and pushed as well, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]