1 // SPDX-License-Identifier: GPL-2.0+
3 * Test for the NOP uclass
5 * (C) Copyright 2019 - Texas Instruments Incorporated - http://www.ti.com/
6 * Jean-Jacques Hiblot <jjhiblot@ti.com>
11 #include <dm/ofnode.h>
13 #include <dm/device.h>
16 #include <test/test.h>
19 static int noptest_bind(struct udevice *parent)
21 ofnode ofnode = dev_read_first_subnode(parent);
23 while (ofnode_valid(ofnode)) {
25 const char *bind_flag = ofnode_read_string(ofnode, "bind");
27 if (bind_flag && (strcmp(bind_flag, "True") == 0))
28 lists_bind_fdt(parent, ofnode, &dev, false);
29 ofnode = dev_read_next_subnode(ofnode);
35 static const struct udevice_id noptest1_ids[] = {
37 .compatible = "sandbox,nop_sandbox1",
42 U_BOOT_DRIVER(noptest_drv1) = {
43 .name = "noptest1_drv",
44 .of_match = noptest1_ids,
49 static const struct udevice_id noptest2_ids[] = {
51 .compatible = "sandbox,nop_sandbox2",
56 U_BOOT_DRIVER(noptest_drv2) = {
57 .name = "noptest2_drv",
58 .of_match = noptest2_ids,
62 static int dm_test_nop(struct unit_test_state *uts)
66 ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_0", &dev));
67 ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_1", &dev));
69 uclass_get_device_by_name(UCLASS_NOP, "nop-test_2", &dev));
74 DM_TEST(dm_test_nop, UT_TESTF_FLAT_TREE | UT_TESTF_SCAN_FDT);