Skip to contentSkip to conversation

selftests: add tests for clone3()

PATCH In review Adrian Reber 2 participants 4 messages Nov 12, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 selftests: add tests for clone3()

This adds tests for clone3() with different values and sizes of struct clone_args.

This selftest was initially part of of the clone3() with PID selftest. After that patch was almost merged Eugene sent out a couple of patches to fix problems with these test.

This commit now only contains the clone3() selftest after the LPC decision to rework clone3() with PID to allow setting the PID in multiple PID namespaces including all of Eugene's patches.

---
v2:
- Applied Christian's suggestions
- Skip root-only tests when running as non-root
v3:
- Removed unnecessary test case (everything set to 1)
- Correctly handle children without SIGCHLD
v4:
- Small cosmetic fixes
- Added two more tests with different sizes

---
 MAINTAINERS                               |   1 +
 tools/testing/selftests/Makefile          |   1 +
 tools/testing/selftests/clone3/.gitignore |   1 +
 tools/testing/selftests/clone3/Makefile   |   7 +
 tools/testing/selftests/clone3/clone3.c   | 205 ++++++++++++++++++++++
 5 files changed, 215 insertions(+)
 create mode 100644 tools/testing/selftests/clone3/.gitignore
 create mode 100644 tools/testing/selftests/clone3/Makefile
 create mode 100644 tools/testing/selftests/clone3/clone3.c
MAINTAINERS +1 -0
index eb19fad370d7..4f4988fbe7b7 100644
@@ -12833,6 +12833,7 @@ S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
 F:	samples/pidfd/
 F:	tools/testing/selftests/pidfd/
+F:	tools/testing/selftests/clone3/
 K:	(?i)pidfd
 K:	(?i)clone3
 K:	\b(clone_args|kernel_clone_args)\b
tools/testing/selftests/Makefile +1 -0
index 4cdbae6f4e61..ad442364218a 100644
@@ -4,6 +4,7 @@ TARGETS += bpf
 TARGETS += breakpoints
 TARGETS += capabilities
 TARGETS += cgroup
+TARGETS += clone3
 TARGETS += cpufreq
 TARGETS += cpu-hotplug
 TARGETS += drivers/dma-buf
tools/testing/selftests/clone3/.gitignore new file +1 -0
new file mode 100644
index 000000000000..85d9d3ba2524
@@ -0,0 +1 @@
+clone3
tools/testing/selftests/clone3/Makefile new file +7 -0
new file mode 100644
index 000000000000..ea922c014ae4
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../usr/include/
+
+TEST_GEN_PROGS := clone3
+
+include ../lib.mk
tools/testing/selftests/clone3/clone3.c new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
2.23.0
Reviewed-by on v4 1/1
#1 lore raw
Quoted 7 lines · Adrian Reber

This adds tests for clone3() with different values and sizes of struct clone_args.

This selftest was initially part of of the clone3() with PID selftest. After that patch was almost merged Eugene sent out a couple of patches to fix problems with these test.

Quoted 6 lines

This commit now only contains the clone3() selftest after the LPC decision to rework clone3() with PID to allow setting the PID in multiple PID namespaces including all of Eugene's patches.

Queuing up for 5.5.
Thanks, Adrian!

#2 lore raw
Quoted 12 lines · Christian Brauner
Quoted 11 lines · Adrian Reber

This adds tests for clone3() with different values and sizes of struct clone_args.

This selftest was initially part of of the clone3() with PID selftest. After that patch was almost merged Eugene sent out a couple of patches to fix problems with these test.

This commit now only contains the clone3() selftest after the LPC decision to rework clone3() with PID to allow setting the PID in multiple PID namespaces including all of Eugene's patches.

Quoted 7 lines
Quoted 2 lines

Queuing up for 5.5.
Thanks, Adrian!

One thing, can you tell me what the base tree for your commit is, please? Given that this is just one commit it should be enough if you give me the "base-commit" line from the end of the patch created via:
git format-patch --base=HEAD~1 HEAD~1

Thanks!
Christian

#3 lore raw
Quoted 19 lines · Christian Brauner
Quoted 18 lines · Christian Brauner
Quoted 7 lines · Adrian Reber

This adds tests for clone3() with different values and sizes of struct clone_args.

This selftest was initially part of of the clone3() with PID selftest. After that patch was almost merged Eugene sent out a couple of patches to fix problems with these test.

Quoted 6 lines

This commit now only contains the clone3() selftest after the LPC decision to rework clone3() with PID to allow setting the PID in multiple PID namespaces including all of Eugene's patches.

Queuing up for 5.5.
Thanks, Adrian!

Quoted 6 lines
Quoted 1 line

One thing, can you tell me what the base tree for your commit is, please? Given that this is just one commit it should be enough if you give me the "base-commit" line from the end of the patch created via:
git format-patch --base=HEAD~1 HEAD~1

Ok, merge base commit seems to have been v5.4-rc7. I've resolved a minor merge conflict (cf. [2]) when applying this commit to [1].

Christian

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=pidfd
[2]:

tools/testing/selftests/clone3/.gitignore +0 -0
diff --cc tools/testing/selftests/clone3/.gitignore
index 6c9f98097774,85d9d3ba2524..000000000000
@@@ -1,1 -1,1 +1,2 @@@
+ clone3
 +clone3_clear_sighand
tools/testing/selftests/clone3/Makefile +0 -0
diff --cc tools/testing/selftests/clone3/Makefile
index e6f259321e16,ea922c014ae4..000000000000
@@@ -1,6 -1,7 +1,6 @@@
- # SPDX-License-Identifier: GPL-2.0-only
+ # SPDX-License-Identifier: GPL-2.0
 +CFLAGS += -g -I../../../../usr/include/

- TEST_GEN_PROGS := clone3_clear_sighand
-CFLAGS += -I../../../../usr/include/
-
-TEST_GEN_PROGS := clone3
++TEST_GEN_PROGS := clone3 clone3_clear_sighand

include ../lib.mk