From: Matti Vaittinen <mazziesaccount@gmail.com>
To: David Gow <davidgow@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Brendan Higgins <brendan.higgins@linux.dev>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
kunit-dev@googlegroups.com, Stephen Boyd <sboyd@kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
linux-iio@vger.kernel.org, Maxime Ripard <maxime@cerno.tech>
Subject: Re: [PATCH v6 3/7] kunit: Add kunit wrappers for (root) device creation
Date: Tue, 28 Mar 2023 16:22:35 +0300 [thread overview]
Message-ID: <e9619a2a-b6c8-e7f9-6018-45541608d0c5@gmail.com> (raw)
In-Reply-To: <CABVgOSnUCsxPf1mAL03GQzaw_kFtgf5J7aTPodo=j6O+wYZ2iQ@mail.gmail.com>
Hi David & Greg and thanks for working with this!
On 3/28/23 15:45, David Gow wrote:
> Thanks, Gred and Matti.
>
> On Mon, 27 Mar 2023 at 20:38, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>>
>> On Mon, Mar 27, 2023 at 03:20:06PM +0300, Matti Vaittinen wrote:
>>> On 3/27/23 15:01, Greg Kroah-Hartman wrote:
>>>> On Mon, Mar 27, 2023 at 02:34:02PM +0300, Matti Vaittinen wrote:
>
> I'm happy to keep working on this, but would definitely appreciate
> your feedback.
>
> I've put my work-in-progress code here:
> https://kunit.googlesource.com/linux/+/refs/heads/kunit/device-helpers%5E%21/#F0
>
> It creates a "kunit" bus, and adds a few helpers to create both
> devices and drivers on that bus, and clean them up when the test
> exits. It seems to work on all of the tests which used
> root_device_register so far (except those -- only
> test_iio_find_closest_gain_low so far -- which create multiple devices
> with the same name, as the driver name won't be unique),
I wouldn't worry about it for as long as it's just because an iio-gts
test does something silly. Those tests are currently only in my personal
playground and changing those tests should be pretty trivial.
And right after saying that - the test_iio_find_closest_gain_low test does
a) register a 'test' device
b) perform test on devm_ API
c) unregister the 'test' device
d) register a 'test' device (same name as at step a)
e) perform test on devm_ API
f) unregister the 'test' device
My assumption is that the test device would be gone after step c)
because there should be no references to it anywhere. Hence, I wonder
why registering at step d) fails? (Or did I misunderstand something?)
> and the drm
> tests work fine when ported to it as well.
>
> There's still a lot of cleanup to do and questions which need
> answering, including:
> - Working out how best to provide an owning module (it's currently
> just kunit, but probably should be the module which contains the
> actual tests)
Maybe there is something I am not seeing but how about wrapping the
kunit_device_register() in a macro and getting the THIS_MODULE in
caller's context?
> In any case, does this seem like the right way forward?
I am by no means an expert on this but this does look good to me. I
would keep this as clean, lean and simple as possible in order to keep
understanding / debugging the problems exposed by the tests as simple as
possible. At some point someone is wondering why a test fails, and ends
up looking through these helpers to ensure problem is no lurking
there... Hence, I'd kept the code there in minimum - meaning, I might
not add kunit class or even a driver until tests require that. (Even if
it would not look as good in the sysfs - as far as I understand the
kunit sysfs entries are a 'test feature' which should not be present in
'production systems'. This is not an excuse to make things bad - but (in
my opinion) this is a good reason to prioritize simplicity.
Anyways, thanks for the work!
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-03-28 13:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 11:27 [PATCH v6 0/7] Support ROHM BU27034 ALS sensor Matti Vaittinen
2023-03-27 11:27 ` [PATCH v6 1/7] dt-bindings: iio: light: Support ROHM BU27034 Matti Vaittinen
2023-03-27 11:28 ` [PATCH v6 2/7] iio: light: Add gain-time-scale helpers Matti Vaittinen
2023-03-30 16:48 ` Matti Vaittinen
2023-03-31 7:39 ` Matti Vaittinen
2023-03-27 11:34 ` [PATCH v6 3/7] kunit: Add kunit wrappers for (root) device creation Matti Vaittinen
2023-03-27 12:01 ` Greg Kroah-Hartman
2023-03-27 12:20 ` Matti Vaittinen
2023-03-27 12:38 ` Greg Kroah-Hartman
2023-03-28 12:45 ` David Gow
2023-03-28 13:22 ` Matti Vaittinen [this message]
2023-03-28 13:38 ` David Gow
2023-03-30 16:53 ` Maxime Ripard
2023-03-27 11:34 ` [PATCH v6 4/7] iio: test: test gain-time-scale helpers Matti Vaittinen
2023-03-27 11:34 ` [PATCH v6 5/7] MAINTAINERS: Add IIO " Matti Vaittinen
2023-03-27 11:34 ` [PATCH v6 6/7] iio: light: ROHM BU27034 Ambient Light Sensor Matti Vaittinen
2023-03-28 5:59 ` kernel test robot
2023-03-30 16:59 ` Matti Vaittinen
2023-03-27 11:35 ` [PATCH v6 7/7] MAINTAINERS: Add ROHM BU27034 Matti Vaittinen
2023-03-27 11:39 ` [PATCH v6 0/7] Support ROHM BU27034 ALS sensor Matti Vaittinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9619a2a-b6c8-e7f9-6018-45541608d0c5@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=brendan.higgins@linux.dev \
--cc=davidgow@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=maxime@cerno.tech \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox