[LTP] [PATCH] ioctl_pidfd05: Check if PIDFD_INFO_EXIT is available

Avinesh Kumar
2025-09-17T16:54:30Z

This test also needs this check as it might fail with
ioctl_pidfd05.c:45: TFAIL: ioctl(pidfd, PIDFD_GET_INFO, NULL) expected EINVAL: ENOTTY (25)
ioctl_pidfd05.c:46: TFAIL: ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) expected EINVAL: ENOTTY (25)
when system does not have PIDFD_INFO_EXIT implementation.

Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
index c379717b3..01ea363b6 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
@@ -14,7 +14,7 @@
#include "tst_test.h"
#include "lapi/pidfd.h"
#include "lapi/sched.h"
-#include "lapi/ioctl.h"
+#include "ioctl_pidfd.h"

struct pidfd_info_invalid {
uint32_t dummy;
@@ -48,8 +48,15 @@ static void run(void)
SAFE_CLOSE(pidfd);
}

+static void setup(void)
+{
+ if (!ioctl_pidfd_info_exit_supported())
+ tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
+}
+
static struct tst_test test = {
.test_all = run,
+ .setup = setup,
.forks_child = 1,
.bufs = (struct tst_buffers []) {
{&args, .size = sizeof(*args)},
--
2.51.0