[LTP] [PATCH v2] sys_hwmon01: always report a result

Cyril Hrubis chrubis@suse.cz
Tue Oct 20 11:50:09 CEST 2026


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


More information about the ltp mailing list