linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] KUnit device API proposal
@ 2023-03-25  4:31 David Gow
  2023-03-25  4:31 ` [RFC PATCH 1/2] kunit: resource: Add kunit_defer() functionality David Gow
  2023-03-25  4:31 ` [RFC PATCH 2/2] kunit: Add APIs for managing devices David Gow
  0 siblings, 2 replies; 8+ messages in thread
From: David Gow @ 2023-03-25  4:31 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Matti Vaittinen, Maxime Ripard,
	Brendan Higgins, Stephen Boyd, Shuah Khan
  Cc: David Gow, Rafael J . Wysocki, Andy Shevchenko, Heikki Krogerus,
	Jonathan Cameron, linux-kernel, linux-kselftest, kunit-dev

Hi all,

This is a follow-up to the conversation[1] about adding helpers to create a
struct device for use in KUnit tests. At the moment, most tests are
using root_device_register(), which doesn't quite fit, and a few are
using platform_devices instead.

This adds a KUnit-specific equivalent: kunit_device_register(), which
creates a device which will be automatically cleaned up on test exit
(such as, for example, if an assertion fails).
It's also possible to unregister it earlier with
kunit_device_unregister().

This can replace the root_device_register() users pretty comfortably,
though doesn't resolve the issue with devm_ resources not being released
properly as laid out in [2]. Updating the implementation here to use a
'kunit' bus should, I think, be reasonably straightforward.

The first patch in the series is an in-progress implementation of a
separate new 'kunit_defer()' API, upon which this device implementation
is built.

If the overall idea seems good, I'll make sure to add better
tests/documentation, and patches converting existing tests to this API.

Cheers,
-- David

[1]: https://lore.kernel.org/linux-kselftest/bad670ee135391eb902bd34b8bcbe777afabc7fd.1679474247.git.mazziesaccount@gmail.com/
[2]: https://lore.kernel.org/linux-kselftest/20230324123157.bbwvfq4gsxnlnfwb@houat/

---
David Gow (2):
  kunit: resource: Add kunit_defer() functionality
  kunit: Add APIs for managing devices

 include/kunit/device.h   |  25 +++++++++
 include/kunit/resource.h |  87 +++++++++++++++++++++++++++++++
 lib/kunit/Makefile       |   1 +
 lib/kunit/device.c       |  68 ++++++++++++++++++++++++
 lib/kunit/resource.c     | 110 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 291 insertions(+)
 create mode 100644 include/kunit/device.h
 create mode 100644 lib/kunit/device.c

-- 
2.40.0.348.gf938b09366-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-03-30  7:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-25  4:31 [RFC PATCH 0/2] KUnit device API proposal David Gow
2023-03-25  4:31 ` [RFC PATCH 1/2] kunit: resource: Add kunit_defer() functionality David Gow
2023-03-26  6:33   ` Matti Vaittinen
2023-03-27 13:56   ` Maxime Ripard
2023-03-30  7:38   ` Benjamin Berg
2023-03-25  4:31 ` [RFC PATCH 2/2] kunit: Add APIs for managing devices David Gow
2023-03-25  6:28   ` Greg Kroah-Hartman
2023-03-27 13:57   ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).