diff options
author | Simon Glass <sjg@chromium.org> | 2021-01-16 14:52:29 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-01-30 14:25:41 -0700 |
commit | 3ae338299e1649ef9a38c45fcde864022c448a9e (patch) | |
tree | 468f3895ae48d1f67814de5c2d0166927df6159c /test | |
parent | 3a6c994f3896d66e617acdf9bb58ffc4def08b71 (diff) | |
download | u-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.zip u-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.tar.gz u-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.tar.bz2 |
cros_ec: Show events in human-readable form
Add a command to show the current events as a list of names. This is
easier to decipher than a bit mask.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/cros_ec.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dm/cros_ec.c b/test/dm/cros_ec.c index 4377440..0da7548 100644 --- a/test/dm/cros_ec.c +++ b/test/dm/cros_ec.c @@ -101,3 +101,40 @@ static int dm_test_cros_ec_switches(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_cros_ec_switches, UT_TESTF_SCAN_FDT); + +static int dm_test_cros_ec_events(struct unit_test_state *uts) +{ + struct udevice *dev; + u32 events; + + ut_assertok(uclass_first_device_err(UCLASS_CROS_EC, &dev)); + ut_assertok(cros_ec_get_host_events(dev, &events)); + ut_asserteq(0, events); + + /* try the command */ + console_record_reset(); + ut_assertok(run_command("crosec events", 0)); + ut_assert_nextline("00000000"); + ut_assert_console_end(); + + /* Open the lid and check the event appears */ + sandbox_cros_ec_set_test_flags(dev, CROSECT_LID_OPEN); + ut_assertok(cros_ec_get_host_events(dev, &events)); + ut_asserteq(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN), events); + + /* try the command */ + console_record_reset(); + ut_assertok(run_command("crosec events", 0)); + ut_assert_nextline("00000002"); + ut_assert_nextline("lid_open"); + ut_assert_console_end(); + + /* Clear the event */ + ut_assertok(cros_ec_clear_host_events(dev, + EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN))); + ut_assertok(cros_ec_get_host_events(dev, &events)); + ut_asserteq(0, events); + + return 0; +} +DM_TEST(dm_test_cros_ec_events, UT_TESTF_SCAN_FDT); |