Simon Glass | 9b306e5 | 2021-01-16 14:52:22 -0700 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | /* |
| 3 | * Copyright 2021 Google LLC |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <cros_ec.h> |
| 8 | #include <dm.h> |
| 9 | #include <asm/test.h> |
| 10 | #include <dm/test.h> |
| 11 | #include <test/ut.h> |
| 12 | |
| 13 | static int dm_test_cros_ec_hello(struct unit_test_state *uts) |
| 14 | { |
| 15 | struct udevice *dev; |
| 16 | uint val; |
| 17 | |
| 18 | ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev)); |
| 19 | |
| 20 | ut_assertok(cros_ec_hello(dev, NULL)); |
| 21 | |
| 22 | val = 0xdead1357; |
| 23 | ut_assertok(cros_ec_hello(dev, &val)); |
| 24 | ut_asserteq(0xdead1357, val); |
| 25 | |
| 26 | sandbox_cros_ec_set_test_flags(dev, CROSECT_BREAK_HELLO); |
| 27 | ut_asserteq(-ENOTSYNC, cros_ec_hello(dev, &val)); |
| 28 | ut_asserteq(0x12345678, val); |
| 29 | |
| 30 | return 0; |
| 31 | } |
| 32 | DM_TEST(dm_test_cros_ec_hello, UT_TESTF_SCAN_FDT); |