Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: "Li Wang (Hieco)" <li.wang@linux.dev>
Cc: Xiaochen Shen <shenxiaochen@open-hieco.net>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] sys_hwmon01: always report a result
Date: Tue, 20 Oct 2026 11:50:09 +0200	[thread overview]
Message-ID: <atc5USFImqRKPt82@yuki.lan> (raw)
In-Reply-To: <20261020080033.123660-1-li.wang@linux.dev>

Hi!
>  #include "tst_test.h"
>  #include "tst_sysfs_assert.h"
> @@ -56,39 +58,67 @@
>  
>  #define MAX_CHANNELS 32
>  
> +static unsigned int checked;
> +
> +static int sysfs_attr_exists(const char *fmt, ...)
> +{
> +	char path[PATH_MAX];
> +	va_list va;
> +
> +	va_start(va, fmt);
> +	vsnprintf(path, sizeof(path), fmt, va);
> +	va_end(va);
> +
> +	return tst_sysfs_exists(path);
> +}

Uff, the tst_sysfs_attr_exists() does work with printf-like parameters.

What do we need the this wrapper for?

> +#define CHECK_RANGELL(lo, hi, ...) do { \
> +	if (sysfs_attr_exists(__VA_ARGS__)) { \
> +		checked++; \
> +		TST_SYSFS_ASSERT_RANGELL_SILENT(lo, hi, __VA_ARGS__); \
> +	} \
> +} while (0)
> +
> +#define CHECK_BOOL(...) do { \
> +	if (sysfs_attr_exists(__VA_ARGS__)) { \
> +		checked++; \
> +		TST_SYSFS_ASSERT_BOOL_SILENT(__VA_ARGS__); \
> +	} \
> +} while (0)

What about we add the counter into the sysfs library instead?

If we add:

void tst_sysfs_cnt_reset(void);

unsigned int tst_sysfs_cnt_get(void);

We can call the tst_sysfs_cnt_rest() at the start of the test function,
and get the counter at the end.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-10-20  9:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  8:00 [LTP] [PATCH v2] sys_hwmon01: always report a result Li Wang (Hieco)
2026-10-20  9:50 ` Cyril Hrubis [this message]
2026-10-20 10:12   ` Li Wang

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=atc5USFImqRKPt82@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=li.wang@linux.dev \
    --cc=ltp@lists.linux.it \
    --cc=shenxiaochen@open-hieco.net \
    /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