/* * Test that kunit_platform_device_alloc() creates a platform device.
*/ staticvoid kunit_platform_device_alloc_test(struct kunit *test)
{
KUNIT_EXPECT_NOT_ERR_OR_NULL(test,
kunit_platform_device_alloc(test, "kunit-platform", 1));
}
/* * Test that kunit_platform_device_add() registers a platform device on the * platform bus with the proper name and id.
*/ staticvoid kunit_platform_device_add_test(struct kunit *test)
{ struct platform_device *pdev; constchar *name = "kunit-platform-add"; constint id = -1;
/* * Test that kunit_platform_device_add() called twice with the same device name * and id fails the second time and properly cleans up.
*/ staticvoid kunit_platform_device_add_twice_fails_test(struct kunit *test)
{ struct platform_device *pdev; constchar *name = "kunit-platform-add-2"; constint id = -1;
/* * Test that kunit_platform_device_add() cleans up by removing the platform
* device when the test finishes. */ staticvoid kunit_platform_device_add_cleans_up(struct kunit *test)
{ struct platform_device *pdev; constchar *name = "kunit-platform-clean"; constint id = -1; struct kunit fake; struct device *dev;
/* * Failing to migrate the kunit_resource would lead to an extra * put_device() call on the platform device. The best we can do here is * make sure the device no longer exists on the bus, but if something * is wrong we'll see a refcount underflow here. We can't test for a * refcount underflow because the kref matches the lifetime of the * device which should already be freed and could be used by something * else.
*/
dev = bus_find_device(&platform_bus_type, NULL, name,
kunit_platform_device_find_by_name);
KUNIT_EXPECT_PTR_EQ(test, NULL, dev);
put_device(dev);
}
/* * Test suite for struct platform_device kunit APIs
*/ staticstruct kunit_case kunit_platform_device_test_cases[] = {
KUNIT_CASE(kunit_platform_device_alloc_test),
KUNIT_CASE(kunit_platform_device_add_test),
KUNIT_CASE(kunit_platform_device_add_twice_fails_test),
KUNIT_CASE(kunit_platform_device_add_cleans_up),
{}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.