Re: [PATCH v7 07/17] iio: test: add kunit tests for channel prefix naming generation
Rodrigo Alencar <[email protected]>
| Newsgroups | org.kernel.vger.linux-hardening,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-doc,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <egyms7ulkxsgu4pvfkoruelec3sf6ca4bndcuqkvxljrdluqwu@edlqne7oy3xs> |
On 12/07/26 02:09, Jonathan Cameron wrote: > On Tue, 07 Jul 2026 15:04:28 +0100 > Rodrigo Alencar via B4 Relay <[email protected]> wrote: > > > From: Rodrigo Alencar <[email protected]> > > > > Add a KUnit test suite covering __iio_chan_prefix_emit(), the helper > > that builds IIO sysfs attribute name prefixes from an iio_chan_spec. > > The suite groups cases by the enum iio_shared_by mode it exercises: > > > > - IIO_SHARED_BY_ALL: produces an empty prefix. > > - IIO_SHARED_BY_DIR: emits direction only ("in" / "out"). > > - IIO_SHARED_BY_TYPE: emits "<dir>_<type>" and the differential > > "<dir>_<type>-<type>" variant. > > - IIO_SEPARATE: covers the full matrix of indexed, differential, > > modified, output and extend_name combinations, plus the two > > documented error paths (differential without indexed, differential > > with modifier). > > > > A final case exercises the seq_buf overflow path by passing an > > undersized buffer and expects -EOVERFLOW. > > > > Because __iio_chan_prefix_emit() is static, the test translation unit > > is pulled into industrialio-core.c. > > Isn't there some magic route cases like this that makes it non static > only when self tests are enabled? > Claude tells me to look at include/kunit/visibility.h There is, Although I think that using #if IS_ENABLED(CONFIG_IIO_CHANNEL_PREFIX_KUNIT_TEST) #include "test/iio-test-channel-prefix.c" #endif was more straight forward, less invasive and easier to change than.. /* In "drivers/iio/industrialio-core.c" */ #include <kunit/visibility.h> ... VISIBLE_IF_KUNIT ssize_t __iio_chan_prefix_emit(...) { ... } EXPORT_SYMBOL_IF_KUNIT(__iio_chan_prefix_emit); /* In "iio_core.h" */ #if IS_ENABLED(CONFIG_KUNIT) ssize_t __iio_chan_prefix_emit(...); #endif /* In "drivers/iio/test/iio-test-channel-prefix.c" */ #include <kunit/visibility.h> #include <iio_core.h> ... MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); ... // Use __iio_chan_prefix_emit() in tests > > Very nice. A couple of really small additions requested inline. > I might well have missed where you exercised the corners requested though! > + I'll need an Ack from Lars for that maintainers entry. I'll guess that > Lars won't give one as not very active at the moment in this area. > > Jonathan > > > > > Also, an entry is created under MAINTAINERS dedicated to tests for IIO > > core helpers. > > > > Signed-off-by: Rodrigo Alencar <[email protected]> > > --- > > MAINTAINERS | 8 + > > drivers/iio/industrialio-core.c | 4 + > > drivers/iio/test/Kconfig | 14 ++ > > drivers/iio/test/iio-test-channel-prefix.c | 246 +++++++++++++++++++++++++++++ > > 4 files changed, 272 insertions(+) > > > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 2b1ec46c5919..57ffc0dcfdb6 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -12634,6 +12634,14 @@ F: include/dt-bindings/iio/ > > F: include/linux/iio/ > > F: tools/iio/ > > > > +IIO CORE KUNIT TESTS > > +M: Lars-Peter Clausen <[email protected]> > > I'd need an Ack from Lars for this entry. If we don't get one are you > fine looking after this without Lars listed? That is fine, will drop his name. -- Kind regards, Rodrigo Alencar