[LTP] [PATCH v4 01/31] lib: Add tst_sysfs_assert

Petr Vorel pvorel@suse.cz
Thu Sep 3 16:57:40 CEST 2026


Hi Cyril,

...
> +++ b/include/tst_sysfs_assert.h
...
> +/**
> + * TST_SYSFS_ASSERT_RANGELF() - Asserts that min <= val <= max.
> + *
> + * The min bound is a long long, while the max bound is read from a file,
> + * hence the LF (long long, file) suffix. The value and max paths are built
> + * by appending val_suffix/max_suffix to a common prefix built from fmt.
> + *
> + * Skips with TCONF if either file does not exist.
doc related nit: If you use
:c:enum:`TCONF <tst_res_flags>`

TCONF will be clickable in the docs, link to:
https://linux-test-project.readthedocs.io/en/latest/developers/api_c_tests.html#c.tst_res_flags

I admit it's really ugly construct (I haven't found better), but newcomers can
find quickly TCONF related doc.

If you agree, just change it before merge.

> + *
> + * @min: A minimal value.
> + * @val_suffix: A filename the val is read from.
> + * @max_suffix: A filename the max is read from.
> + * @fmt: A printf-like format to build the path to val and max from.
> + * @...: A printf-like parameters for fmt.
> + */
> +#define TST_SYSFS_ASSERT_RANGELF(min, val_suffix, max_suffix, fmt, ...) \
> +	tst_sysfs_assert_rangelf(__FILE__, __LINE__, min, val_suffix, \
> +		max_suffix, fmt, ##__VA_ARGS__)
> +
> +void tst_sysfs_assert_rangelf(const char *file, const int lineno,
> +	long long min, const char *val_suffix, const char *max_suffix,
> +	const char *fmt, ...);
> +
> +/**
> + * TST_SYSFS_ASSERT_BOOL() - Asserts that file has boolean value.
> + *
> + * Reads a value from the file at the path built from fmt and asserts
> + * that it is a boolean (0 or 1).
> + *
> + * Skips with TCONF if the file does not exist.
And here as well.

Kind regards,
Petr


More information about the ltp mailing list