test: Add tests for dev_{enable, disable}_by_path
authorMario Six <mario.six@gdsys.cc>
Tue, 26 Jun 2018 06:46:51 +0000 (08:46 +0200)
committerSimon Glass <sjg@chromium.org>
Sat, 29 Sep 2018 17:49:35 +0000 (11:49 -0600)
Add tests for the dev_{enable,disable}_by_path functions.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>
test/dm/test-fdt.c

index efe5342b0761762c1aeee74a5532b347a165639e..79b1f1de452dde1ac23f2e0a2779995eec884142 100644 (file)
@@ -557,3 +557,31 @@ static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_fdt_livetree_writing, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
+{
+       ofnode node;
+
+       if (!of_live_active()) {
+               printf("Live tree not active; ignore test\n");
+               return 0;
+       }
+
+       node = ofnode_path("/usb@2");
+
+       /* Test enabling devices */
+
+       ut_assert(!of_device_is_available(ofnode_to_np(node)));
+       dev_enable_by_path("/usb@2");
+       ut_assert(of_device_is_available(ofnode_to_np(node)));
+
+       /* Test disabling devices */
+
+       ut_assert(of_device_is_available(ofnode_to_np(node)));
+       dev_disable_by_path("/usb@2");
+       ut_assert(!of_device_is_available(ofnode_to_np(node)));
+
+       return 0;
+}
+DM_TEST(dm_test_fdt_disable_enable_by_path, DM_TESTF_SCAN_PDATA |
+                                           DM_TESTF_SCAN_FDT);