Re: [PATCH RFC v2 4/4] iio: test: add kunit tests for channel info writes

From: Andy Shevchenko

Date: Tue Oct 13 2026 - 15:30:22 EST


On Tue, Oct 13, 2026 at 10:36:47AM -0300, Rodrigo Alencar via B4 Relay wrote:

> Add a KUnit test suite covering iio_write_channel_info(), the sysfs
> store handler that parses a channel info value according to the format
> reported by write_raw_get_fmt() and hands it to write_raw(). The
> function is made visible to KUnit through VISIBLE_IF_KUNIT and
> EXPORT_SYMBOL_IF_KUNIT, so it stays static in regular builds.
>
> The suite uses an unregistered iio_dev allocated on a KUnit device,
> with stub write_raw_get_fmt() and write_raw() callbacks that select
> the format under test and capture the parsed values. Cases are grouped
> by format:
>
> - IIO_VAL_INT: decimal, hex and octal input, decimal fallback with
> truncation and E notation, and 32-bit range checks.
> - IIO_VAL_INT_PLUS_MICRO / IIO_VAL_INT_PLUS_NANO: sign handling,
> truncation of extra digits, E notation and malformed input.
> - IIO_VAL_INT_PLUS_MICRO_DB: optional "dB" / " dB" suffix.
> - IIO_VAL_CHAR: single character input.
> - IIO_VAL_INT_64 and IIO_VAL_DECIMAL64_*: 64-bit values split into
> val/val2, including the S64_MAX / S64_MIN boundaries.
>
> Further cases cover unsupported formats, the default micro precision
> used when write_raw_get_fmt() is absent, a missing write_raw(), and
> error propagation from write_raw().

Please, add 'dBm' to the test cases.

--
With Best Regards,
Andy Shevchenko