summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-07-30 15:52:09 -0600
committerTom Rini <trini@konsulko.com>2022-08-12 08:14:24 -0400
commit6571559449cef5fe11678c25bc4fdf57b6a4e81f (patch)
tree1df81959bc279fd1ce393f3babff302660f3f185 /test
parent331048471dee5c1d9cede54382256e6cfaee2370 (diff)
downloadu-boot-6571559449cef5fe11678c25bc4fdf57b6a4e81f.tar.gz
u-boot-6571559449cef5fe11678c25bc4fdf57b6a4e81f.tar.bz2
u-boot-6571559449cef5fe11678c25bc4fdf57b6a4e81f.zip
dm: core: Move ofnode-writing test to ofnode
This fits better in the ofnode tests, so move it. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/ofnode.c56
-rw-r--r--test/dm/test-fdt.c53
2 files changed, 56 insertions, 53 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 6a252f3f50..b8d8e440db 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -4,8 +4,12 @@
#include <dm.h>
#include <log.h>
#include <of_live.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
#include <dm/of_extra.h>
+#include <dm/root.h>
#include <dm/test.h>
+#include <dm/uclass-internal.h>
#include <test/test.h>
#include <test/ut.h>
@@ -536,3 +540,55 @@ static int dm_test_ofnode_root(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_root, UT_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ ofnode node;
+
+ if (!of_live_active()) {
+ printf("Live tree not active; ignore test\n");
+ return 0;
+ }
+
+ /* Test enabling devices */
+
+ node = ofnode_path("/usb@2");
+
+ ut_assert(!of_device_is_available(ofnode_to_np(node)));
+ ofnode_set_enabled(node, true);
+ ut_assert(of_device_is_available(ofnode_to_np(node)));
+
+ device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node,
+ &dev);
+ ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev));
+
+ /* Test string property setting */
+
+ ut_assert(device_is_compatible(dev, "sandbox,usb"));
+ ofnode_write_string(node, "compatible", "gdsys,super-usb");
+ ut_assert(device_is_compatible(dev, "gdsys,super-usb"));
+ ofnode_write_string(node, "compatible", "sandbox,usb");
+ ut_assert(device_is_compatible(dev, "sandbox,usb"));
+
+ /* Test setting generic properties */
+
+ /* Non-existent in DTB */
+ ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev));
+ /* reg = 0x42, size = 0x100 */
+ ut_assertok(ofnode_write_prop(node, "reg", 8,
+ "\x00\x00\x00\x42\x00\x00\x01\x00"));
+ ut_asserteq(0x42, dev_read_addr(dev));
+
+ /* Test disabling devices */
+
+ device_remove(dev, DM_REMOVE_NORMAL);
+ device_unbind(dev);
+
+ ut_assert(of_device_is_available(ofnode_to_np(node)));
+ ofnode_set_enabled(node, false);
+ ut_assert(!of_device_is_available(ofnode_to_np(node)));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index f9e8174759..6118ad42ca 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -17,7 +17,6 @@
#include <dm/devres.h>
#include <dm/uclass-internal.h>
#include <dm/util.h>
-#include <dm/lists.h>
#include <dm/of_access.h>
#include <linux/ioport.h>
#include <test/test.h>
@@ -735,58 +734,6 @@ static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts)
DM_TEST(dm_test_fdt_remap_addr_name_live,
UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
-{
- struct udevice *dev;
- ofnode node;
-
- if (!of_live_active()) {
- printf("Live tree not active; ignore test\n");
- return 0;
- }
-
- /* Test enabling devices */
-
- node = ofnode_path("/usb@2");
-
- ut_assert(!of_device_is_available(ofnode_to_np(node)));
- ofnode_set_enabled(node, true);
- ut_assert(of_device_is_available(ofnode_to_np(node)));
-
- device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node,
- &dev);
- ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev));
-
- /* Test string property setting */
-
- ut_assert(device_is_compatible(dev, "sandbox,usb"));
- ofnode_write_string(node, "compatible", "gdsys,super-usb");
- ut_assert(device_is_compatible(dev, "gdsys,super-usb"));
- ofnode_write_string(node, "compatible", "sandbox,usb");
- ut_assert(device_is_compatible(dev, "sandbox,usb"));
-
- /* Test setting generic properties */
-
- /* Non-existent in DTB */
- ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev));
- /* reg = 0x42, size = 0x100 */
- ut_assertok(ofnode_write_prop(node, "reg", 8,
- "\x00\x00\x00\x42\x00\x00\x01\x00"));
- ut_asserteq(0x42, dev_read_addr(dev));
-
- /* Test disabling devices */
-
- device_remove(dev, DM_REMOVE_NORMAL);
- device_unbind(dev);
-
- ut_assert(of_device_is_available(ofnode_to_np(node)));
- ofnode_set_enabled(node, false);
- ut_assert(!of_device_is_available(ofnode_to_np(node)));
-
- return 0;
-}
-DM_TEST(dm_test_fdt_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-
static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
{
ofnode node;