summaryrefslogtreecommitdiff
path: root/test/motion_angle_tablet.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /test/motion_angle_tablet.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14469.8.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'test/motion_angle_tablet.c')
-rw-r--r--test/motion_angle_tablet.c109
1 files changed, 0 insertions, 109 deletions
diff --git a/test/motion_angle_tablet.c b/test/motion_angle_tablet.c
deleted file mode 100644
index 8eea053405..0000000000
--- a/test/motion_angle_tablet.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Copyright 2018 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Test motion sense code, when in tablet mode.
- */
-
-#include <math.h>
-#include <stdio.h>
-
-#include "accelgyro.h"
-#include "common.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "motion_common.h"
-#include "motion_lid.h"
-#include "motion_sense.h"
-#include "tablet_mode.h"
-#include "test_util.h"
-#include "util.h"
-
-
-/*****************************************************************************/
-/* Test utilities */
-
-/* convert array value from g to m.s^2. */
-int filler(const struct motion_sensor_t *s, const float v)
-{
- return FP_TO_INT( fp_div(
- FLOAT_TO_FP(v) * MOTION_SCALING_FACTOR,
- fp_mul(INT_TO_FP(s->current_range), MOTION_ONE_G)));
-}
-
-static int test_lid_angle_less180(void)
-{
- int index = 0, lid_angle;
- struct motion_sensor_t *lid = &motion_sensors[
- CONFIG_LID_ANGLE_SENSOR_LID];
- struct motion_sensor_t *base = &motion_sensors[
- CONFIG_LID_ANGLE_SENSOR_BASE];
-
- /* We don't have TASK_CHIP so simulate init ourselves */
- hook_notify(HOOK_CHIPSET_SHUTDOWN);
- TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5);
- TEST_ASSERT(lid->drv->get_data_rate(lid) == 0);
-
- /* Go to S0 state */
- hook_notify(HOOK_CHIPSET_SUSPEND);
- hook_notify(HOOK_CHIPSET_RESUME);
- msleep(1000);
- TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0);
- TEST_ASSERT(lid->drv->get_data_rate(lid) == TEST_LID_FREQUENCY);
-
- /* Open lid, testing close to 180 degree. */
- gpio_set_level(GPIO_LID_OPEN, 1);
- msleep(1000);
-
- cprints(CC_ACCEL, "start loop");
- /* Force clamshell mode, to be sure we go in tablet mode ASAP. */
- tablet_set_mode(0, TABLET_TRIGGER_LID);
-
- /* Check we stay in tablet mode, even when hinge is vertical. */
- while (index < kAccelerometerVerticalHingeTestDataLength) {
- feed_accel_data(kAccelerometerVerticalHingeTestData,
- &index, filler);
- wait_for_valid_sample();
- lid_angle = motion_lid_get_angle();
- cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d",
- index / TEST_LID_SAMPLE_SIZE,
- lid->xyz[X], lid->xyz[Y], lid->xyz[Z],
- base->xyz[X], base->xyz[Y], base->xyz[Z],
- lid_angle);
- /* We need few sample to debounce and enter laptop mode. */
- TEST_ASSERT(index < 2 * TEST_LID_SAMPLE_SIZE * \
- (TABLET_MODE_DEBOUNCE_COUNT + 2) ||
- tablet_get_mode());
- }
- /*
- * Check we stay in tablet mode, even when hinge is vertical and
- * shaked.
- */
- tablet_set_mode(0, TABLET_TRIGGER_LID);
- while (index < kAccelerometerVerticalHingeUnstableTestDataLength) {
- feed_accel_data(kAccelerometerVerticalHingeUnstableTestData,
- &index, filler);
- wait_for_valid_sample();
- lid_angle = motion_lid_get_angle();
- cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d",
- index / TEST_LID_SAMPLE_SIZE,
- lid->xyz[X], lid->xyz[Y], lid->xyz[Z],
- base->xyz[X], base->xyz[Y], base->xyz[Z],
- lid_angle);
- /* We need few sample to debounce and enter laptop mode. */
- TEST_ASSERT(index < TEST_LID_SAMPLE_SIZE *
- (TABLET_MODE_DEBOUNCE_COUNT + 2) ||
- tablet_get_mode());
- }
- return EC_SUCCESS;
-}
-
-
-void run_test(int argc, char **argv)
-{
- test_reset();
-
- RUN_TEST(test_lid_angle_less180);
-
- test_print_result();
-}