From: Andrei Vagin <avagin@gmail.com>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Adrian Reber <areber@redhat.com>,
linux-kernel@vger.kernel.org, Andrei Vagin <avagin@gmail.com>
Subject: [PATCH 3/3] selftests/clone3: check that all pids are released on error paths
Date: Sun, 17 Nov 2019 22:47:50 -0800 [thread overview]
Message-ID: <20191118064750.408003-3-avagin@gmail.com> (raw)
In-Reply-To: <20191118064750.408003-1-avagin@gmail.com>
This is a regression test case for an issue when pids have not been
released on error paths.
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
tools/testing/selftests/clone3/clone3_set_tid.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/clone3/clone3_set_tid.c b/tools/testing/selftests/clone3/clone3_set_tid.c
index 9c19bae03661..c6309f5d7d88 100644
--- a/tools/testing/selftests/clone3/clone3_set_tid.c
+++ b/tools/testing/selftests/clone3/clone3_set_tid.c
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
ksft_exit_fail_msg("pipe() failed\n");
ksft_print_header();
- ksft_set_plan(27);
+ ksft_set_plan(29);
f = fopen("/proc/sys/kernel/pid_max", "r");
if (f == NULL)
@@ -290,6 +290,18 @@ int main(int argc, char *argv[])
/* Let's create a PID 1 */
ns_pid = fork();
if (ns_pid == 0) {
+ /*
+ * This and the next test cases check that all pid-s are
+ * released on error paths.
+ */
+ set_tid[0] = 43;
+ set_tid[1] = -1;
+ test_clone3_set_tid(set_tid, 2, 0, -EINVAL, 0, 0);
+
+ set_tid[0] = 43;
+ set_tid[1] = pid;
+ test_clone3_set_tid(set_tid, 2, 0, 0, 43, 0);
+
ksft_print_msg("Child in PID namespace has PID %d\n", getpid());
set_tid[0] = 2;
test_clone3_set_tid(set_tid, 1, 0, 0, 2, 0);
@@ -366,7 +378,7 @@ int main(int argc, char *argv[])
if (!WIFEXITED(status))
ksft_test_result_fail("Child error\n");
- ksft_cnt.ksft_pass += 4 - (ksft_cnt.ksft_fail - WEXITSTATUS(status));
+ ksft_cnt.ksft_pass += 6 - (ksft_cnt.ksft_fail - WEXITSTATUS(status));
ksft_cnt.ksft_fail = WEXITSTATUS(status);
if (ns3 == pid && ns2 == 42 && ns1 == 1)
--
2.23.0
next prev parent reply other threads:[~2019-11-18 6:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-18 6:47 [PATCH 1/3] selftests/clone3: flush stdout and stderr before clone3() and _exit() Andrei Vagin
2019-11-18 6:47 ` [PATCH 2/3] selftests/clone3: report a correct number of fails Andrei Vagin
2019-11-18 7:38 ` Christian Brauner
2019-11-18 6:47 ` Andrei Vagin [this message]
2019-11-18 7:38 ` [PATCH 3/3] selftests/clone3: check that all pids are released on error paths Christian Brauner
2019-11-18 7:37 ` [PATCH 1/3] selftests/clone3: flush stdout and stderr before clone3() and _exit() Christian Brauner
2019-11-18 8:24 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191118064750.408003-3-avagin@gmail.com \
--to=avagin@gmail.com \
--cc=areber@redhat.com \
--cc=christian.brauner@ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome