Merge tag 'linux-kselftest-fixes-6.1-rc4' of git://git.kernel.org/pub/scm/linux/kerne...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Nov 2022 18:03:38 +0000 (11:03 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Nov 2022 18:03:38 +0000 (11:03 -0700)
Pull Kselftest fixes from Shuah Khan:
 "Fixes to the pidfd test"

* tag 'linux-kselftest-fixes-6.1-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/pidfd_test: Remove the erroneous ','
  selftests: pidfd: Fix compling warnings
  ksefltests: pidfd: Fix wait_states: Test terminated by timeout

tools/testing/selftests/pidfd/Makefile
tools/testing/selftests/pidfd/pidfd_test.c
tools/testing/selftests/pidfd/pidfd_wait.c

index f4a2f28..778b6cd 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/ -pthread
+CFLAGS += -g -I../../../../usr/include/ -pthread -Wall
 
 TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \
        pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test
index 9a2d649..e2dd4ed 100644 (file)
@@ -413,7 +413,7 @@ static void poll_pidfd(const char *test_name, int pidfd)
 
        c = epoll_wait(epoll_fd, events, MAX_EVENTS, 5000);
        if (c != 1 || !(events[0].events & EPOLLIN))
-               ksft_exit_fail_msg("%s test: Unexpected epoll_wait result (c=%d, events=%x) ",
+               ksft_exit_fail_msg("%s test: Unexpected epoll_wait result (c=%d, events=%x) "
                                   "(errno %d)\n",
                                   test_name, c, events[0].events, errno);
 
@@ -435,6 +435,8 @@ static int child_poll_exec_test(void *args)
         */
        while (1)
                sleep(1);
+
+       return 0;
 }
 
 static void test_pidfd_poll_exec(int use_waitpid)
index 070c1c8..0dcb836 100644 (file)
@@ -95,20 +95,28 @@ TEST(wait_states)
                .flags = CLONE_PIDFD | CLONE_PARENT_SETTID,
                .exit_signal = SIGCHLD,
        };
+       int pfd[2];
        pid_t pid;
        siginfo_t info = {
                .si_signo = 0,
        };
 
+       ASSERT_EQ(pipe(pfd), 0);
        pid = sys_clone3(&args);
        ASSERT_GE(pid, 0);
 
        if (pid == 0) {
+               char buf[2];
+
+               close(pfd[1]);
                kill(getpid(), SIGSTOP);
+               ASSERT_EQ(read(pfd[0], buf, 1), 1);
+               close(pfd[0]);
                kill(getpid(), SIGSTOP);
                exit(EXIT_SUCCESS);
        }
 
+       close(pfd[0]);
        ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WSTOPPED, NULL), 0);
        ASSERT_EQ(info.si_signo, SIGCHLD);
        ASSERT_EQ(info.si_code, CLD_STOPPED);
@@ -117,6 +125,8 @@ TEST(wait_states)
        ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGCONT, NULL, 0), 0);
 
        ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WCONTINUED, NULL), 0);
+       ASSERT_EQ(write(pfd[1], "C", 1), 1);
+       close(pfd[1]);
        ASSERT_EQ(info.si_signo, SIGCHLD);
        ASSERT_EQ(info.si_code, CLD_CONTINUED);
        ASSERT_EQ(info.si_pid, parent_tid);
@@ -138,7 +148,7 @@ TEST(wait_states)
 
 TEST(wait_nonblock)
 {
-       int pidfd, status = 0;
+       int pidfd;
        unsigned int flags = 0;
        pid_t parent_tid = -1;
        struct clone_args args = {