Merge git://git.denx.de/u-boot-dm
This commit is contained in:
@@ -14,8 +14,10 @@ obj-$(CONFIG_UT_DM) += test-uclass.o
|
||||
obj-$(CONFIG_UT_DM) += core.o
|
||||
ifneq ($(CONFIG_SANDBOX),)
|
||||
obj-$(CONFIG_BLK) += blk.o
|
||||
obj-$(CONFIG_BOARD) += board.o
|
||||
obj-$(CONFIG_CLK) += clk.o
|
||||
obj-$(CONFIG_DM_ETH) += eth.o
|
||||
obj-$(CONFIG_FIRMWARE) += firmware.o
|
||||
obj-$(CONFIG_DM_GPIO) += gpio.o
|
||||
obj-$(CONFIG_DM_I2C) += i2c.o
|
||||
obj-$(CONFIG_LED) += led.o
|
||||
|
||||
57
test/dm/board.c
Normal file
57
test/dm/board.c
Normal file
@@ -0,0 +1,57 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* (C) Copyright 2018
|
||||
* Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <dm/test.h>
|
||||
#include <board.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
#include "../../drivers/board/sandbox.h"
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
DM_TEST(dm_test_board, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
|
||||
22
test/dm/firmware.c
Normal file
22
test/dm/firmware.c
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2018 Xilinx, Inc.
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <syscon.h>
|
||||
#include <asm/test.h>
|
||||
#include <dm/test.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
/* Base test of firmware probe */
|
||||
static int dm_test_firmware_probe(struct unit_test_state *uts)
|
||||
{
|
||||
struct udevice *dev;
|
||||
|
||||
ut_assertok(uclass_get_device_by_name(UCLASS_FIRMWARE,
|
||||
"sandbox-firmware", &dev));
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_firmware_probe, DM_TESTF_SCAN_FDT);
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <dm/util.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/of_access.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
@@ -503,3 +505,83 @@ static int dm_test_fdt_remap_addr_live(struct unit_test_state *uts)
|
||||
}
|
||||
DM_TEST(dm_test_fdt_remap_addr_live,
|
||||
DM_TESTF_SCAN_PDATA | DM_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, true, &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(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, 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);
|
||||
|
||||
Reference in New Issue
Block a user