Mario Six | ab664ff | 2018-07-31 11:44:13 +0200 | [diff] [blame] | 1 | // 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 Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Mario Six | ab664ff | 2018-07-31 11:44:13 +0200 | [diff] [blame] | 10 | #include <dm/test.h> |
| 11 | #include <board.h> |
Simon Glass | 75c4d41 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 12 | #include <test/test.h> |
Mario Six | ab664ff | 2018-07-31 11:44:13 +0200 | [diff] [blame] | 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 | |
| 59 | DM_TEST(dm_test_board, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |