Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: alex.shi at linux.alibaba.com (Alex Shi)
Subject: [PATCH v3 2/3] kselftest/cgroup: fix unexpected testing failure on test_core
Date: Mon, 27 May 2019 14:28:06 +0800	[thread overview]
Message-ID: <20190527062807.93404-2-alex.shi@linux.alibaba.com> (raw)
In-Reply-To: <20190527062807.93404-1-alex.shi@linux.alibaba.com>

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 at linux.alibaba.com>
Cc: Shuah Khan <shuah at kernel.org>
Cc: Tejun Heo <tj at kernel.org>
Cc: Roman Gushchin <guro at fb.com>
Cc: Claudio Zumbo <claudioz at fb.com>
Cc: Claudio <claudiozumbo at gmail.com>
Cc: linux-kselftest at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Reviewed-by: Roman Gushchin <guro at fb.com>
Acked-by: Tejun Heo <tj at kernel.org>
---
 tools/testing/selftests/cgroup/test_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
index be59f9c34ea2..d78f1c5366d3 100644
--- a/tools/testing/selftests/cgroup/test_core.c
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -376,6 +376,11 @@ int main(int argc, char *argv[])
 
 	if (cg_find_unified_root(root, sizeof(root)))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+
+	if (cg_read_strstr(root, "cgroup.subtree_control", "memory"))
+		if (cg_write(root, "cgroup.subtree_control", "+memory"))
+			ksft_exit_skip("Failed to set memory controller\n");
+
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
-- 
2.19.1.856.g8858448bb

WARNING: multiple messages have this Message-ID (diff)
From: alex.shi@linux.alibaba.com (Alex Shi)
Subject: [PATCH v3 2/3] kselftest/cgroup: fix unexpected testing failure on test_core
Date: Mon, 27 May 2019 14:28:06 +0800	[thread overview]
Message-ID: <20190527062807.93404-2-alex.shi@linux.alibaba.com> (raw)
Message-ID: <20190527062806.WRH8W_ds_YCK5ytB6ZtYCfF70V1eZ4nf6kRpcmy_PBs@z> (raw)
In-Reply-To: <20190527062807.93404-1-alex.shi@linux.alibaba.com>

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 at linux.alibaba.com>
Cc: Shuah Khan <shuah at kernel.org>
Cc: Tejun Heo <tj at kernel.org>
Cc: Roman Gushchin <guro at fb.com>
Cc: Claudio Zumbo <claudioz at fb.com>
Cc: Claudio <claudiozumbo at gmail.com>
Cc: linux-kselftest at vger.kernel.org
Cc: linux-kernel at vger.kernel.org
Reviewed-by: Roman Gushchin <guro at fb.com>
Acked-by: Tejun Heo <tj at kernel.org>
---
 tools/testing/selftests/cgroup/test_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c
index be59f9c34ea2..d78f1c5366d3 100644
--- a/tools/testing/selftests/cgroup/test_core.c
+++ b/tools/testing/selftests/cgroup/test_core.c
@@ -376,6 +376,11 @@ int main(int argc, char *argv[])
 
 	if (cg_find_unified_root(root, sizeof(root)))
 		ksft_exit_skip("cgroup v2 isn't mounted\n");
+
+	if (cg_read_strstr(root, "cgroup.subtree_control", "memory"))
+		if (cg_write(root, "cgroup.subtree_control", "+memory"))
+			ksft_exit_skip("Failed to set memory controller\n");
+
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		switch (tests[i].fn(root)) {
 		case KSFT_PASS:
-- 
2.19.1.856.g8858448bb

  parent reply	other threads:[~2019-05-27  6:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27  6:28 [PATCH v3 1/3] kselftest/cgroup: fix unexpected testing failure on test_memcontrol alex.shi
2019-05-27  6:28 ` Alex Shi
2019-05-27  6:28 ` alex.shi [this message]
2019-05-27  6:28   ` [PATCH v3 2/3] kselftest/cgroup: fix unexpected testing failure on test_core Alex Shi
2019-05-27  6:28 ` [PATCH v3 3/3] kselftest/cgroup: fix incorrect test_core skip alex.shi
2019-05-27  6:28   ` Alex Shi

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=20190527062807.93404-2-alex.shi@linux.alibaba.com \
    --to=linux-kselftest@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