diff options
Diffstat (limited to 'zephyr/test/drivers/host_cmd')
-rw-r--r-- | zephyr/test/drivers/host_cmd/src/motion_sense.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/zephyr/test/drivers/host_cmd/src/motion_sense.c b/zephyr/test/drivers/host_cmd/src/motion_sense.c index c231f6f55e..94c654de05 100644 --- a/zephyr/test/drivers/host_cmd/src/motion_sense.c +++ b/zephyr/test/drivers/host_cmd/src/motion_sense.c @@ -127,13 +127,25 @@ ZTEST_USER(host_cmd_motion_sense, test_dump) * tests in a loop, but since the number of sensors (as well as the * order) is adjustable by devicetree, it would be too difficult to hard * code here. + * When CONFIG_GESTURE_HOST_DETECTION is enabled, ALL_MOTION_SENSORS is + * increased by 1 (see include/motion_sense.h). Additionally, + * host_cmd_motion_sense() only fills in |motion_sensor_count| worth of + * data (not ALL_MOTION_SENSORS+1), and zeroes out the rest, so only + * validate |motion_sensor_count| worth of data and that the rest is + * zeroed out. */ for (int i = 0; i < ALL_MOTION_SENSORS; ++i) { - zassert_equal(result->dump.sensor[i].flags, - MOTIONSENSE_SENSOR_FLAG_PRESENT, NULL); - zassert_equal(result->dump.sensor[i].data[0], i); - zassert_equal(result->dump.sensor[i].data[1], i + 1); - zassert_equal(result->dump.sensor[i].data[2], i + 2); + if (i < motion_sensor_count) { + zassert_equal(result->dump.sensor[i].flags, + MOTIONSENSE_SENSOR_FLAG_PRESENT, NULL); + zassert_equal(result->dump.sensor[i].data[0], i); + zassert_equal(result->dump.sensor[i].data[1], i + 1); + zassert_equal(result->dump.sensor[i].data[2], i + 2); + } else { + zassert_equal(result->dump.sensor[i].data[0], 0); + zassert_equal(result->dump.sensor[i].data[1], 0); + zassert_equal(result->dump.sensor[i].data[2], 0); + } } /* Make sure that the accelerometer status presence bit is on */ |