Bug 1217145 - LTP test ioctl02.c failed: ioctl TCSETA TCGETA inconsistent.
Summary: LTP test ioctl02.c failed: ioctl TCSETA TCGETA inconsistent.
Status: RESOLVED INVALID
Alias: None
Product: PUBLIC SUSE Linux Enterprise Server 15 SP6
Classification: openSUSE
Component: Kernel (show other bugs)
Version: unspecified
Hardware: PowerPC-64 Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Kernel Bugs
QA Contact:
URL: https://openqa.suse.de/tests/12799195...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-14 23:33 UTC by WEI GAO
Modified: 2024-02-26 16:08 UTC (History)
6 users (show)

See Also:
Found By: openQA
Services Priority:
Business Priority:
Blocker: Yes
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description WEI GAO 2023-11-14 23:33:01 UTC
## Observation
openQA test in scenario sle-15-SP6-Online-ppc64le-ltp_syscalls@ppc64le-virtio fails in
[ioctl02](https://openqa.suse.de/tests/12799195/modules/ioctl02/steps/7)

The main step for this test case are:
 
termio.c_lflag =((unsigned short)(ISIG | ICANON | XCASE | ECHO | ECHOE | NOFLSH));
IOCTL(parentfd, TCSETA, &termio);
IOCTL(parentfd, TCGETA, &termio);
chk_tty_parms(); <<<<< check the lflag is same as setting or not

LTP log:
susetest:~/ltp/testcases/kernel/syscalls/ioctl # ./ioctl02 -D /dev/tty0
tst_test.c:1690: TINFO: LTP version: 20230929
tst_test.c:1576: TINFO: Timeout per run is 0h 00m 30s
ioctl02.c:148: TFAIL: lflag has incorrect value. 40612
ioctl02.c:179: TINFO: child: parent has finished testing

In order to identify issue related with glibc or kernel, i replace ioctl to syscall directly but issue still exist, so it should be kernel related issue.

Code change:
-       SAFE_IOCTL(parentfd, TCSETA, &termio);
+       /* SAFE_IOCTL(parentfd, TCSETA, &termio); */
+
+       if (syscall(__NR_ioctl, parentfd, TCSETA, &termio) == -1) {
+               perror("Error getting terminal attributes");
+               return 1;
+       }

        /* Get termio and see if all parameters actually got set */
-       SAFE_IOCTL(parentfd, TCGETA, &termio);
+       /* SAFE_IOCTL(parentfd, TCGETA, &termio); */
+       if (syscall(__NR_ioctl, parentfd, TCGETA, &termio) == -1) {
+               perror("Error getting terminal attributes");
+               return 1;
+       }
        chk_tty_parms();
 }
Comment 1 Takashi Iwai 2023-11-17 14:22:23 UTC
Is it specific to powerpc, or can it be generically?

Also, is it a regression?  A bit more details please.
Comment 2 WEI GAO 2023-11-20 09:07:42 UTC
(In reply to Takashi Iwai from comment #1)
> Is it specific to powerpc, or can it be generically?
> 
ONLY happen on powerpc, such as x86 result is pass.
> Also, is it a regression?  A bit more details please.
Not regression. I move case manually run on 15sp5, issue still exist.
Comment 3 Petr Vorel 2024-02-20 16:47:47 UTC
FYI the problem started with this LTP change [1]:
which caused ppc64le specific failure (on any kernel version):
ioctl02.c:162: TFAIL: lflag has incorrect value. 40612
 
later change, which added struct termios [2] caused failing it on ppc64le (again, on any kernel version):
ioctl02.c:80: TINFO: Testing termios variant
ioctl02.c:141: TBROK: ioctl(3,(v->tcset),...) failed: ENOTTY (25)

[1] https://github.com/linux-test-project/ltp/commit/73dcf173c
[2] https://github.com/linux-test-project/ltp/commit/0ec2164
Comment 4 Petr Vorel 2024-02-20 17:03:28 UTC
I suppose similarly as for ioctl01.c (#1217134) glibc ppc64le specific handling of  TCSETS (and TCGETS) in sysdeps/unix/sysv/linux/powerpc/internal-ioctl.h causes ENOTTY. I wonder how to workaround it.
Comment 5 Martin Doucha 2024-02-26 16:08:59 UTC
Both failures (wrong c_lflag value and ENOTTY error) turn out to be a test issue.

The c_lflag value bug was due to NOFLSH bit not fitting into unsigned short on PPC64LE. It was stripped during TCSETS by typecast but included in the TCGETS check.

The ENOTTY was caused by including the wrong struct termios definition (and possibly also wrong TCSETS constant) from <termios.h>. The correct definition is in <asm/termbits.h>. Patch sent to LTP upstream.