ioctl01.c:Test also struct termios
PATCH 1/1 ioctl01.c:Test also struct termios
ATM we're testing just legacy struct termio in ioctl01.c, we also need test struct termios.
--- testcases/kernel/syscalls/ioctl/ioctl01.c | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +22 -6
@@ -28,26 +28,28 @@ static int fd, fd_file;static int bfd =-1 ;static struct termio termio; +static struct termios termios;static struct tcase {int *fd;int request;struct termio *s_tio; +struct termios *s_tios;int error; } tcases[] = {/* file descriptor is invalid */ - {&bfd,TCGETA , &termio,EBADF }, + {&bfd,TCGETA , &termio, &termios,EBADF },/* termio address is invalid */ - {&fd,TCGETA , (struct termio *)-1 ,EFAULT }, + {&fd,TCGETA , (struct termio *)-1 , (struct termios *)-1 ,EFAULT },/* command is invalid */ /* This errno value was changed from EINVAL to ENOTTY * by kernel commit 07d106d0 and bbb63c51 */ - {&fd,INVAL_IOCTL , &termio,ENOTTY }, + {&fd,INVAL_IOCTL , &termio, &termios,ENOTTY },/* file descriptor is for a regular file */ - {&fd_file,TCGETA , &termio,ENOTTY }, + {&fd_file,TCGETA , &termio, &termios,ENOTTY },/* termio is NULL */ - {&fd,TCGETA ,NULL ,EFAULT } + {&fd,TCGETA ,NULL ,NULL ,EFAULT } };static char *device;
@@ -64,7 +66,21 @@ static void verify_ioctl(unsigned int i)if (TST_ERR != tcases[i].error) {tst_res (TFAIL |TTERRNO ,"failed unexpectedly; expected %s" , -tst_strerrno (tcases[i].error)); +tst_strerrno (tcases[i].error)); +return ; + } + +TEST (ioctl (*(tcases[i].fd), tcases[i].request, tcases[i].s_tios)); + +if (TST_RET !=-1 ) { +tst_res (TFAIL ,"call succeeded unexpectedly" ); +return ; + } + +if (TST_ERR != tcases[i].error) { +tst_res (TFAIL |TTERRNO , +"failed unexpectedly; expected %s" , +tst_strerrno (tcases[i].error));return ; }
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 5 lines · Wei Gao via ltp
ATM we're testing just legacy struct termio in
ioctl01.c, we also need test struct termios.Signed-off-by Wei Gao <[email protected]>
Quoted 74 lines
--- testcases/kernel/syscalls/ioctl/ioctl01.c | 28 ++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-)testcases/kernel/syscalls/ioctl/ioctl01.c +22
-7@@ -28,26 +28,28 @@ static int fd, fd_file;static int bfd =-1 ;static struct termio termio; +static struct termios termios;static struct tcase {int *fd;int request;struct termio *s_tio; +struct termios *s_tios;int error; } tcases[] = {/* file descriptor is invalid */ - {&bfd,TCGETA , &termio,EBADF }, + {&bfd,TCGETA , &termio, &termios,EBADF },/* termio address is invalid */ - {&fd,TCGETA , (struct termio *)-1 ,EFAULT }, + {&fd,TCGETA , (struct termio *)-1 , (struct termios *)-1 ,EFAULT },/* command is invalid */ /* This errno value was changed from EINVAL to ENOTTY * by kernel commit 07d106d0 and bbb63c51 */ - {&fd,INVAL_IOCTL , &termio,ENOTTY }, + {&fd,INVAL_IOCTL , &termio, &termios,ENOTTY },/* file descriptor is for a regular file */ - {&fd_file,TCGETA , &termio,ENOTTY }, + {&fd_file,TCGETA , &termio, &termios,ENOTTY },/* termio is NULL */ - {&fd,TCGETA ,NULL ,EFAULT } + {&fd,TCGETA ,NULL ,NULL ,EFAULT } };static char *device;@@ -64,7 +66,21 @@ static void verify_ioctl(unsigned int i)if (TST_ERR != tcases[i].error) {tst_res (TFAIL |TTERRNO ,"failed unexpectedly; expected %s" , -tst_strerrno (tcases[i].error)); +tst_strerrno (tcases[i].error)); +return ; + } + +TEST (ioctl (*(tcases[i].fd), tcases[i].request, tcases[i].s_tios)); + +if (TST_RET !=-1 ) { +tst_res (TFAIL ,"call succeeded unexpectedly" ); +return ; + } + +if (TST_ERR != tcases[i].error) { +tst_res (TFAIL |TTERRNO , +"failed unexpectedly; expected %s" , +tst_strerrno (tcases[i].error));return ; } --2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 2 lines
ATM we're testing just legacy struct termio in
ioctl01.c, we also need test struct termios.
Good idea.
testcases/kernel/syscalls/ioctl/ioctl01.c static void verify_ioctl(unsigned int i) · line 71
Quoted 8 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +3
-1@@ -64,7 +66,21 @@ static void verify_ioctl(unsigned int i)if (TST_ERR != tcases[i].error) {tst_res (TFAIL |TTERRNO ,"failed unexpectedly; expected %s" , -tst_strerrno (tcases[i].error)); +tst_strerrno (tcases[i].error)); +return ; + }
Could you please replace TEST(ioctl(...) with TST_EXP_FAIL(ioctl(...))? That would save all error handling.
We try to use these helping macros in include/tst_test_macros.h. Although they would deserve some docs as macros are a bit harder to read.
testcases/kernel/syscalls/ioctl/ioctl01.c static void verify_ioctl(unsigned int i) · line 74
Quoted 3 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +3
-0+ +TEST (ioctl (*(tcases[i].fd), tcases[i].request, tcases[i].s_tios)); +
And obviously here should go TST_EXP_FAIL(ioctl(...)) as well.
Kind regards,
Petr
Quoted 11 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +9
-0+if (TST_RET !=-1 ) { +tst_res (TFAIL ,"call succeeded unexpectedly" ); +return ; + } + +if (TST_ERR != tcases[i].error) { +tst_res (TFAIL |TTERRNO , +"failed unexpectedly; expected %s" , +tst_strerrno (tcases[i].error));return ; }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 1 line
Hi Wei,
...
Quoted 11 lines
testcases/kernel/syscalls/ioctl/ioctl01.c static void verify_ioctl(unsigned int i) · line 71
Quoted 8 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +3
-1@@ -64,7 +66,21 @@ static void verify_ioctl(unsigned int i)if (TST_ERR != tcases[i].error) {tst_res (TFAIL |TTERRNO ,"failed unexpectedly; expected %s" , -tst_strerrno (tcases[i].error)); +tst_strerrno (tcases[i].error)); +return ; + }Could you please replace TEST(ioctl(...) with TST_EXP_FAIL(ioctl(...))? That would save all error handling.
Quoted 2 lines
We try to use these helping macros in
include/tst_test_macros.h. Although they would deserve some docs as macros are a bit harder to read.
I implemented this in 4c86809f77 ("ioctl01: cleanup"). Could you please rebase your commit and use TST_EXP_FAIL() in it?
Thank you!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 16 lines · Petr Vorel
Hi Wei,
Quoted 1 line
Hi Wei,
...
Quoted 10 lines
testcases/kernel/syscalls/ioctl/ioctl01.c static void verify_ioctl(unsigned int i) · line 71
Quoted 8 lines
testcases/kernel/syscalls/ioctl/ioctl01.c +3
-1@@ -64,7 +66,21 @@ static void verify_ioctl(unsigned int i)if (TST_ERR != tcases[i].error) {tst_res (TFAIL |TTERRNO ,"failed unexpectedly; expected %s" , -tst_strerrno (tcases[i].error)); +tst_strerrno (tcases[i].error)); +return ; + }Could you please replace TEST(ioctl(...) with TST_EXP_FAIL(ioctl(...))? That would save all error handling.
Quoted 5 lines
Quoted 2 lines
We try to use these helping macros in
include/tst_test_macros.h. Although they would deserve some docs as macros are a bit harder to read.I implemented this in
4c86809f77("ioctl01: cleanup"). Could you please rebase your commit and useTST_EXP_FAIL()in it?
Done, could you help check it, thanks!
Quoted 5 lines
Thank you!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 ioctl01.c:Test also struct termios
In reply to Wei Gao via ltpATM we're testing just legacy struct termio in ioctl01.c, we also need test struct termios.
--- testcases/kernel/syscalls/ioctl/ioctl01.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/ioctl/ioctl01.c +10 -5
@@ -32,26 +32,28 @@ static int fd, fd_file;static int bfd =-1 ;static struct termio termio; +static struct termios termios;static struct tcase {int *fd;int request;struct termio *s_tio; +struct termios *s_tios;int error; } tcases[] = {/* file descriptor is invalid */ - {&bfd,TCGETA , &termio,EBADF }, + {&bfd,TCGETA , &termio, &termios,EBADF },/* termio address is invalid */ - {&fd,TCGETA , (struct termio *)-1 ,EFAULT }, + {&fd,TCGETA , (struct termio *)-1 , (struct termios *)-1 ,EFAULT },/* command is invalid */ /* This errno value was changed from EINVAL to ENOTTY * by kernel commit 07d106d0 and bbb63c51 */ - {&fd,INVAL_IOCTL , &termio,ENOTTY }, + {&fd,INVAL_IOCTL , &termio, &termios,ENOTTY },/* file descriptor is for a regular file */ - {&fd_file,TCGETA , &termio,ENOTTY }, + {&fd_file,TCGETA , &termio, &termios,ENOTTY },/* termio is NULL */ - {&fd,TCGETA ,NULL ,EFAULT } + {&fd,TCGETA ,NULL ,NULL ,EFAULT } };static char *device;
@@ -60,6 +62,9 @@ static void verify_ioctl(unsigned int i) {TST_EXP_FAIL (ioctl (*(tcases[i].fd), tcases[i].request, tcases[i].s_tio), tcases[i].error); + +TST_EXP_FAIL (ioctl (*(tcases[i].fd), tcases[i].request, tcases[i].s_tios), + tcases[i].error); }static void setup (void )
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp