ioctl, pty Add: fallback definition of struct termio
PATCH v2 1/1 ioctl, pty Add: fallback definition of struct termio
into ioctl0{1,2}.c, ptem01.c, pty01.c.
replace <termio.h> with <termios.h> and <sys/ioctl.h>
MUSL is not including <sys/ttydefaults.h> in <sys/ioctl.h>, thus loaded in lapi/ioctl.h.
This fixes musl build, thus update travis.
---v1->v2:
* add a fallback defition of the structure into lapi/termio.h instead of disabling the test
(suggested by Cyril, I've just added it into lapi/ioctl.h instead of creating lapi/termio.h, as the struct is loadable via <sys/ioctl.h>)
* fix more tests: ioctl02.c ptem01.c, pty01.c
* add <sys/ttydefaults.h> fix for MUSL
* update Travis
CI: https://travis-ci.org/pevik/ltp/builds/643367472
Kind regards,
Petr
configure.ac | 1 + include/lapi/ioctl.h | 25 +++++++++++++++++++++++ m4/ltp-termio.m4 | 6 ++++++ testcases/kernel/pty/ptem01.c | 6 +++--- testcases/kernel/pty/pty01.c | 4 ++-- testcases/kernel/syscalls/ioctl/ioctl01.c | 15 +++++++------- testcases/kernel/syscalls/ioctl/ioctl02.c | 7 +++---- travis/alpine.sh | 4 ---- 8 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 m4/ltp-termio.m4
configure.ac +1 -0
@@ -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
include/lapi/ioctl.h +25 -0
@@ -1,15 +1,40 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2020 Cyril Hrubis <[email protected]> +* Copyright (c) 2020 Petr Vorel <[email protected]> */ #ifndef IOCTL_H__ #define IOCTL_H__ +#include "config.h" #include <sys/ioctl.h> +/* musl not including it in <sys/ioctl.h> */ +#include <sys/ttydefaults.h> +#ifndef TIOCVHANGUP # define TIOCVHANGUP 0x5437#endif +#ifndef HAVE_STRUCT_TERMIO +# ifndef NCC +# ifdef __powerpc__ +# define NCC 10 +# else +# define NCC 8 +# endif +# endif /* NCC */ + +struct termio + { +unsigned short int c_iflag;/* input mode flags */ +unsigned short int c_oflag;/* output mode flags */ +unsigned short int c_cflag;/* control mode flags */ +unsigned short int c_lflag;/* local mode flags */ +unsigned char c_line;/* line discipline */ +unsigned char c_cc[NCC ];/* control characters */ +}; +#endif /* HAVE_STRUCT_TERMIO */ +#endif /* IOCTL_H__ */
m4/ltp-termio.m4 new file +6 -0
@@ -0,0 +1,6 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2020 Petr Vorel <[email protected]> + +AC_DEFUN([LTP_CHECK_TERMIO],[ +AC_CHECK_TYPES([struct termio],,,[#include <sys/ioctl.h>]) +])
testcases/kernel/pty/ptem01.c +3 -3
@@ -1,6 +1,6 @@/* -* * Copyright (c) International Business Machines Corp., 2002 +* Copyright (c) 2020 Petr Vorel <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -25,15 +25,15 @@#include <stdio.h> #include <stdlib.h> #include <stdio.h> -#include <termio.h> +#include <termios.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/poll.h> #include <sys/types.h> -/** LTP Port **/ #include "test.h" #include "safe_macros.h" +#include "lapi/ioctl.h" char *TCID ="ptem01" ;/* Test program identifier. */ int TST_TOTAL =6 ;/* Total number of test cases. */
testcases/kernel/pty/pty01.c +2 -2
@@ -29,12 +29,12 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <termio.h> +#include <termios.h> #include <unistd.h> -/** LTP Port **/ #include "test.h" #include "safe_macros.h" +#include "lapi/ioctl.h" char *TCID ="pty01" ;/* Test program identifier. */ int TST_TOTAL =5 ;/* Total number of test cases. */
testcases/kernel/syscalls/ioctl/ioctl01.c +7 -8
@@ -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 <[email protected]> +* 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,15 +13,15 @@* 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 <termios.h> #include "tst_test.h" +#include "lapi/ioctl.h" #define INVAL_IOCTL 9999999
testcases/kernel/syscalls/ioctl/ioctl02.c +3 -4
@@ -1,6 +1,6 @@/* -* * Copyright (c) International Business Machines Corp., 2001 +* Copyright (c) 2020 Petr Vorel <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -57,17 +57,16 @@*/ #include <stdio.h> -#include <termio.h> #include <fcntl.h> #include <signal.h> #include <errno.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/termios.h> +#include <termios.h> #include "test.h" #include "safe_macros.h" +#include "lapi/ioctl.h" #define CNUL 0
travis/alpine.sh +0 -4
@@ -30,8 +30,6 @@ cat /etc/os-release echo "WARNING: remove unsupported tests (until they're fixed)" cd .. rm -rfv \ - testcases/kernel/pty/pty01.c \ - testcases/kernel/pty/ptem01.c \ testcases/kernel/sched/process_stress/process.c \ testcases/kernel/syscalls/accept4/accept4_01.c \ testcases/kernel/syscalls/confstr/confstr01.c \
@@ -39,8 +37,6 @@ rm -rfv \ testcases/kernel/syscalls/getcontext/getcontext01.c \ testcases/kernel/syscalls/getdents/getdents01.c \ testcases/kernel/syscalls/getdents/getdents02.c \ - testcases/kernel/syscalls/ioctl/ioctl01.c \ - testcases/kernel/syscalls/ioctl/ioctl02.c \ testcases/kernel/syscalls/rt_tgsigqueueinfo/rt_tgsigqueueinfo01.c \ testcases/kernel/syscalls/sched_getaffinity/sched_getaffinity01.c \ testcases/kernel/syscalls/timer_create/timer_create01.c \
Signature · 1 line
2.24.1
PATCH v2 1/1 ioctl, pty Add: fallback definition of struct termio
Hi!
Looks good, acked.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 ioctl, pty Add: fallback definition of struct termio
Hi,
Quoted 2 lines
Hi!
Looks good, acked.
Thanks! I wonder if I should move new LTP_CHECK_TERMIO function from newly created ltp-termio.m4 into already existing ltp-ioctl.m4. If we want to bother.
BTW we might want do consider moving simple uses of AC_CHECK_TYPES (e.g. ltp-quota.m4) or AC_CHECK_MEMBERS (e.g. ltp-signal.m4, ltp-perf_event.m4) into configure.ac, similarly we did for AC_CHECK_HEADERS and AC_CHECK_FUNCS (to cut number of files in m4/, which just contain single line). But maybe this way it's easier to track why check was done.
Kind regards,
Petr
PATCH v2 1/1 ioctl, pty Add: fallback definition of struct termio
Hi!
Quoted 8 lines
Thanks! I wonder if I should move new
LTP_CHECK_TERMIOfunction from newly created ltp-termio.m4 into already existing ltp-ioctl.m4. If we want to bother.BTW we might want do consider moving simple uses of
AC_CHECK_TYPES(e.g. ltp-quota.m4) orAC_CHECK_MEMBERS(e.g. ltp-signal.m4, ltp-perf_event.m4) into configure.ac, similarly we did forAC_CHECK_HEADERSandAC_CHECK_FUNCS(to cut number of files in m4/, which just contain single line). But maybe this way it's easier to track why check was done.
I would say that either way is fine, but if you prefer having the simple ones in configure.ac then go for it.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 ioctl, pty Add: fallback definition of struct termio
Hi,
Quoted 11 lines
Quoted 8 lines
Thanks! I wonder if I should move new
LTP_CHECK_TERMIOfunction from newly created ltp-termio.m4 into already existing ltp-ioctl.m4. If we want to bother.BTW we might want do consider moving simple uses of
AC_CHECK_TYPES(e.g. ltp-quota.m4) orAC_CHECK_MEMBERS(e.g. ltp-signal.m4, ltp-perf_event.m4) into configure.ac, similarly we did forAC_CHECK_HEADERSandAC_CHECK_FUNCS(to cut number of files in m4/, which just contain single line). But maybe this way it's easier to track why check was done.I would say that either way is fine, but if you prefer having the simple ones in configure.ac then go for it.
OK, I kept it as it is and I'll prepare some autotools cleanup patch. Thanks for your review.
Kind regards,
Petr