summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaojie Sun <sunshaojie@kylinos.cn>2026-07-30 21:07:17 +0800
committerTejun Heo <tj@kernel.org>2026-08-02 09:50:55 -1000
commit77bc7e952f660a7bab9741fe352f960f3675a650 (patch)
tree0e3e1e07a795dacc8788081db3653af0c4c5ad51
parentae649c9636244a7529a1559c143d4ce9c5da62fa (diff)
downloadlinux-77bc7e952f660a7bab9741fe352f960f3675a650.tar.gz
linux-77bc7e952f660a7bab9741fe352f960f3675a650.zip
selftests/cgroup: add user_usec sanity check in test_cpucg_nice
In test_cpucg_nice, after the child process exits, user_usec is read from cpu.stat but the value is not checked. Add a sanity check to ensure user_usec > 0, analogous to test_cpucg_stats(), so that the test fails early if CPU usage wasn't properly accounted. Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn> Reviewed-by: Michal Koutný <mkoutny@suse.com> Acked-by: Tao Cui <cuitao@kylinos.cn> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--tools/testing/selftests/cgroup/test_cpu.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c
index a5eccfcabef5..f9f7017d9299 100644
--- a/tools/testing/selftests/cgroup/test_cpu.c
+++ b/tools/testing/selftests/cgroup/test_cpu.c
@@ -291,6 +291,8 @@ static int test_cpucg_nice(const char *root)
user_usec = cg_read_key_long(cpucg, "cpu.stat", "user_usec");
nice_usec = cg_read_key_long(cpucg, "cpu.stat", "nice_usec");
+ if (user_usec <= 0)
+ goto cleanup;
if (!values_close_report(nice_usec, expected_nice_usec, 1))
goto cleanup;