예제 #1
0
/* Test regulator set and get Enable method */
static int dm_test_power_regulator_set_get_enable(struct unit_test_state *uts)
{
	const char *platname;
	struct udevice *dev;
	bool val_set = true;

	/* Set the Enable of LDO1 - default is disabled */
	platname = regulator_names[LDO1][PLATNAME];
	ut_assertok(regulator_get_by_platname(platname, &dev));
	ut_assertok(regulator_set_enable(dev, val_set));

	/* Get the Enable state of LDO1 and compare it with the requested one */
	ut_asserteq(regulator_get_enable(dev), val_set);

	return 0;
}
예제 #2
0
/* Test that binding with platdata occurs correctly */
static int dm_test_autobind(struct dm_test_state *dms)
{
	struct udevice *dev;

	/*
	 * We should have a single class (UCLASS_ROOT) and a single root
	 * device with no children.
	 */
	ut_assert(dms->root);
	ut_asserteq(1, list_count_items(&gd->uclass_root));
	ut_asserteq(0, list_count_items(&gd->dm_root->child_head));
	ut_asserteq(0, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);

	ut_assertok(dm_scan_platdata());

	/* We should have our test class now at least, plus more children */
	ut_assert(1 < list_count_items(&gd->uclass_root));
	ut_assert(0 < list_count_items(&gd->dm_root->child_head));

	/* Our 3 dm_test_infox children should be bound to the test uclass */
	ut_asserteq(3, dm_testdrv_op_count[DM_TEST_OP_POST_BIND]);

	/* No devices should be probed */
	list_for_each_entry(dev, &gd->dm_root->child_head, sibling_node)
		ut_assert(!(dev->flags & DM_FLAG_ACTIVATED));

	/* Our test driver should have been bound 3 times */
	ut_assert(dm_testdrv_op_count[DM_TEST_OP_BIND] == 3);

	return 0;
}
예제 #3
0
/* Check that we can perform operations on devices */
static int dm_test_operations(struct dm_test_state *dms)
{
	struct udevice *dev;
	int i;

	/*
	 * Now check that the ping adds are what we expect. This is using the
	 * ping-add property in each node.
	 */
	for (i = 0; i < ARRAY_SIZE(test_pdata); i++) {
		uint32_t base;

		ut_assertok(uclass_get_device(UCLASS_TEST, i, &dev));

		/*
		 * Get the 'reg' property, which tells us what the ping add
		 * should be. We don't use the platdata because we want
		 * to test the code that sets that up (testfdt_drv_probe()).
		 */
		base = test_pdata[i].ping_add;
		debug("dev=%d, base=%d\n", i, base);

		ut_assert(!dm_check_operations(dms, dev, base, dev->priv));
	}

	return 0;
}
예제 #4
0
/* Test that sequence numbers are allocated properly */
static int dm_test_fdt_uclass_seq(struct unit_test_state *uts)
{
	struct udevice *dev;

	/* A few basic santiy tests */
	ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 3, true, &dev));
	ut_asserteq_str("b-test", dev->name);

	ut_assertok(uclass_find_device_by_seq(UCLASS_TEST_FDT, 8, true, &dev));
	ut_asserteq_str("a-test", dev->name);

	ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 5,
						       true, &dev));
	ut_asserteq_ptr(NULL, dev);

	/* Test aliases */
	ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 6, &dev));
	ut_asserteq_str("e-test", dev->name);

	ut_asserteq(-ENODEV, uclass_find_device_by_seq(UCLASS_TEST_FDT, 7,
						       true, &dev));

	/*
	 * Note that c-test nodes are not probed since it is not a top-level
	 * node
	 */
	ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 3, &dev));
	ut_asserteq_str("b-test", dev->name);

	/*
	 * d-test wants sequence number 3 also, but it can't have it because
	 * b-test gets it first.
	 */
	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 2, &dev));
	ut_asserteq_str("d-test", dev->name);

	/* d-test actually gets 0 */
	ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 0, &dev));
	ut_asserteq_str("d-test", dev->name);

	/* initially no one wants seq 1 */
	ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_TEST_FDT, 1,
						      &dev));
	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
	ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 4, &dev));

	/* But now that it is probed, we can find it */
	ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 1, &dev));
	ut_asserteq_str("f-test", dev->name);

	return 0;
}
예제 #5
0
/*
 * Basic test of the mmc uclass. We could expand this by implementing an MMC
 * stack for sandbox, or at least implementing the basic operation.
 */
static int dm_test_mmc_base(struct unit_test_state *uts)
{
	struct udevice *dev;

	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));

	return 0;
}
예제 #6
0
static int dm_test_mmc_blk(struct unit_test_state *uts)
{
	struct udevice *dev;
	struct blk_desc *dev_desc;
	char cmp[1024];

	ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
	ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));

	/* Read a few blocks and look for the string we expect */
	ut_asserteq(512, dev_desc->blksz);
	memset(cmp, '\0', sizeof(cmp));
	ut_asserteq(2, blk_dread(dev_desc, 0, 2, cmp));
	ut_assertok(strcmp(cmp, "this is a test"));

	return 0;
}
예제 #7
0
파일: sysreset.c 프로젝트: Noltari/u-boot
static int dm_test_sysreset_get_status(struct unit_test_state *uts)
{
	struct udevice *dev;
	char msg[64];

	/* Device 1 is the warm sysreset device */
	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
	ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
	ut_asserteq_str("Reset Status: WARM", msg);

	/* Device 2 is the cold sysreset device */
	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
	ut_assertok(sysreset_get_status(dev, msg, sizeof(msg)));
	ut_asserteq_str("Reset Status: COLD", msg);

	return 0;
}
예제 #8
0
파일: sysreset.c 프로젝트: Noltari/u-boot
static int dm_test_sysreset_get_last(struct unit_test_state *uts)
{
	struct udevice *dev;

	/* Device 1 is the warm sysreset device */
	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev));
	ut_asserteq(SYSRESET_WARM, sysreset_get_last(dev));

	/* Device 2 is the cold sysreset device */
	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
	ut_asserteq(SYSRESET_POWER, sysreset_get_last(dev));

	/* This is device 0, the non-DT one */
	ut_asserteq(SYSRESET_POWER, sysreset_get_last_walk());

	return 0;
}
예제 #9
0
/* Test that sandbox PCI bus numbering works correctly */
static int dm_test_pci_busnum(struct unit_test_state *uts)
{
	struct udevice *bus;

	ut_assertok(uclass_get_device_by_seq(UCLASS_PCI, 0, &bus));

	return 0;
}
예제 #10
0
int dm_test_main(const char *test_name)
{
	struct dm_test *tests = ll_entry_start(struct dm_test, dm_test);
	const int n_ents = ll_entry_count(struct dm_test, dm_test);
	struct dm_test_state *dms = &global_test_state;
	struct dm_test *test;

	/*
	 * If we have no device tree, or it only has a root node, then these
	 * tests clearly aren't going to work...
	 */
	if (!gd->fdt_blob || fdt_next_node(gd->fdt_blob, 0, NULL) < 0) {
		puts("Please run with test device tree:\n"
		     "     dtc -I dts -O dtb test/dm/test.dts  -o test/dm/test.dtb\n"
		     "    ./u-boot -d test/dm/test.dtb\n");
		ut_assert(gd->fdt_blob);
	}

	if (!test_name)
		printf("Running %d driver model tests\n", n_ents);

	for (test = tests; test < tests + n_ents; test++) {
		if (test_name && strcmp(test_name, test->name))
			continue;
		printf("Test: %s\n", test->name);
		ut_assertok(dm_test_init(dms));

		dms->start = mallinfo();
		if (test->flags & DM_TESTF_SCAN_PDATA)
			ut_assertok(dm_scan_platdata(false));
		if (test->flags & DM_TESTF_PROBE_TEST)
			ut_assertok(do_autoprobe(dms));
		if (test->flags & DM_TESTF_SCAN_FDT)
			ut_assertok(dm_scan_fdt(gd->fdt_blob, false));

		if (test->func(dms))
			break;

		ut_assertok(dm_test_destroy(dms));
	}

	printf("Failures: %d\n", dms->fail_count);

	return 0;
}
예제 #11
0
파일: eth.c 프로젝트: Noltari/u-boot
/**
 * This test case is trying to test the following scenario:
 *	- All ethernet devices are not probed
 *	- "ethaddr" for all ethernet devices are not set
 *	- "ethact" is set to a valid ethernet device name
 *
 * With Sandbox default test configuration, all ethernet devices are
 * probed after power-up, so we have to manually create such scenario:
 *	- Remove all ethernet devices
 *	- Remove all "ethaddr" environment variables
 *	- Set "ethact" to the first ethernet device
 *
 * Do a ping test to see if anything goes wrong.
 */
static int dm_test_eth_act(struct unit_test_state *uts)
{
	struct udevice *dev[DM_TEST_ETH_NUM];
	const char *ethname[DM_TEST_ETH_NUM] = {"eth@10002000", "eth@10003000",
						"sbe5", "eth@10004000"};
	const char *addrname[DM_TEST_ETH_NUM] = {"ethaddr", "eth5addr",
						 "eth3addr", "eth1addr"};
	char ethaddr[DM_TEST_ETH_NUM][18];
	int i;

	memset(ethaddr, '\0', sizeof(ethaddr));
	net_ping_ip = string_to_ip("1.1.2.2");

	/* Prepare the test scenario */
	for (i = 0; i < DM_TEST_ETH_NUM; i++) {
		ut_assertok(uclass_find_device_by_name(UCLASS_ETH,
						       ethname[i], &dev[i]));
		ut_assertok(device_remove(dev[i], DM_REMOVE_NORMAL));

		/* Invalidate MAC address */
		strncpy(ethaddr[i], env_get(addrname[i]), 17);
		/* Must disable access protection for ethaddr before clearing */
		env_set(".flags", addrname[i]);
		env_set(addrname[i], NULL);
	}

	/* Set ethact to "eth@10002000" */
	env_set("ethact", ethname[0]);

	/* Segment fault might happen if something is wrong */
	ut_asserteq(-ENODEV, net_loop(PING));

	for (i = 0; i < DM_TEST_ETH_NUM; i++) {
		/* Restore the env */
		env_set(".flags", addrname[i]);
		env_set(addrname[i], ethaddr[i]);

		/* Probe the device again */
		ut_assertok(device_probe(dev[i]));
	}
	env_set(".flags", NULL);
	env_set("ethact", NULL);

	return 0;
}
예제 #12
0
파일: clk.c 프로젝트: Xilinx/u-boot-xlnx
static int dm_test_clk_bulk(struct unit_test_state *uts)
{
	struct udevice *dev_clk, *dev_test;

	ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
					      &dev_clk));
	ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "clk-test",
					      &dev_test));
	ut_assertok(sandbox_clk_test_get_bulk(dev_test));

	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));

	/* Fixed clock does not support enable, thus should not fail */
	ut_assertok(sandbox_clk_test_enable_bulk(dev_test));
	ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
	ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));

	/* Fixed clock does not support disable, thus should not fail */
	ut_assertok(sandbox_clk_test_disable_bulk(dev_test));
	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));

	/* Fixed clock does not support enable, thus should not fail */
	ut_assertok(sandbox_clk_test_enable_bulk(dev_test));
	ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
	ut_asserteq(1, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));

	/* Fixed clock does not support disable, thus should not fail */
	ut_assertok(sandbox_clk_test_release_bulk(dev_test));
	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_I2C));

	return 0;
}
예제 #13
0
파일: blk.c 프로젝트: Noltari/u-boot
/* Test that block devices work correctly with USB */
static int dm_test_blk_usb(struct unit_test_state *uts)
{
	struct udevice *usb_dev, *dev;
	struct blk_desc *dev_desc;

	/* Get a flash device */
	state_set_skip_delays(true);
	ut_assertok(usb_init());
	ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &usb_dev));
	ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));

	/* The parent should be a block device */
	ut_assertok(blk_get_device(IF_TYPE_USB, 0, &dev));
	ut_asserteq_ptr(usb_dev, dev_get_parent(dev));

	/* Check we have one block device for each mass storage device */
	ut_asserteq(6, count_blk_devices());

	/* Now go around again, making sure the old devices were unbound */
	ut_assertok(usb_stop());
	ut_assertok(usb_init());
	ut_asserteq(6, count_blk_devices());
	ut_assertok(usb_stop());

	return 0;
}
예제 #14
0
파일: led.c 프로젝트: axxia/axxia_u-boot
/* Test obtaining an LED by label */
static int dm_test_led_label(struct unit_test_state *uts)
{
	struct udevice *dev, *cmp;

	ut_assertok(led_get_by_label("sandbox:red", &dev));
	ut_asserteq(1, device_active(dev));
	ut_assertok(uclass_get_device(UCLASS_LED, 1, &cmp));
	ut_asserteq_ptr(dev, cmp);

	ut_assertok(led_get_by_label("sandbox:green", &dev));
	ut_asserteq(1, device_active(dev));
	ut_assertok(uclass_get_device(UCLASS_LED, 2, &cmp));
	ut_asserteq_ptr(dev, cmp);

	ut_asserteq(-ENODEV, led_get_by_label("sandbox:blue", &dev));

	return 0;
}
예제 #15
0
static int dm_test_device_get_uclass_id(struct unit_test_state *uts)
{
	struct udevice *dev;

	ut_assertok(uclass_get_device(UCLASS_TEST, 0, &dev));
	ut_asserteq(UCLASS_TEST, device_get_uclass_id(dev));

	return 0;
}
예제 #16
0
파일: blk.c 프로젝트: Noltari/u-boot
/* Test that we can find block devices without probing them */
static int dm_test_blk_find(struct unit_test_state *uts)
{
	struct udevice *blk, *dev;

	ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
				      IF_TYPE_HOST, 1, 512, 2, &blk));
	ut_asserteq(-ENODEV, blk_find_device(IF_TYPE_HOST, 0, &dev));
	ut_assertok(blk_find_device(IF_TYPE_HOST, 1, &dev));
	ut_asserteq_ptr(blk, dev);
	ut_asserteq(false, device_active(dev));

	/* Now activate it */
	ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
	ut_asserteq_ptr(blk, dev);
	ut_asserteq(true, device_active(dev));

	return 0;
}
예제 #17
0
파일: eth.c 프로젝트: Noltari/u-boot
static int dm_test_eth(struct unit_test_state *uts)
{
	net_ping_ip = string_to_ip("1.1.2.2");

	env_set("ethact", "eth@10002000");
	ut_assertok(net_loop(PING));
	ut_asserteq_str("eth@10002000", env_get("ethact"));

	env_set("ethact", "eth@10003000");
	ut_assertok(net_loop(PING));
	ut_asserteq_str("eth@10003000", env_get("ethact"));

	env_set("ethact", "eth@10004000");
	ut_assertok(net_loop(PING));
	ut_asserteq_str("eth@10004000", env_get("ethact"));

	return 0;
}
예제 #18
0
파일: eth.c 프로젝트: Noltari/u-boot
static int dm_test_eth_prime(struct unit_test_state *uts)
{
	net_ping_ip = string_to_ip("1.1.2.2");

	/* Expected to be "eth@10003000" because of ethprime variable */
	env_set("ethact", NULL);
	env_set("ethprime", "eth5");
	ut_assertok(net_loop(PING));
	ut_asserteq_str("eth@10003000", env_get("ethact"));

	/* Expected to be "eth@10002000" because it is first */
	env_set("ethact", NULL);
	env_set("ethprime", NULL);
	ut_assertok(net_loop(PING));
	ut_asserteq_str("eth@10002000", env_get("ethact"));

	return 0;
}
예제 #19
0
/* Remove all drivers and check that things work */
static int dm_test_remove(struct unit_test_state *uts)
{
	struct udevice *dev;
	int i;

	for (i = 0; i < 3; i++) {
		ut_assertok(uclass_find_device(UCLASS_TEST, i, &dev));
		ut_assert(dev);
		ut_assertf(dev->flags & DM_FLAG_ACTIVATED,
			   "Driver %d/%s not activated", i, dev->name);
		ut_assertok(device_remove(dev));
		ut_assertf(!(dev->flags & DM_FLAG_ACTIVATED),
			   "Driver %d/%s should have deactivated", i,
			   dev->name);
		ut_assert(!dev->priv);
	}

	return 0;
}
예제 #20
0
파일: led.c 프로젝트: axxia/axxia_u-boot
static int dm_test_led_blink(struct unit_test_state *uts)
{
	const int offset = 1;
	struct udevice *dev, *gpio;

	/*
	 * Check that we get an error when trying to blink an LED, since it is
	 * not supported by the GPIO LED driver.
	 */
	ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev));
	ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio));
	ut_asserteq(0, sandbox_gpio_get_value(gpio, offset));
	ut_asserteq(-ENOSYS, led_set_state(dev, LEDST_BLINK));
	ut_asserteq(0, sandbox_gpio_get_value(gpio, offset));
	ut_asserteq(LEDST_OFF, led_get_state(dev));
	ut_asserteq(-ENOSYS, led_set_period(dev, 100));

	return 0;
}
예제 #21
0
파일: gpio.c 프로젝트: KunYi/uboot-samx6i
/* Test that gpio_request() copies its string */
static int dm_test_gpio_copy(struct dm_test_state *dms)
{
	unsigned int offset, gpio;
	struct udevice *dev;
	char buf[80], name[10];

	ut_assertok(gpio_lookup_name("b6", &dev, &offset, &gpio));
	strcpy(name, "odd_name");
	ut_assertok(gpio_request(gpio, name));
	sandbox_gpio_set_direction(dev, offset, 1);
	sandbox_gpio_set_value(dev, offset, 1);
	ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
	ut_asserteq_str("b6: output: 1 [x] odd_name", buf);
	strcpy(name, "nothing");
	ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
	ut_asserteq_str("b6: output: 1 [x] odd_name", buf);

	return 0;
}
예제 #22
0
static int dm_test_uclass_devices_get_by_name(struct unit_test_state *uts)
{
	struct udevice *finddev;
	struct udevice *testdev;
	int ret, findret;

	/*
	 * For each test device found in fdt like: "a-test", "b-test", etc.,
	 * use its name and try to get it by uclass_get_device_by_name().
	 * On success check if:
	 * - returned finddev' is active
	 * - current 'testdev' name is equal to the returned 'finddev' name
	 * - current 'testdev' pointer is equal to the returned 'finddev'
	 *
	 * We asserts that the 'testdev' is active on each loop entry, so we
	 * could be sure that the 'finddev' is activated too, but for sure
	 * we check it again.
	 *
	 * We assume that, each uclass's device name is unique, so if not, then
	 * this will fail on checking condition: testdev == finddev, since the
	 * uclass_get_device_by_name(), returns the first device by given name.
	*/
	for (ret = uclass_first_device(UCLASS_TEST_FDT, &testdev);
	     testdev;
	     ret = uclass_next_device(&testdev)) {
		ut_assertok(ret);
		ut_assert(testdev);
		ut_assert(device_active(testdev));

		findret = uclass_get_device_by_name(UCLASS_TEST_FDT,
						    testdev->name,
						    &finddev);

		ut_assertok(findret);
		ut_assert(finddev);
		ut_assert(device_active(finddev));
		ut_asserteq_str(testdev->name, finddev->name);
		ut_asserteq_ptr(testdev, finddev);
	}

	return 0;
}
예제 #23
0
/* Test regulator get method */
static int dm_test_power_regulator_get(struct unit_test_state *uts)
{
	struct dm_regulator_uclass_platdata *uc_pdata;
	struct udevice *dev_by_devname;
	struct udevice *dev_by_platname;
	const char *devname;
	const char *platname;
	int i;

	for (i = 0; i < OUTPUT_COUNT; i++) {
		/*
		 * Do the test for each regulator's devname and platname,
		 * which are related to a single device.
		 */
		devname = regulator_names[i][DEVNAME];
		platname = regulator_names[i][PLATNAME];

		/*
		 * Check, that regulator_get_by_devname() function, returns
		 * a device with the name equal to the requested one.
		 */
		ut_assertok(regulator_get_by_devname(devname, &dev_by_devname));
		ut_asserteq_str(devname, dev_by_devname->name);

		/*
		 * Check, that regulator_get_by_platname() function, returns
		 * a device with the name equal to the requested one.
		 */
		ut_assertok(regulator_get_by_platname(platname, &dev_by_platname));
		uc_pdata = dev_get_uclass_platdata(dev_by_platname);
		ut_assert(uc_pdata);
		ut_asserteq_str(platname, uc_pdata->name);

		/*
		 * Check, that the pointers returned by both get functions,
		 * points to the same regulator device.
		 */
		ut_asserteq_ptr(dev_by_devname, dev_by_platname);
	}

	return 0;
}
예제 #24
0
/* Remove and recreate everything, check for memory leaks */
static int dm_test_leak(struct dm_test_state *dms)
{
	int i;

	for (i = 0; i < 2; i++) {
		struct mallinfo start, end;
		struct udevice *dev;
		int ret;
		int id;

		start = mallinfo();
		if (!start.uordblks)
			puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n");

		ut_assertok(dm_scan_platdata());
		ut_assertok(dm_scan_fdt(gd->fdt_blob));

		/* Scanning the uclass is enough to probe all the devices */
		for (id = UCLASS_ROOT; id < UCLASS_COUNT; id++) {
			for (ret = uclass_first_device(UCLASS_TEST, &dev);
			     dev;
			     ret = uclass_next_device(&dev))
				;
			ut_assertok(ret);
		}

		/* Don't delete the root class, since we started with that */
		for (id = UCLASS_ROOT + 1; id < UCLASS_COUNT; id++) {
			struct uclass *uc;

			uc = uclass_find(id);
			if (!uc)
				continue;
			ut_assertok(uclass_destroy(uc));
		}

		end = mallinfo();
		ut_asserteq(start.uordblks, end.uordblks);
	}

	return 0;
}
예제 #25
0
/* Test scrolling TrueType console */
static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
{
	struct sandbox_sdl_plat *plat;
	struct udevice *dev, *con;
	const char *test_string = "Criticism may not be agreeable, but it is necessary. It fulfils the same function as pain in the human body. It calls attention to an unhealthy state of things. Some see private enterprise as a predatory target to be shot, others as a cow to be milked, but few are those who see it as a sturdy horse pulling the wagon. The \aprice OF\b\bof greatness\n\tis responsibility.\n\nBye";
	const char *s;

	ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
	ut_assert(!device_active(dev));
	plat = dev_get_platdata(dev);
	plat->font_size = 100;

	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
	for (s = test_string; *s; s++)
		vidconsole_put_char(con, *s);
	ut_asserteq(33849, compress_frame_buffer(dev));

	return 0;
}
예제 #26
0
/* Test TrueType backspace, within and across lines */
static int dm_test_video_truetype_bs(struct unit_test_state *uts)
{
	struct sandbox_sdl_plat *plat;
	struct udevice *dev, *con;
	const char *test_string = "...Criticism may or may\b\b\b\b\b\bnot be agreeable, but seldom it is necessary\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bit is necessary. It fulfils the same function as pain in the human body. It calls attention to an unhealthy state of things.";
	const char *s;

	ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
	ut_assert(!device_active(dev));
	plat = dev_get_platdata(dev);
	plat->font_size = 100;

	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
	for (s = test_string; *s; s++)
		vidconsole_put_char(con, *s);
	ut_asserteq(34871, compress_frame_buffer(dev));

	return 0;
}
예제 #27
0
/* Test that we can probe for children */
static int dm_test_bus_children(struct unit_test_state *uts)
{
	int num_devices = 6;
	struct udevice *bus;
	struct uclass *uc;

	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
	ut_asserteq(num_devices, list_count_items(&uc->dev_head));

	/* Probe the bus, which should yield 3 more devices */
	ut_assertok(uclass_get_device(UCLASS_TEST_BUS, 0, &bus));
	num_devices += 3;

	ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc));
	ut_asserteq(num_devices, list_count_items(&uc->dev_head));

	ut_assert(!dm_check_devices(uts, num_devices));

	return 0;
}
예제 #28
0
/* Get ready for testing */
static int dm_test_init(struct dm_test_state *dms)
{
	memset(dms, '\0', sizeof(*dms));
	gd->dm_root = NULL;
	memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));

	ut_assertok(dm_init());
	dms->root = dm_root();

	return 0;
}
예제 #29
0
파일: core.c 프로젝트: mfkiwl/u-boot
static int dm_test_uclass_before_ready(struct dm_test_state *dms)
{
	struct uclass *uc;

	ut_assertok(uclass_get(UCLASS_TEST, &uc));

	memset(gd, '\0', sizeof(*gd));
	ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));

	return 0;
}
예제 #30
0
파일: board.c 프로젝트: Noltari/u-boot
static int dm_test_board(struct unit_test_state *uts)
{
	struct udevice *board;
	bool called_detect;
	char str[64];
	int i;

	board_get(&board);
	ut_assert(board);

	board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
	ut_assert(!called_detect);

	board_detect(board);

	board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
	ut_assert(called_detect);

	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
	ut_assertok(strcmp(str, "R'lyeh"));

	board_get_int(board, INT_TEST1, &i);
	ut_asserteq(0, i);

	board_get_int(board, INT_TEST2, &i);
	ut_asserteq(100, i);

	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
	ut_assertok(strcmp(str, "Carcosa"));

	board_get_int(board, INT_TEST1, &i);
	ut_asserteq(1, i);

	board_get_int(board, INT_TEST2, &i);
	ut_asserteq(99, i);

	board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
	ut_assertok(strcmp(str, "Yuggoth"));

	return 0;
}