[LTP] [PATCH 1/1] ioctl01: Workaround segfault on ppc64le
Petr Vorel
pvorel@suse.cz
Thu Nov 14 18:29:11 CET 2024
Testing termio/termios invalid/NULL address for EFAULT fails on ppc64le.
Use typical LTP workaround to test by forked child + checking the
terminating signal (on all archs).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/kernel/syscalls/ioctl/ioctl01.c | 45 ++++++++++++++++++++---
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
index c84a72b9a2..e4f32330d0 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
@@ -2,7 +2,7 @@
/*
* Copyright (c) International Business Machines Corp., 2001
* Copyright (c) 2020 Petr Vorel <petr.vorel@gmail.com>
- * Copyright (c) Linux Test Project, 2002-2023
+ * Copyright (c) Linux Test Project, 2002-2024
* 07/2001 Ported by Wayne Boyer
* 04/2002 Fixes by wjhuie
*/
@@ -59,8 +59,42 @@ static struct tcase {
static void verify_ioctl(unsigned int i)
{
- TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
- tcases[i].error, "%s", tcases[i].desc);
+ struct tcase *tc = &tcases[i];
+
+ TST_EXP_FAIL(ioctl(*(tc->fd), tc->request, tc->s_tio), tc->error, "%s",
+ tc->desc);
+}
+
+static void test_bad_addr(unsigned int i)
+{
+ pid_t pid;
+ int status;
+
+ pid = SAFE_FORK();
+ if (!pid) {
+ verify_ioctl(i);
+ _exit(0);
+ }
+
+ SAFE_WAITPID(pid, &status, 0);
+
+ if (WIFEXITED(status) && !WEXITSTATUS(status))
+ return;
+
+ if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+ tst_res(TPASS, "Child killed by expected signal");
+ return;
+ }
+
+ tst_res(TFAIL, "Child %s", tst_strstatus(status));
+}
+
+static void do_test(unsigned int i)
+{
+ if (tcases[i].error == EFAULT)
+ test_bad_addr(i);
+ else
+ verify_ioctl(i);
}
static void setup(void)
@@ -86,6 +120,7 @@ static struct tst_test test = {
.needs_tmpdir = 1,
.setup = setup,
.cleanup = cleanup,
- .test = verify_ioctl,
- .tcnt = ARRAY_SIZE(tcases)
+ .test = do_test,
+ .tcnt = ARRAY_SIZE(tcases),
+ .forks_child = 1,
};
--
2.45.2
More information about the ltp
mailing list