On Wed, 15 Jul 2026 09:32:15 +0300
Andy Shevchenko <[email protected]> wrote:

> On Tue, Jul 14, 2026 at 06:08:12PM -0700, Jonathan Cameron wrote:
> > On Mon, 13 Jul 2026 10:52:56 +0100
> > Rodrigo Alencar <[email protected]> wrote:  
> > > 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:  
> 
> ...
> 
> > > > > Because __iio_chan_prefix_emit() is static, the test translation unit
> > > > > is pulled into industrialio-core.c.    
> 
> KUnit also has static/non-static automation via a macro (defined in the
> kunit/visibility.h) and I see that's used in the below example.
> 
> > > > 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..  
> 
> Maybe, but thanks to this thread, I fixed other modules that use their own
> approach to use the standard KUnit infra for this (as below).
> 
> > >   /* 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  
> > 
> > I'd rather this wasn't built into the core module.  So prefer you jump
> > though those hoops.  
> 
> Hmm... The above (while being verbose) is the standard way of how we export
> symbols for KUnit tests. Do you have a better alternative that everyone can
> use? (Not only IIO subsystem.)

Ah. I put that comment in an unhelpful place. I meant the include above not 
this bit.
Absolutely fine with the exports being there.

Jonathan

> 


Reply via email to