]>
Commit | Line | Data |
---|---|---|
e6fd0181 MS |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * (C) Copyright 2018 | |
4 | * Mario Six, Guntermann & Drunck GmbH, [email protected] | |
5 | */ | |
6 | ||
7 | #include <common.h> | |
8 | #include <dm.h> | |
f7ae49fc | 9 | #include <log.h> |
e6fd0181 MS |
10 | #include <dm/test.h> |
11 | #include <board.h> | |
0e1fad43 | 12 | #include <test/test.h> |
e6fd0181 MS |
13 | #include <test/ut.h> |
14 | ||
15 | #include "../../drivers/board/sandbox.h" | |
16 | ||
17 | static 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 | ||
e180c2b1 | 59 | DM_TEST(dm_test_board, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |