summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMario Six <mario.six@gdsys.cc>2018-07-31 12:44:13 +0300
committerSimon Glass <sjg@chromium.org>2018-09-29 20:49:35 +0300
commite6fd0181082a04e743a07ebd9f6fdd0e06dc1399 (patch)
treed552e2aa2fbe7bb6e4ea4ff6b262696d04f0b4d9 /test
parent6238ae4d60476dd7535b781ef3f255f676851283 (diff)
downloadu-boot-e6fd0181082a04e743a07ebd9f6fdd0e06dc1399.tar.xz
test: Add tests for board uclass
Add tests for the new board uclass. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
Diffstat (limited to 'test')
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/board.c57
2 files changed, 58 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 8b1ba915d0..d7f5d6b061 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -14,6 +14,7 @@ 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_DM_GPIO) += gpio.o
diff --git a/test/dm/board.c b/test/dm/board.c
new file mode 100644
index 0000000000..0f267a1926
--- /dev/null
+++ b/test/dm/board.c
@@ -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);