public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] ioctl02.c: check for struct termio
@ 2020-01-28 21:27 Petr Vorel
  2020-01-28 21:39 ` Petr Vorel
  2020-01-29 10:06 ` Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2020-01-28 21:27 UTC (permalink / raw)
  To: ltp

Test is meant to use legacy struct termio, so we need to check for it.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Tested: https://travis-ci.org/pevik/ltp/builds/643099597

NOTE: also rewriting other tests to new API which will use LTP_CHECK_TERMIO
(ioctl02.c and ptem01.c).

Kind regards,
Petr

 configure.ac                              |  1 +
 m4/ltp-termio.m4                          |  6 ++++++
 testcases/kernel/syscalls/ioctl/ioctl01.c | 20 ++++++++++++--------
 3 files changed, 19 insertions(+), 8 deletions(-)
 create mode 100644 m4/ltp-termio.m4

diff --git a/configure.ac b/configure.ac
index c7cdff1c4..b860bdacc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -257,6 +257,7 @@ LTP_CHECK_SYSCALL_QUOTACTL
 LTP_CHECK_SYSCALL_SIGNALFD
 LTP_CHECK_SYSCALL_UTIMENSAT
 LTP_CHECK_TASKSTATS
+LTP_CHECK_TERMIO
 LTP_CHECK_TIMERFD
 test "x$with_tirpc" = xyes && LTP_CHECK_TIRPC
 LTP_CHECK_TPACKET_V3
diff --git a/m4/ltp-termio.m4 b/m4/ltp-termio.m4
new file mode 100644
index 000000000..e745df1d9
--- /dev/null
+++ b/m4/ltp-termio.m4
@@ -0,0 +1,6 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2020 Petr Vorel <petr.vorel@gmail.com>
+
+AC_DEFUN([LTP_CHECK_TERMIO],[
+AC_CHECK_TYPES([struct termio],,,[#include <sys/ioctl.h>])
+])
diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index 7fb8d417e..88c0b9ffb 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -1,11 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) International Business Machines  Corp., 2001
- *  07/2001 Ported by Wayne Boyer
- *  04/2002 Fixes by wjhuie
- */
-/*
- * DESCRIPTION
+ * Copyright (c) International Business Machines Corp., 2001
+ * Copyright (c) 2020 Petr Vorel <petr.vorel@gmail.com>
+ * 07/2001 Ported by Wayne Boyer
+ * 04/2002 Fixes by wjhuie
+ *
  *	Testcase to check the errnos set by the ioctl(2) system call.
  *
  * ALGORITHM
@@ -14,13 +13,13 @@
  *	3. EINVAL: Pass invalid cmd in ioctl(fd, cmd, arg)
  *	4. ENOTTY: Pass an non-streams fd in ioctl(fd, cmd, arg)
  *	5. EFAULT: Pass a NULL address for termio
- *
  */
 
+#include "config.h"
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
-#include <termio.h>
+#include <sys/ioctl.h>
 #include <termios.h>
 #include "tst_test.h"
 
@@ -29,6 +28,7 @@
 static int fd, fd_file;
 static int bfd = -1;
 
+#ifdef HAVE_STRUCT_TERMIO
 static struct termio termio;
 
 static struct tcase {
@@ -113,3 +113,7 @@ static struct tst_test test = {
 		{}
 	}
 };
+
+#else
+	TST_TEST_TCONF("libc doesn't provide legacy struct termio");
+#endif /* HAVE_STRUCT_TERMIO */
-- 
2.24.1


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

* [LTP] [PATCH 1/1] ioctl02.c: check for struct termio
  2020-01-28 21:27 [LTP] [PATCH 1/1] ioctl02.c: check for struct termio Petr Vorel
@ 2020-01-28 21:39 ` Petr Vorel
  2020-01-29 10:01   ` Cyril Hrubis
  2020-01-29 10:06 ` Cyril Hrubis
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2020-01-28 21:39 UTC (permalink / raw)
  To: ltp

Hi,

> Test is meant to use legacy struct termio, so we need to check for it.
Hm, am I wrong, and we should rewrite ioctl01.c and ioctl02.c to use struct
termios? Or do we want to test with both new struct termios and legacy termio?

Kind regards,
Petr

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

* [LTP] [PATCH 1/1] ioctl02.c: check for struct termio
  2020-01-28 21:39 ` Petr Vorel
@ 2020-01-29 10:01   ` Cyril Hrubis
  2020-01-29 10:27     ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2020-01-29 10:01 UTC (permalink / raw)
  To: ltp

Hi!
> Hm, am I wrong, and we should rewrite ioctl01.c and ioctl02.c to use struct
> termios? Or do we want to test with both new struct termios and legacy termio?

Just have a look at 'man ioctl_list' there are two sets of ioctls one
for termio and one for termios and as usuall we should ideally test both.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 1/1] ioctl02.c: check for struct termio
  2020-01-28 21:27 [LTP] [PATCH 1/1] ioctl02.c: check for struct termio Petr Vorel
  2020-01-28 21:39 ` Petr Vorel
@ 2020-01-29 10:06 ` Cyril Hrubis
  1 sibling, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2020-01-29 10:06 UTC (permalink / raw)
  To: ltp

Hi!
>  configure.ac                              |  1 +
>  m4/ltp-termio.m4                          |  6 ++++++
>  testcases/kernel/syscalls/ioctl/ioctl01.c | 20 ++++++++++++--------
>  3 files changed, 19 insertions(+), 8 deletions(-)
>  create mode 100644 m4/ltp-termio.m4
> 
> diff --git a/configure.ac b/configure.ac
> index c7cdff1c4..b860bdacc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -257,6 +257,7 @@ LTP_CHECK_SYSCALL_QUOTACTL
>  LTP_CHECK_SYSCALL_SIGNALFD
>  LTP_CHECK_SYSCALL_UTIMENSAT
>  LTP_CHECK_TASKSTATS
> +LTP_CHECK_TERMIO
>  LTP_CHECK_TIMERFD
>  test "x$with_tirpc" = xyes && LTP_CHECK_TIRPC
>  LTP_CHECK_TPACKET_V3
> diff --git a/m4/ltp-termio.m4 b/m4/ltp-termio.m4
> new file mode 100644
> index 000000000..e745df1d9
> --- /dev/null
> +++ b/m4/ltp-termio.m4
> @@ -0,0 +1,6 @@
> +dnl SPDX-License-Identifier: GPL-2.0-or-later
> +dnl Copyright (c) 2020 Petr Vorel <petr.vorel@gmail.com>
> +
> +AC_DEFUN([LTP_CHECK_TERMIO],[
> +AC_CHECK_TYPES([struct termio],,,[#include <sys/ioctl.h>])
> +])

What about we add a fallback defition of the structure into
lapi/termio.h instead of disabling the test?

That way we would be able to test the kernel even if the userspace
headers were missing...

#include "config.h"

#ifndef HAVE_STRUCT_TERMIO
struct termio {
...
}
#ifdef

Should be enough to be able to compile that test, right?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH 1/1] ioctl02.c: check for struct termio
  2020-01-29 10:01   ` Cyril Hrubis
@ 2020-01-29 10:27     ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2020-01-29 10:27 UTC (permalink / raw)
  To: ltp

Hi,

> > Hm, am I wrong, and we should rewrite ioctl01.c and ioctl02.c to use struct
> > termios? Or do we want to test with both new struct termios and legacy termio?

> Just have a look at 'man ioctl_list' there are two sets of ioctls one
> for termio and one for termios and as usuall we should ideally test both.
Thanks for info. I had a look at man ioctl_tty, just wasn't sure whether it's
worth to test the legacy one.

Added as easyhack issue (I'll wait a bit before implementing it)
https://github.com/linux-test-project/ltp/issues/637

Kind regards,
Petr

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

end of thread, other threads:[~2020-01-29 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-28 21:27 [LTP] [PATCH 1/1] ioctl02.c: check for struct termio Petr Vorel
2020-01-28 21:39 ` Petr Vorel
2020-01-29 10:01   ` Cyril Hrubis
2020-01-29 10:27     ` Petr Vorel
2020-01-29 10:06 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox