// SPDX-License-Identifier: GPL-2.0+
/*
 * Test for the NOP uclass
 *
 * (C) Copyright 2019 - Texas Instruments Incorporated - https://www.ti.com/
 * Jean-Jacques Hiblot <jjhiblot@ti.com>
 */

#include <common.h>
#include <dm.h>
#include <dm/ofnode.h>
#include <dm/lists.h>
#include <dm/device.h>
#include <dm/test.h>
#include <misc.h>
#include <test/test.h>
#include <test/ut.h>

static int noptest_bind(struct udevice *parent)
{
	ofnode ofnode = dev_read_first_subnode(parent);

	while (ofnode_valid(ofnode)) {
		struct udevice *dev;
		const char *bind_flag = ofnode_read_string(ofnode, "bind");

		if (bind_flag && (strcmp(bind_flag, "True") == 0))
			lists_bind_fdt(parent, ofnode, &dev, NULL, false);
		ofnode = dev_read_next_subnode(ofnode);
	}

	return 0;
}

static const struct udevice_id noptest1_ids[] = {
	{
		.compatible = "sandbox,nop_sandbox1",
	},
	{ }
};

U_BOOT_DRIVER(noptest_drv1) = {
	.name	= "noptest1_drv",
	.of_match	= noptest1_ids,
	.id	= UCLASS_NOP,
	.bind = noptest_bind,
};

static const struct udevice_id noptest2_ids[] = {
	{
		.compatible = "sandbox,nop_sandbox2",
	},
	{ }
};

U_BOOT_DRIVER(noptest_drv2) = {
	.name	= "noptest2_drv",
	.of_match	= noptest2_ids,
	.id	= UCLASS_NOP,
};

static int dm_test_nop(struct unit_test_state *uts)
{
	struct udevice *dev;

	ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_0", &dev));
	ut_assertok(uclass_get_device_by_name(UCLASS_NOP, "nop-test_1", &dev));
	ut_asserteq(-ENODEV,
		    uclass_get_device_by_name(UCLASS_NOP, "nop-test_2", &dev));

	return 0;
}

DM_TEST(dm_test_nop, UT_TESTF_FLAT_TREE | UT_TESTF_SCAN_FDT);
