History log of /linux-master/tools/testing/selftests/cgroup/test_core.c
Revision Date Author Comments
# 12101424 03-Jul-2023 Michal Koutný <mkoutny@suse.com>

selftests: cgroup: Minor code reorganizations

No functional change intended, these small changes are merged into one
commit and they serve as a preparation for an upcoming new testcase.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# bf35a787 06-Jan-2022 Tejun Heo <tj@kernel.org>

selftests: cgroup: Test open-time cgroup namespace usage for migration checks

When a task is writing to an fd opened by a different task, the perm check
should use the cgroup namespace of the latter task. Add a test for it.

Tested-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 613e040e 06-Jan-2022 Tejun Heo <tj@kernel.org>

selftests: cgroup: Test open-time credential usage for migration checks

When a task is writing to an fd opened by a different task, the perm check
should use the credentials of the latter task. Add a test for it.

Tested-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 9bd5910d 05-Feb-2020 Christian Brauner <christian.brauner@ubuntu.com>

selftests/cgroup: add tests for cloning into cgroups

Expand the cgroup test-suite to include tests for CLONE_INTO_CGROUP.
This adds the following tests:
- CLONE_INTO_CGROUP manages to clone a process directly into a correctly
delegated cgroup
- CLONE_INTO_CGROUP fails to clone a process into a cgroup that has been
removed after we've opened an fd to it
- CLONE_INTO_CGROUP fails to clone a process into an invalid domain
cgroup
- CLONE_INTO_CGROUP adheres to the no internal process constraint
- CLONE_INTO_CGROUP works with the freezer feature

Cc: Tejun Heo <tj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: cgroups@vger.kernel.org
Cc: linux-kselftest@vger.kernel.org
Acked-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 04189382 23-Jan-2020 Suren Baghdasaryan <surenb@google.com>

kselftest/cgroup: add cgroup destruction test

Add new test to verify that a cgroup with dead processes can be destroyed.
The test spawns a child process which allocates and touches 100MB of RAM
to ensure prolonged exit. Subsequently it kills the child, waits until
the cgroup containing the child is empty and destroys the cgroup.

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
[mkoutny@suse.com: Fix typo in test_cgcore_destroy comment]
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 192c197c 07-Jan-2020 Dan Carpenter <dan.carpenter@oracle.com>

selftests: Uninitialized variable in test_cgcore_proc_migration()

The "c_threads" variable is used in the error handling code before it
has been initialized

Fixes: 11318989c381 ("selftests: cgroup: Add task migration tests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# 11318989 03-Oct-2019 Michal Koutný <mkoutny@suse.com>

selftests: cgroup: Add task migration tests

Add two new tests that verify that thread and threadgroup migrations
work as expected.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# f97f3f88 27-May-2019 Alex Shi <alex.shi@linux.alibaba.com>

kselftest/cgroup: fix incorrect test_core skip

The test_core will skip the
test_cgcore_no_internal_process_constraint_on_threads test case if the
'cpu' controller missing in root's subtree_control. In fact we need to
set the 'cpu' in subtree_control, to make the testing meaningful.

./test_core
...
ok 4 # skip test_cgcore_no_internal_process_constraint_on_threads
...

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Claudio Zumbo <claudioz@fb.com>
Cc: Claudio <claudiozumbo@gmail.com>
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# 00e38a5d 27-May-2019 Alex Shi <alex.shi@linux.alibaba.com>

kselftest/cgroup: fix unexpected testing failure on test_core

The cgroup testing relys on the root cgroup's subtree_control setting,
If the 'memory' controller isn't set, some test cases will be failed
as following:

$sudo ./test_core
not ok 1 test_cgcore_internal_process_constraint
ok 2 test_cgcore_top_down_constraint_enable
not ok 3 test_cgcore_top_down_constraint_disable
...

To correct this unexpected failure, this patch write the 'memory' to
subtree_control of root to get a right result.

Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Claudio Zumbo <claudioz@fb.com>
Cc: Claudio <claudiozumbo@gmail.com>
Cc: linux-kselftest@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# d863cb03fc 18-Jul-2018 Claudio <claudiozumbo@gmail.com>

Add cgroup core selftests

This commit adds tests for some of the core functionalities
of cgroups v2.

The commit adds tests for some core principles of croup V2 API:

- test_cgcore_internal_process_constraint

Tests internal process constraint.
You can't add a pid to a domain parent if a controller is enabled.

- test_cgcore_top_down_constraint_enable

Tests that you can't enable a controller on a child if it's not enabled
on the parent.

- test_cgcore_top_down_constraint_disable

Tests that you can't disable a controller on a parent if it's
enabled in a child.

- test_cgcore_no_internal_process_constraint_on_threads

Tests that there's no internal process constrain on threaded cgroups.
You can add threads/processes on a parent with a controller enabled.

- test_cgcore_parent_becomes_threaded

Tests that when a child becomes threaded the parent type becomes
domain threaded.

- test_cgcore_invalid_domain

In a situation like:

A (domain threaded) - B (threaded) - C (domain)

it tests that C can't be used until it is turned into a threaded cgroup.
The "cgroup.type" file will report "domain (invalid)" in these cases.
Operations which fail due to invalid topology use EOPNOTSUPP as the errno.

- test_cgcore_populated

In a situation like:

A(0) - B(0) - C(1)
\ D(0)

It tests that A, B and C's "populated" fields would be 1 while D's 0.
It tests that after the one process in C is moved to root, A,B and C's
"populated" fields would flip to "0" and file modified events will
be generated on the "cgroup.events" files of both cgroups.

Signed-off-by: Claudio Zumbo <claudioz@fb.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: kernel-team@fb.com
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>