aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/clone3
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@gmail.com>2019-11-17 22:47:48 -0800
committerChristian Brauner <christian.brauner@ubuntu.com>2019-11-18 08:57:23 +0100
commit4f5c289ea66a33457d51b305d4d77e1ca4c8ff17 (patch)
tree5d6568cbad4f6e5b588cb0421f670ae3557252e5 /tools/testing/selftests/clone3
parentselftests: add tests for clone3() with *set_tid (diff)
downloadlinux-dev-4f5c289ea66a33457d51b305d4d77e1ca4c8ff17.tar.xz
linux-dev-4f5c289ea66a33457d51b305d4d77e1ca4c8ff17.zip
selftests/clone3: flush stdout and stderr before clone3() and _exit()
Buffers have to be flushed before clone3() to avoid double messages in the log. Fixes: 41585bbeeef9 ("selftests: add tests for clone3() with *set_tid") Signed-off-by: Andrei Vagin <avagin@gmail.com> Link: https://lore.kernel.org/r/20191118064750.408003-1-avagin@gmail.com Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Diffstat (limited to 'tools/testing/selftests/clone3')
-rw-r--r--tools/testing/selftests/clone3/clone3_selftests.h2
-rw-r--r--tools/testing/selftests/clone3/clone3_set_tid.c15
2 files changed, 13 insertions, 4 deletions
diff --git a/tools/testing/selftests/clone3/clone3_selftests.h b/tools/testing/selftests/clone3/clone3_selftests.h
index 1a270390766a..0e3dea58855f 100644
--- a/tools/testing/selftests/clone3/clone3_selftests.h
+++ b/tools/testing/selftests/clone3/clone3_selftests.h
@@ -29,6 +29,8 @@ struct clone_args {
static pid_t sys_clone3(struct clone_args *args, size_t size)
{
+ fflush(stdout);
+ fflush(stderr);
return syscall(__NR_clone3, args, size);
}
diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c
index 3480e1c46983..e93369dcfe3b 100644
--- a/tools/testing/selftests/clone3/clone3_set_tid.c
+++ b/tools/testing/selftests/clone3/clone3_set_tid.c
@@ -30,6 +30,13 @@
static int pipe_1[2];
static int pipe_2[2];
+static void child_exit(int ret)
+{
+ fflush(stdout);
+ fflush(stderr);
+ _exit(ret);
+}
+
static int call_clone3_set_tid(pid_t *set_tid,
size_t set_tid_size,
int flags,
@@ -84,8 +91,8 @@ static int call_clone3_set_tid(pid_t *set_tid,
}
if (set_tid[0] != getpid())
- _exit(EXIT_FAILURE);
- _exit(exit_code);
+ child_exit(EXIT_FAILURE);
+ child_exit(exit_code);
}
if (expected_pid == 0 || expected_pid == pid) {
@@ -249,7 +256,7 @@ int main(int argc, char *argv[])
pid = fork();
if (pid == 0) {
ksft_print_msg("Child has PID %d\n", getpid());
- _exit(EXIT_SUCCESS);
+ child_exit(EXIT_SUCCESS);
}
if (waitpid(pid, &status, 0) < 0)
ksft_exit_fail_msg("Waiting for child %d failed", pid);
@@ -309,7 +316,7 @@ int main(int argc, char *argv[])
*/
test_clone3_set_tid(set_tid, 3, CLONE_NEWPID, 0, 42, true);
- _exit(ksft_cnt.ksft_pass);
+ child_exit(ksft_cnt.ksft_pass);
}
close(pipe_1[1]);