Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / pid_namespace / regression_enomem.c
blob7d84097ad45c55317c7aa3fdb9d80fd5d37178fd
1 #define _GNU_SOURCE
2 #include <assert.h>
3 #include <errno.h>
4 #include <fcntl.h>
5 #include <linux/types.h>
6 #include <sched.h>
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <syscall.h>
12 #include <sys/wait.h>
14 #include "../kselftest_harness.h"
15 #include "../pidfd/pidfd.h"
18 * Regression test for:
19 * 35f71bc0a09a ("fork: report pid reservation failure properly")
20 * b26ebfe12f34 ("pid: Fix error return value in some cases")
22 TEST(regression_enomem)
24 pid_t pid;
26 if (geteuid())
27 EXPECT_EQ(0, unshare(CLONE_NEWUSER));
29 EXPECT_EQ(0, unshare(CLONE_NEWPID));
31 pid = fork();
32 ASSERT_GE(pid, 0);
34 if (pid == 0)
35 exit(EXIT_SUCCESS);
37 EXPECT_EQ(0, wait_for_pid(pid));
39 pid = fork();
40 ASSERT_LT(pid, 0);
41 ASSERT_EQ(errno, ENOMEM);
44 TEST_HARNESS_MAIN