blob: ff50d6c38bce3883032e0a0c14631f8136682e4e [file] [log] [blame]
Mario Sixab664ff2018-07-31 11:44:13 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (C) Copyright 2018
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
5 */
6
7#include <common.h>
8#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Mario Sixab664ff2018-07-31 11:44:13 +020010#include <dm/test.h>
11#include <board.h>
Simon Glass75c4d412020-07-19 10:15:37 -060012#include <test/test.h>
Mario Sixab664ff2018-07-31 11:44:13 +020013#include <test/ut.h>
14
15#include "../../drivers/board/sandbox.h"
16
17static int dm_test_board(struct unit_test_state *uts)
18{
19 struct udevice *board;
20 bool called_detect;
21 char str[64];
22 int i;
23
24 board_get(&board);
25 ut_assert(board);
26
27 board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
28 ut_assert(!called_detect);
29
30 board_detect(board);
31
32 board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
33 ut_assert(called_detect);
34
35 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
36 ut_assertok(strcmp(str, "R'lyeh"));
37
38 board_get_int(board, INT_TEST1, &i);
39 ut_asserteq(0, i);
40
41 board_get_int(board, INT_TEST2, &i);
42 ut_asserteq(100, i);
43
44 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
45 ut_assertok(strcmp(str, "Carcosa"));
46
47 board_get_int(board, INT_TEST1, &i);
48 ut_asserteq(1, i);
49
50 board_get_int(board, INT_TEST2, &i);
51 ut_asserteq(99, i);
52
53 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
54 ut_assertok(strcmp(str, "Yuggoth"));
55
56 return 0;
57}
58
59DM_TEST(dm_test_board, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);