Linux cgroups development
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Sebastian Chlad <sebastianchlad@gmail.com>
Cc: cgroups@vger.kernel.org, mkoutny@suse.com,
	Sebastian Chlad <sebastian.chlad@suse.com>
Subject: Re: [PATCH 1/2] selftests: cgroup: add values_close_assert helper
Date: Tue, 14 Oct 2025 09:32:26 -1000	[thread overview]
Message-ID: <aO6lSuegFp4G7lRE@slm.duckdns.org> (raw)
In-Reply-To: <20251014143151.5790-2-sebastian.chlad@suse.com>

Hello,

On Tue, Oct 14, 2025 at 04:31:50PM +0200, Sebastian Chlad wrote:
> +/*
> + * Checks if two given values differ by less than err% of their sum and assert
> + * with detailed debug info if not.
> + */
> +static inline int values_close_assert(long a, long b, int err)

I wonder whether assert is a bit misleading given that asserts are generally
expected to terminate the program on failure. Maybe sth like
values_close_verbose() or values_close_report()?

> +{
> +	long diff  = labs(a - b);
> +	long limit = (a + b) / 100 * err;
> +	double actual_err = (a + b) ? (100.0 * diff / (a + b)) : 0.0;
> +	int close = diff <= limit;
> +
> +	if (!close) {
> +		fprintf(stderr,
> +			"[FAIL] actual=%ld expected=%ld | diff=%ld | limit=%ld | "
> +			"tolerance=%d%% | actual_error=%.2f%%\n",
> +			a, b, diff, limit, err, actual_err);
> +	}

{} are unnecessary here. Can you please drop them?

Thanks.

-- 
tejun

  reply	other threads:[~2025-10-14 19:32 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 [this message]
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   ` [PATCH v2 2/2] selftests: cgroup: Use values_close_assert in test_cpu Sebastian Chlad
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=aO6lSuegFp4G7lRE@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=sebastian.chlad@suse.com \
    --cc=sebastianchlad@gmail.com \
    /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