diff options
author | Simon Glass <sjg@chromium.org> | 2021-01-16 14:52:22 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-01-30 14:25:41 -0700 |
commit | d8e9a93895fb3ad710963ddef6a4cc7c43bd65f6 (patch) | |
tree | 1696ef961329c3eba9122bda0d0f7cb284165587 /test | |
parent | 3096ee866e7388277ad3968d9c7ea704589dedea (diff) | |
download | u-boot-d8e9a93895fb3ad710963ddef6a4cc7c43bd65f6.zip u-boot-d8e9a93895fb3ad710963ddef6a4cc7c43bd65f6.tar.gz u-boot-d8e9a93895fb3ad710963ddef6a4cc7c43bd65f6.tar.bz2 |
cros_ec: Add a function for the hello message
This is used several times in this file. Put it in a function to avoid
code duplication.
Also add a test for this function. There are no cros_ec tests at present,
so it is time to update the code.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/cros_ec.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile index 46e076e..afcabfa 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_BLK) += blk.o obj-$(CONFIG_BUTTON) += button.o obj-$(CONFIG_DM_BOOTCOUNT) += bootcount.o obj-$(CONFIG_CLK) += clk.o clk_ccf.o +obj-$(CONFIG_CROS_EC) += cros_ec.o obj-$(CONFIG_DEVRES) += devres.o obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o obj-$(CONFIG_DM_ETH) += eth.o diff --git a/test/dm/cros_ec.c b/test/dm/cros_ec.c new file mode 100644 index 0000000..823245c --- /dev/null +++ b/test/dm/cros_ec.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2021 Google LLC + */ + +#include <common.h> +#include <cros_ec.h> +#include <dm.h> +#include <asm/test.h> +#include <dm/test.h> +#include <test/ut.h> + +static int dm_test_cros_ec_hello(struct unit_test_state *uts) +{ + struct udevice *dev; + uint val; + + ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev)); + + ut_assertok(cros_ec_hello(dev, NULL)); + + val = 0xdead1357; + ut_assertok(cros_ec_hello(dev, &val)); + ut_asserteq(0xdead1357, val); + + sandbox_cros_ec_set_test_flags(dev, CROSECT_BREAK_HELLO); + ut_asserteq(-ENOTSYNC, cros_ec_hello(dev, &val)); + ut_asserteq(0x12345678, val); + + return 0; +} +DM_TEST(dm_test_cros_ec_hello, UT_TESTF_SCAN_FDT); |