Robin Murphy
unread,9:46 AM (11 hours ago) 9:46 AMSign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to brendan...@linux.dev, davi...@google.com, cor...@lwn.net, rm...@google.com, linux-k...@vger.kernel.org, kuni...@googlegroups.com, linu...@vger.kernel.org, work...@vger.kernel.org
kunit_device_register() only returns error pointers, not NULL.
Furthermore for regular users who aren't testing the KUnit API
itself, errors most likely represent major system failure (e.g. OOM
or sysfs collision) beyond the scope of their own test conditions.
Replace the assert with straightforward error handling for clarity.
Signed-off-by: Robin Murphy <
robin....@arm.com>
---
This seemed the logical conclusion by inspection, but please do correct
me if I've misunderstood the intent...
---
Documentation/dev-tools/kunit/usage.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
index 038f480074fd..3452c739dd44 100644
--- a/Documentation/dev-tools/kunit/usage.rst
+++ b/Documentation/dev-tools/kunit/usage.rst
@@ -873,7 +873,8 @@ For example:
// Create a fake device.
fake_device = kunit_device_register(test, "my_device");
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fake_device)
+ if (IS_ERR(fake_device))
+ return;
// Pass it to functions which need a device.
dev_managed_string = devm_kstrdup(fake_device, "Hello, World!");
--
2.34.1