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); |
Simon Glass | 33909b5 | 2021-01-16 14:52:25 -0700 | [diff] [blame^] | 33 | |
| 34 | static int dm_test_cros_ec_sku_id(struct unit_test_state *uts) |
| 35 | { |
| 36 | struct udevice *dev; |
| 37 | |
| 38 | ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev)); |
| 39 | ut_asserteq(1234, cros_ec_get_sku_id(dev)); |
| 40 | |
| 41 | /* try the command */ |
| 42 | console_record_reset(); |
| 43 | ut_assertok(run_command("crosec sku", 0)); |
| 44 | ut_assert_nextline("1234"); |
| 45 | ut_assert_console_end(); |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | DM_TEST(dm_test_cros_ec_sku_id, UT_TESTF_SCAN_FDT); |