1 // SPDX-License-Identifier: GPL-2.0
3 * KUnit tests for OF APIs
5 #include <linux/module.h>
8 #include <kunit/test.h>
11 * Test that the root node "/" can be found by path.
13 static void of_dtb_root_node_found_by_path(struct kunit *test)
15 struct device_node *np;
17 np = of_find_node_by_path("/");
18 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, np);
23 * Test that the 'of_root' global variable is always populated when DT code is
24 * enabled. Remove this test once of_root is removed from global access.
26 static void of_dtb_root_node_populates_of_root(struct kunit *test)
28 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, of_root);
31 static struct kunit_case of_dtb_test_cases[] = {
32 KUNIT_CASE(of_dtb_root_node_found_by_path),
33 KUNIT_CASE(of_dtb_root_node_populates_of_root),
37 static int of_dtb_test_init(struct kunit *test)
39 if (!IS_ENABLED(CONFIG_OF_EARLY_FLATTREE))
40 kunit_skip(test, "requires CONFIG_OF_EARLY_FLATTREE");
46 * Test suite to confirm a DTB is loaded.
48 static struct kunit_suite of_dtb_suite = {
50 .test_cases = of_dtb_test_cases,
51 .init = of_dtb_test_init,
57 MODULE_LICENSE("GPL");