Skip to content

Commit dd7588e

Browse files
Werkovhtejun
authored andcommitted
selftests: cgroup: Add support for named v1 hierarchies in test_core
This comes useful when using selftests from mainline on older kernels/setups that still rely on cgroup v1. The core tests that rely on v2 specific features are skipped, the remaining ones are adjusted to work with a v1 hierarchy. The expected output on v1 system: ok 1 # SKIP test_cgcore_internal_process_constraint ok 2 # SKIP test_cgcore_top_down_constraint_enable ok 3 # SKIP test_cgcore_top_down_constraint_disable ok 4 # SKIP test_cgcore_no_internal_process_constraint_on_threads ok 5 # SKIP test_cgcore_parent_becomes_threaded ok 6 # SKIP test_cgcore_invalid_domain ok 7 # SKIP test_cgcore_populated ok 8 test_cgcore_proc_migration ok 9 test_cgcore_thread_migration ok 10 test_cgcore_destroy ok 11 test_cgcore_lesser_euid_open ok 12 # SKIP test_cgcore_lesser_ns_open Signed-off-by: Michal Koutný <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 0925275 commit dd7588e

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

tools/testing/selftests/cgroup/test_core.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ static int test_cgcore_populated(const char *root)
148148
int cgroup_fd = -EBADF;
149149
pid_t pid;
150150

151+
if (cg_test_v1_named)
152+
return KSFT_SKIP;
153+
151154
cg_test_a = cg_name(root, "cg_test_a");
152155
cg_test_b = cg_name(root, "cg_test_a/cg_test_b");
153156
cg_test_c = cg_name(root, "cg_test_a/cg_test_b/cg_test_c");
@@ -277,6 +280,9 @@ static int test_cgcore_invalid_domain(const char *root)
277280
int ret = KSFT_FAIL;
278281
char *grandparent = NULL, *parent = NULL, *child = NULL;
279282

283+
if (cg_test_v1_named)
284+
return KSFT_SKIP;
285+
280286
grandparent = cg_name(root, "cg_test_grandparent");
281287
parent = cg_name(root, "cg_test_grandparent/cg_test_parent");
282288
child = cg_name(root, "cg_test_grandparent/cg_test_parent/cg_test_child");
@@ -339,6 +345,9 @@ static int test_cgcore_parent_becomes_threaded(const char *root)
339345
int ret = KSFT_FAIL;
340346
char *parent = NULL, *child = NULL;
341347

348+
if (cg_test_v1_named)
349+
return KSFT_SKIP;
350+
342351
parent = cg_name(root, "cg_test_parent");
343352
child = cg_name(root, "cg_test_parent/cg_test_child");
344353
if (!parent || !child)
@@ -378,7 +387,8 @@ static int test_cgcore_no_internal_process_constraint_on_threads(const char *roo
378387
int ret = KSFT_FAIL;
379388
char *parent = NULL, *child = NULL;
380389

381-
if (cg_read_strstr(root, "cgroup.controllers", "cpu") ||
390+
if (cg_test_v1_named ||
391+
cg_read_strstr(root, "cgroup.controllers", "cpu") ||
382392
cg_write(root, "cgroup.subtree_control", "+cpu")) {
383393
ret = KSFT_SKIP;
384394
goto cleanup;
@@ -430,6 +440,9 @@ static int test_cgcore_top_down_constraint_enable(const char *root)
430440
int ret = KSFT_FAIL;
431441
char *parent = NULL, *child = NULL;
432442

443+
if (cg_test_v1_named)
444+
return KSFT_SKIP;
445+
433446
parent = cg_name(root, "cg_test_parent");
434447
child = cg_name(root, "cg_test_parent/cg_test_child");
435448
if (!parent || !child)
@@ -465,6 +478,9 @@ static int test_cgcore_top_down_constraint_disable(const char *root)
465478
int ret = KSFT_FAIL;
466479
char *parent = NULL, *child = NULL;
467480

481+
if (cg_test_v1_named)
482+
return KSFT_SKIP;
483+
468484
parent = cg_name(root, "cg_test_parent");
469485
child = cg_name(root, "cg_test_parent/cg_test_child");
470486
if (!parent || !child)
@@ -506,6 +522,9 @@ static int test_cgcore_internal_process_constraint(const char *root)
506522
int ret = KSFT_FAIL;
507523
char *parent = NULL, *child = NULL;
508524

525+
if (cg_test_v1_named)
526+
return KSFT_SKIP;
527+
509528
parent = cg_name(root, "cg_test_parent");
510529
child = cg_name(root, "cg_test_parent/cg_test_child");
511530
if (!parent || !child)
@@ -642,10 +661,12 @@ static int test_cgcore_thread_migration(const char *root)
642661
if (cg_create(grps[2]))
643662
goto cleanup;
644663

645-
if (cg_write(grps[1], "cgroup.type", "threaded"))
646-
goto cleanup;
647-
if (cg_write(grps[2], "cgroup.type", "threaded"))
648-
goto cleanup;
664+
if (!cg_test_v1_named) {
665+
if (cg_write(grps[1], "cgroup.type", "threaded"))
666+
goto cleanup;
667+
if (cg_write(grps[2], "cgroup.type", "threaded"))
668+
goto cleanup;
669+
}
649670

650671
if (cg_enter_current(grps[1]))
651672
goto cleanup;

0 commit comments

Comments
 (0)