* [LTP] [PATCH V3] container: new testcase pidns32
@ 2015-08-14 8:17 Yuan Sun
2015-08-17 13:33 ` Jan Stancek
0 siblings, 1 reply; 3+ messages in thread
From: Yuan Sun @ 2015-08-14 8:17 UTC (permalink / raw)
To: jstancek; +Cc: ltp-list
Kernel imposes a limit of 32 nested levels of pid namespaces.
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
---
runtest/containers | 1 +
testcases/kernel/containers/pidns/.gitignore | 1 +
testcases/kernel/containers/pidns/pidns32.c | 103 +++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
create mode 100644 testcases/kernel/containers/pidns/pidns32.c
diff --git a/runtest/containers b/runtest/containers
index 9dc44bc..ac37ab2 100644
--- a/runtest/containers
+++ b/runtest/containers
@@ -13,6 +13,7 @@ pidns17 pidns17
pidns20 pidns20
pidns30 pidns30
pidns31 pidns31
+pidns32 pidns32
mqns_01 mqns_01
mqns_01_clone mqns_01 -clone
diff --git a/testcases/kernel/containers/pidns/.gitignore b/testcases/kernel/containers/pidns/.gitignore
index e56c1f9..488b045 100644
--- a/testcases/kernel/containers/pidns/.gitignore
+++ b/testcases/kernel/containers/pidns/.gitignore
@@ -12,3 +12,4 @@
/pidns20
/pidns30
/pidns31
+/pidns32
diff --git a/testcases/kernel/containers/pidns/pidns32.c b/testcases/kernel/containers/pidns/pidns32.c
new file mode 100644
index 0000000..fe530d3
--- /dev/null
+++ b/testcases/kernel/containers/pidns/pidns32.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) Huawei Technologies Co., Ltd., 2015
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ */
+
+/*
+ * Verify that:
+ * The kernel imposes a limit of 32 nested levels of pid namespaces.
+ */
+
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include "test.h"
+#include "pidns_helper.h"
+
+#define MAXNEST 32
+
+char *TCID = "pidns32";
+int TST_TOTAL = 1;
+
+static void setup(void)
+{
+ if (tst_kvercmp(3, 7, 0) < 0)
+ tst_brkm(TCONF, NULL, "nest depth limitation not supported");
+ tst_require_root();
+ check_newpid();
+ tst_tmpdir();
+}
+
+static void cleanup(void)
+{
+ tst_rmdir();
+}
+
+static int child_fn1(void *arg)
+{
+ pid_t cpid1;
+ long level = (long)arg;
+ int status;
+
+ if (level == MAXNEST)
+ return 0;
+ cpid1 = ltp_clone_quick(CLONE_NEWPID | SIGCHLD,
+ (void *)child_fn1, (void *)(level + 1));
+ if (cpid1 < 0) {
+ printf("level %ld:unexpected error: (%d) %s\n",
+ level, errno, strerror(errno));
+ return -1;
+ }
+ if (waitpid(cpid1, &status, 0) == -1)
+ return -1;
+
+ if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
+ printf("child exited abnormally\n");
+ return -1;
+ } else if (WIFSIGNALED(status)) {
+ printf("child was killed with signal = %d", WTERMSIG(status));
+ return -1;
+ }
+ return 0;
+}
+
+static void test_max_nest(void)
+{
+ pid_t cpid1;
+
+ cpid1 = ltp_clone_quick(CLONE_NEWPID | SIGCHLD,
+ (void *)child_fn1, (void *)1);
+ if (cpid1 < 0)
+ tst_brkm(TBROK | TERRNO, cleanup, "clone failed");
+
+ tst_record_childstatus(cleanup, cpid1);
+}
+
+int main(int argc, char *argv[])
+{
+ int lc;
+
+ setup();
+ tst_parse_opts(argc, argv, NULL, NULL);
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ tst_count = 0;
+ test_max_nest();
+ }
+
+ cleanup();
+ tst_exit();
+}
--
1.9.1
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] [PATCH V3] container: new testcase pidns32
2015-08-14 8:17 [LTP] [PATCH V3] container: new testcase pidns32 Yuan Sun
@ 2015-08-17 13:33 ` Jan Stancek
2015-08-18 1:08 ` Yuan Sun
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2015-08-17 13:33 UTC (permalink / raw)
To: Yuan Sun; +Cc: ltp-list
----- Original Message -----
> From: "Yuan Sun" <sunyuan3@huawei.com>
> To: jstancek@redhat.com
> Cc: ltp-list@lists.sourceforge.net
> Sent: Friday, 14 August, 2015 10:17:24 AM
> Subject: [PATCH V3] container: new testcase pidns32
>
> Kernel imposes a limit of 32 nested levels of pid namespaces.
>
> Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
Hi,
pushed with updated commit message and removed kernel version check.
Since we expect that 32 levels will work on any kernel, there's
no need for it now.
Regards,
Jan
> ---
> runtest/containers | 1 +
> testcases/kernel/containers/pidns/.gitignore | 1 +
> testcases/kernel/containers/pidns/pidns32.c | 103
> +++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
> create mode 100644 testcases/kernel/containers/pidns/pidns32.c
>
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH V3] container: new testcase pidns32
2015-08-17 13:33 ` Jan Stancek
@ 2015-08-18 1:08 ` Yuan Sun
0 siblings, 0 replies; 3+ messages in thread
From: Yuan Sun @ 2015-08-18 1:08 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
On 2015/8/17 21:33, Jan Stancek wrote:
>
>
>
> ----- Original Message -----
>> From: "Yuan Sun" <sunyuan3@huawei.com>
>> To: jstancek@redhat.com
>> Cc: ltp-list@lists.sourceforge.net
>> Sent: Friday, 14 August, 2015 10:17:24 AM
>> Subject: [PATCH V3] container: new testcase pidns32
>>
>> Kernel imposes a limit of 32 nested levels of pid namespaces.
>>
>> Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
> Hi,
>
> pushed with updated commit message and removed kernel version check.
> Since we expect that 32 levels will work on any kernel, there's
> no need for it now.
Yes, you are right. I agree with you. Thank you.
Yuan
>
> Regards,
> Jan
>
>> ---
>> runtest/containers | 1 +
>> testcases/kernel/containers/pidns/.gitignore | 1 +
>> testcases/kernel/containers/pidns/pidns32.c | 103
>> +++++++++++++++++++++++++++
>> 3 files changed, 105 insertions(+)
>> create mode 100644 testcases/kernel/containers/pidns/pidns32.c
>>
>
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-18 1:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14 8:17 [LTP] [PATCH V3] container: new testcase pidns32 Yuan Sun
2015-08-17 13:33 ` Jan Stancek
2015-08-18 1:08 ` Yuan Sun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox