summaryrefslogtreecommitdiff
path: root/test/motion_lid.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2020-11-04 16:01:18 -0800
committerCommit Bot <commit-bot@chromium.org>2020-12-01 02:37:52 +0000
commit2d723bc9961fd18a0f08db8b244ba59f31d7188b (patch)
tree7f312d423758ea16072738252473bc7eedee5688 /test/motion_lid.c
parentdcdd0522d12ec52790f73963d6845b5da2b49308 (diff)
downloadchrome-ec-2d723bc9961fd18a0f08db8b244ba59f31d7188b.tar.gz
motion_sense: Stop collection when sensor is powered down
Set collection_rate to 0 when sensor is not in initialized state anymore. It will prevent the motion_sense task to be neededlessly scheduled. Export wait_us to be tested. BUG=b:170703322 BRANCH=kukui TEST=unit test Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: I1dc4c7a07ff30fa10997ef87784114c725f100d5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2520297 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Chen-Tsung Hsieh <chentsung@chromium.org> Reviewed-by: Yuval Peress <peress@chromium.org>
Diffstat (limited to 'test/motion_lid.c')
-rw-r--r--test/motion_lid.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/motion_lid.c b/test/motion_lid.c
index d3b64fa1ba..9935767a68 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -21,6 +21,7 @@
#include "util.h"
extern enum chipset_state_mask sensor_active;
+extern int wait_us;
/*
* Period in us for the motion task period.
@@ -160,6 +161,9 @@ static int test_lid_angle(void)
msleep(50);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5);
TEST_ASSERT(accel_get_data_rate(lid) == 0);
+ TEST_ASSERT(base->collection_rate == 0);
+ TEST_ASSERT(lid->collection_rate == 0);
+ TEST_ASSERT(wait_us == -1);
/* Go to S0 state */
hook_notify(HOOK_CHIPSET_SUSPEND);
@@ -167,6 +171,9 @@ static int test_lid_angle(void)
msleep(50);
TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0);
TEST_ASSERT(accel_get_data_rate(lid) == 119000);
+ TEST_ASSERT(base->collection_rate != 0);
+ TEST_ASSERT(lid->collection_rate != 0);
+ TEST_ASSERT(wait_us > 0);
/*
* Set the base accelerometer as if it were sitting flat on a desk
@@ -300,6 +307,15 @@ static int test_lid_angle(void)
wait_for_valid_sample();
TEST_ASSERT(motion_lid_get_angle() == 10);
+ hook_notify(HOOK_CHIPSET_SHUTDOWN);
+ msleep(1000);
+ TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5);
+ /* Base ODR is 0, collection rate is 0. */
+ TEST_ASSERT(base->collection_rate == 0);
+ /* Lid is powered off, collection rate is 0. */
+ TEST_ASSERT(lid->collection_rate == 0);
+ TEST_ASSERT(wait_us == -1);
+
return EC_SUCCESS;
}