summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/src/console_cmd/accelrange.c
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2022-07-24 21:31:52 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-25 20:51:37 +0000
commitc16f255ef203b67eb31cb727a98f96e3fbce1d4b (patch)
tree7f6b5f11e5221b9588795cd56dfd6db8dad90cc9 /zephyr/test/drivers/src/console_cmd/accelrange.c
parent3524a1f7eb23533a4a6cffd4c69bd07cf1b43129 (diff)
downloadchrome-ec-c16f255ef203b67eb31cb727a98f96e3fbce1d4b.tar.gz
zephyr: test: migrate drivers test to twister
1. Move the common test logic to drivers/common with its own CMakeLists.txt 2. Move the drivers test suites to drivers/default with its own CMakeLists.txt 3. Add a Kconfig for each suite that can enable it, use Zephyr's add_subdirectory_ifdef to control which suites get added to the biary and verify that at least 1 suite was added. 4. Add a check for ZMAKE_PROJECT_NAME to still allow zmake commands 5. Add testcase.yaml which runs all the tests BRANCH=none BUG=b:240093007 TEST=./twister --coverage -p native_posix -T zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ib9d4ea4a8431539391cc5349a7a8fd7a7d21f120 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3784043 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
Diffstat (limited to 'zephyr/test/drivers/src/console_cmd/accelrange.c')
-rw-r--r--zephyr/test/drivers/src/console_cmd/accelrange.c112
1 files changed, 0 insertions, 112 deletions
diff --git a/zephyr/test/drivers/src/console_cmd/accelrange.c b/zephyr/test/drivers/src/console_cmd/accelrange.c
deleted file mode 100644
index b78702e486..0000000000
--- a/zephyr/test/drivers/src/console_cmd/accelrange.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2022 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.
- */
-
-#include <zephyr/shell/shell.h>
-#include <zephyr/devicetree.h>
-#include <ztest.h>
-
-#include "console.h"
-#include "driver/accel_bma2x2.h"
-#include "ec_commands.h"
-#include "emul/emul_bma255.h"
-#include "emul/emul_common_i2c.h"
-#include "i2c.h"
-#include "motion_sense.h"
-#include "test/drivers/test_state.h"
-
-#define EMUL_LABEL DT_NODELABEL(bma_emul)
-
-#define BMA_ORD DT_DEP_ORD(EMUL_LABEL)
-
-static void console_cmd_accelrange_after(void *fixture)
-{
- struct i2c_emul *emul = bma_emul_get(BMA_ORD);
-
- ARG_UNUSED(fixture);
- shell_execute_cmd(get_ec_shell(), "accelrange 0 2");
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-}
-
-ZTEST_SUITE(console_cmd_accelrange, drivers_predicate_post_main, NULL, NULL,
- console_cmd_accelrange_after, NULL);
-
-ZTEST_USER(console_cmd_accelrange, test_num_args)
-{
- int rv;
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange");
- zassert_equal(rv, EC_ERROR_PARAM_COUNT, "Expected %d, but got %d",
- EC_ERROR_PARAM_COUNT, rv);
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange 0 1 2 3");
- zassert_equal(rv, EC_ERROR_PARAM_COUNT, "Expected %d, but got %d",
- EC_ERROR_PARAM_COUNT, rv);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_bad_sensor_num)
-{
- int rv;
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange t");
- zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
- EC_ERROR_PARAM1, rv);
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange -1");
- zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
- EC_ERROR_PARAM1, rv);
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange 100");
- zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
- EC_ERROR_PARAM1, rv);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_print_range)
-{
- zassert_ok(shell_execute_cmd(get_ec_shell(), "accelrange 0"), NULL);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_set_invalid_range)
-{
- int rv = shell_execute_cmd(get_ec_shell(), "accelrange 0 t");
-
- zassert_equal(rv, EC_ERROR_PARAM2, "Expected %d, but got %d",
- EC_ERROR_PARAM2, rv);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_set_range_round_up_implicit)
-{
- zassert_ok(shell_execute_cmd(get_ec_shell(), "accelrange 0 3"), NULL);
- zassert_equal(motion_sensors[0].current_range, 4,
- "Expected 4, but got %d",
- motion_sensors[0].current_range);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_set_range_round_up_explicit)
-{
- zassert_ok(shell_execute_cmd(get_ec_shell(), "accelrange 0 3 1"), NULL);
- zassert_equal(motion_sensors[0].current_range, 4,
- "Expected 4, but got %d",
- motion_sensors[0].current_range);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_set_range_round_down)
-{
- zassert_ok(shell_execute_cmd(get_ec_shell(), "accelrange 0 5 0"), NULL);
- zassert_equal(motion_sensors[0].current_range, 4,
- "Expected 4, but got %d",
- motion_sensors[0].current_range);
-}
-
-ZTEST_USER(console_cmd_accelrange, test_i2c_error)
-{
- struct i2c_emul *emul = bma_emul_get(BMA_ORD);
- int rv;
-
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_RANGE_SELECT_ADDR);
-
- rv = shell_execute_cmd(get_ec_shell(), "accelrange 0 3");
- zassert_equal(rv, EC_ERROR_PARAM2, "Expected %d, but got %d",
- EC_ERROR_PARAM2, rv);
-}