From: Sebastian Chlad <sebastianchlad@gmail.com>
To: cgroups@vger.kernel.org
Cc: tejun@kernel.org, mkoutny@suse.com,
Sebastian Chlad <sebastian.chlad@suse.com>
Subject: [PATCH v2 2/2] selftests: cgroup: Use values_close_assert in test_cpu
Date: Wed, 15 Oct 2025 10:00:22 +0200 [thread overview]
Message-ID: <20251015080022.14883-3-sebastian.chlad@suse.com> (raw)
In-Reply-To: <20251015080022.14883-1-sebastian.chlad@suse.com>
Convert test_cpu to use the newly added values_close_assert() helper
to print detailed diagnostics when a tolerance check fails. This
provides clearer insight into deviations while run in the CI.
Signed-off-by: Sebastian Chlad <sebastian.chlad@suse.com>
---
tools/testing/selftests/cgroup/test_cpu.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/cgroup/test_cpu.c b/tools/testing/selftests/cgroup/test_cpu.c
index 2a60e6c41940..d54e2317efff 100644
--- a/tools/testing/selftests/cgroup/test_cpu.c
+++ b/tools/testing/selftests/cgroup/test_cpu.c
@@ -219,7 +219,7 @@ static int test_cpucg_stats(const char *root)
if (user_usec <= 0)
goto cleanup;
- if (!values_close(usage_usec, expected_usage_usec, 1))
+ if (!values_close_report(usage_usec, expected_usage_usec, 1))
goto cleanup;
ret = KSFT_PASS;
@@ -291,7 +291,7 @@ 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 (!values_close(nice_usec, expected_nice_usec, 1))
+ if (!values_close_report(nice_usec, expected_nice_usec, 1))
goto cleanup;
ret = KSFT_PASS;
@@ -404,7 +404,7 @@ overprovision_validate(const struct cpu_hogger *children, int num_children)
goto cleanup;
delta = children[i + 1].usage - children[i].usage;
- if (!values_close(delta, children[0].usage, 35))
+ if (!values_close_report(delta, children[0].usage, 35))
goto cleanup;
}
@@ -444,7 +444,7 @@ underprovision_validate(const struct cpu_hogger *children, int num_children)
int ret = KSFT_FAIL, i;
for (i = 0; i < num_children - 1; i++) {
- if (!values_close(children[i + 1].usage, children[0].usage, 15))
+ if (!values_close_report(children[i + 1].usage, children[0].usage, 15))
goto cleanup;
}
@@ -573,16 +573,16 @@ run_cpucg_nested_weight_test(const char *root, bool overprovisioned)
nested_leaf_usage = leaf[1].usage + leaf[2].usage;
if (overprovisioned) {
- if (!values_close(leaf[0].usage, nested_leaf_usage, 15))
+ if (!values_close_report(leaf[0].usage, nested_leaf_usage, 15))
goto cleanup;
- } else if (!values_close(leaf[0].usage * 2, nested_leaf_usage, 15))
+ } else if (!values_close_report(leaf[0].usage * 2, nested_leaf_usage, 15))
goto cleanup;
child_usage = cg_read_key_long(child, "cpu.stat", "usage_usec");
if (child_usage <= 0)
goto cleanup;
- if (!values_close(child_usage, nested_leaf_usage, 1))
+ if (!values_close_report(child_usage, nested_leaf_usage, 1))
goto cleanup;
ret = KSFT_PASS;
@@ -691,7 +691,7 @@ static int test_cpucg_max(const char *root)
expected_usage_usec
= n_periods * quota_usec + MIN(remainder_usec, quota_usec);
- if (!values_close(usage_usec, expected_usage_usec, 10))
+ if (!values_close_report(usage_usec, expected_usage_usec, 10))
goto cleanup;
ret = KSFT_PASS;
@@ -762,7 +762,7 @@ static int test_cpucg_max_nested(const char *root)
expected_usage_usec
= n_periods * quota_usec + MIN(remainder_usec, quota_usec);
- if (!values_close(usage_usec, expected_usage_usec, 10))
+ if (!values_close_report(usage_usec, expected_usage_usec, 10))
goto cleanup;
ret = KSFT_PASS;
--
2.51.0
next prev parent reply other threads:[~2025-10-15 8:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 14:31 [PATCH 0/2] selftests: cgroup: improve diagnostics for CPU test failures Sebastian Chlad
2025-10-14 14:31 ` [PATCH 1/2] selftests: cgroup: add values_close_assert helper Sebastian Chlad
2025-10-14 19:32 ` Tejun Heo
2025-10-14 14:31 ` [PATCH 2/2] selftests: cgroup: Use values_close_assert in test_cpu Sebastian Chlad
2025-10-15 8:00 ` [PATCH v2 0/2] selftests: cgroup: improve diagnostics for CPU test failures Sebastian Chlad
2025-10-15 8:00 ` [PATCH v2 1/2] selftests: cgroup: add values_close_assert helper Sebastian Chlad
2025-10-15 8:00 ` Sebastian Chlad [this message]
2025-10-15 10:33 ` [PATCH v3 0/2] selftests: cgroup: improve diagnostics for CPU test failures Sebastian Chlad
2025-10-15 10:33 ` [PATCH v3 1/2] selftests: cgroup: add values_close_report helper Sebastian Chlad
2025-10-15 10:33 ` [PATCH v3 2/2] selftests: cgroup: Use values_close_report in test_cpu Sebastian Chlad
2025-10-15 15:00 ` [PATCH v3 0/2] selftests: cgroup: improve diagnostics for CPU test failures Tejun Heo
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=20251015080022.14883-3-sebastian.chlad@suse.com \
--to=sebastianchlad@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=mkoutny@suse.com \
--cc=sebastian.chlad@suse.com \
--cc=tejun@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