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