* [LTP] [PATCH v1] ioctl01.c:Test also struct termios
@ 2023-01-29 18:39 Wei Gao via ltp
2023-02-03 9:03 ` Li Wang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Wei Gao via ltp @ 2023-01-29 18:39 UTC (permalink / raw)
To: ltp
ATM we're testing just legacy struct termio in ioctl01.c,
we also need test struct termios.
Signed-off-by: Wei Gao <wegao@suse.com>
---
testcases/kernel/syscalls/ioctl/ioctl01.c | 28 ++++++++++++++++++-----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index 2989c0e9b..cc8d1d731 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1] ioctl01.c:Test also struct termios
2023-01-29 18:39 [LTP] [PATCH v1] ioctl01.c:Test also struct termios Wei Gao via ltp
@ 2023-02-03 9:03 ` Li Wang
2023-02-06 5:31 ` Petr Vorel
2023-02-07 7:16 ` [LTP] [PATCH v2] " Wei Gao via ltp
2 siblings, 0 replies; 6+ messages in thread
From: Li Wang @ 2023-02-03 9:03 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
On Mon, Jan 30, 2023 at 12:03 PM Wei Gao via ltp <ltp@lists.linux.it> wrote:
> ATM we're testing just legacy struct termio in ioctl01.c,
> we also need test struct termios.
>
> Signed-off-by: Wei Gao <wegao@suse.com>
>
Reviewed-by: Li Wang <liwang@redhat.com>
> ---
> testcases/kernel/syscalls/ioctl/ioctl01.c | 28 ++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c
> b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index 2989c0e9b..cc8d1d731 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -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
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1] ioctl01.c:Test also struct termios
2023-01-29 18:39 [LTP] [PATCH v1] ioctl01.c:Test also struct termios Wei Gao via ltp
2023-02-03 9:03 ` Li Wang
@ 2023-02-06 5:31 ` Petr Vorel
2023-02-06 6:12 ` Petr Vorel
2023-02-07 7:16 ` [LTP] [PATCH v2] " Wei Gao via ltp
2 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2023-02-06 5:31 UTC (permalink / raw)
To: Wei Gao; +Cc: ltp
Hi Wei,
> ATM we're testing just legacy struct termio in ioctl01.c,
> we also need test struct termios.
Good idea.
> @@ -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.
> +
> + 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
> + 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;
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1] ioctl01.c:Test also struct termios
2023-02-06 5:31 ` Petr Vorel
@ 2023-02-06 6:12 ` Petr Vorel
2023-02-07 7:17 ` Wei Gao via ltp
0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2023-02-06 6:12 UTC (permalink / raw)
To: Wei Gao, ltp
Hi Wei,
> Hi Wei,
...
> > @@ -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.
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2] ioctl01.c:Test also struct termios
2023-01-29 18:39 [LTP] [PATCH v1] ioctl01.c:Test also struct termios Wei Gao via ltp
2023-02-03 9:03 ` Li Wang
2023-02-06 5:31 ` Petr Vorel
@ 2023-02-07 7:16 ` Wei Gao via ltp
2 siblings, 0 replies; 6+ messages in thread
From: Wei Gao via ltp @ 2023-02-07 7:16 UTC (permalink / raw)
To: ltp
ATM we're testing just legacy struct termio in ioctl01.c,
we also need test struct termios.
Signed-off-by: Wei Gao <wegao@suse.com>
Reviewed-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/syscalls/ioctl/ioctl01.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index ccc48cdb2..1be38e79d 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -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)
--
2.35.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1] ioctl01.c:Test also struct termios
2023-02-06 6:12 ` Petr Vorel
@ 2023-02-07 7:17 ` Wei Gao via ltp
0 siblings, 0 replies; 6+ messages in thread
From: Wei Gao via ltp @ 2023-02-07 7:17 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Mon, Feb 06, 2023 at 07:12:11AM +0100, Petr Vorel wrote:
> Hi Wei,
>
> > Hi Wei,
>
> ...
> > > @@ -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.
>
> I implemented this in 4c86809f77 ("ioctl01: cleanup"). Could you please rebase
> your commit and use TST_EXP_FAIL() in it?
Done, could you help check it, thanks!
>
> Thank you!
>
> Kind regards,
> Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-07 7:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-29 18:39 [LTP] [PATCH v1] ioctl01.c:Test also struct termios Wei Gao via ltp
2023-02-03 9:03 ` Li Wang
2023-02-06 5:31 ` Petr Vorel
2023-02-06 6:12 ` Petr Vorel
2023-02-07 7:17 ` Wei Gao via ltp
2023-02-07 7:16 ` [LTP] [PATCH v2] " Wei Gao via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox