blob: 0f267a192606f3f4d1c1430c604ff8667386b4e4 [file] [log] [blame]
Mario Sixe6fd0182018-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>
9#include <dm/test.h>
10#include <board.h>
11#include <test/ut.h>
12
13#include "../../drivers/board/sandbox.h"
14
15static int dm_test_board(struct unit_test_state *uts)
16{
17 struct udevice *board;
18 bool called_detect;
19 char str[64];
20 int i;
21
22 board_get(&board);
23 ut_assert(board);
24
25 board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
26 ut_assert(!called_detect);
27
28 board_detect(board);
29
30 board_get_bool(board, BOOL_CALLED_DETECT, &called_detect);
31 ut_assert(called_detect);
32
33 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
34 ut_assertok(strcmp(str, "R'lyeh"));
35
36 board_get_int(board, INT_TEST1, &i);
37 ut_asserteq(0, i);
38
39 board_get_int(board, INT_TEST2, &i);
40 ut_asserteq(100, i);
41
42 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
43 ut_assertok(strcmp(str, "Carcosa"));
44
45 board_get_int(board, INT_TEST1, &i);
46 ut_asserteq(1, i);
47
48 board_get_int(board, INT_TEST2, &i);
49 ut_asserteq(99, i);
50
51 board_get_str(board, STR_VACATIONSPOT, sizeof(str), str);
52 ut_assertok(strcmp(str, "Yuggoth"));
53
54 return 0;
55}
56
57DM_TEST(dm_test_board, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);