summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-16 14:52:29 -0700
committerSimon Glass <sjg@chromium.org>2021-01-30 14:25:41 -0700
commit3ae338299e1649ef9a38c45fcde864022c448a9e (patch)
tree468f3895ae48d1f67814de5c2d0166927df6159c /test
parent3a6c994f3896d66e617acdf9bb58ffc4def08b71 (diff)
downloadu-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.tar.gz
u-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.tar.xz
u-boot-3ae338299e1649ef9a38c45fcde864022c448a9e.zip
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.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/dm/cros_ec.c b/test/dm/cros_ec.c
index 43774400a1..0da7548fd2 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);