summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Semjonovs <asemjonovs@google.com>2023-01-12 14:00:17 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-17 18:51:03 +0000
commitc66e32f13520e49ca9eed2689a5e94894540dfa4 (patch)
tree2038e7895f23823847f2e1297907f825e17a3b0b
parent1959c156c77804a646d531942bf01949f2f7f64f (diff)
downloadchrome-ec-c66e32f13520e49ca9eed2689a5e94894540dfa4.tar.gz
zephyr: Add coverage for gpio-keys power_button.c
Enable gpio-keys power button to exercise tests for board specific code. BUG=None BRANCH=NONE TEST=zmake build --coverage herobrine ./twister -v -i --coverage -p native_posix -p unit_testing genhtml -q -s --branch-coverage -o build/zephyr/coverage_rpt/ twister-out/coverage.info build/zephyr/herobrine/output/zephyr.info Change-Id: I79901e458f1e7fc48806779b05e80cc58a5a83e5 Signed-off-by: Al Semjonovs <asemjonovs@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4159985 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/test/drivers/boards/native_posix.overlay2
-rw-r--r--zephyr/test/drivers/default/boards/power_button.dtsi17
-rw-r--r--zephyr/test/drivers/testcase.yaml7
-rw-r--r--zephyr/test/qcom_power/src/main.c3
4 files changed, 28 insertions, 1 deletions
diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay
index a0b3a2b868..d36f19f15c 100644
--- a/zephyr/test/drivers/boards/native_posix.overlay
+++ b/zephyr/test/drivers/boards/native_posix.overlay
@@ -211,7 +211,7 @@
/* GPIO_PULL_UP will cause this start asserted,
* i.e. not pressed.
*/
- gpios = <&gpio0 25 (GPIO_INPUT | GPIO_PULL_UP)>;
+ gpios = <&gpio0 25 (GPIO_ACTIVE_LOW | GPIO_INPUT | GPIO_PULL_UP)>;
enum-name = "GPIO_POWER_BUTTON_L";
};
gpio_src_vph_pwr_pg: src_vph_pwr_pg {
diff --git a/zephyr/test/drivers/default/boards/power_button.dtsi b/zephyr/test/drivers/default/boards/power_button.dtsi
new file mode 100644
index 0000000000..b618b15fe2
--- /dev/null
+++ b/zephyr/test/drivers/default/boards/power_button.dtsi
@@ -0,0 +1,17 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <dt-bindings/buttons.h>
+
+/ {
+ gpio_keys0: gpio-keys {
+ compatible = "zephyr,gpio-keys";
+ debounce-interval-ms = <30>;
+ power_button: power_button {
+ gpios = <&gpio0 25 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
+ zephyr,code = <BUTTON_POWER>;
+ };
+ };
+
+};
diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml
index 9b970c77be..afd0538732 100644
--- a/zephyr/test/drivers/testcase.yaml
+++ b/zephyr/test/drivers/testcase.yaml
@@ -31,6 +31,13 @@ tests:
extra_configs:
- CONFIG_LINK_TEST_SUITE_DEFAULT_CONSOLE_CMDS=y
- CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+ drivers.default.console_cmds.gpio_keys:
+ extra_args: CONF_FILE="prj.conf;default/prj.conf"
+ DTC_OVERLAY_FILE="default/boards/native_posix.overlay;default/boards/power_button.dtsi"
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_DEFAULT_CONSOLE_CMDS=y
+ - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+ - CONFIG_PLATFORM_EC_POWER_BUTTON=n
drivers.default.mock_power:
timeout: 360
extra_args: CONF_FILE="prj.conf;default/prj.conf"
diff --git a/zephyr/test/qcom_power/src/main.c b/zephyr/test/qcom_power/src/main.c
index 706b830447..2697a8c3aa 100644
--- a/zephyr/test/qcom_power/src/main.c
+++ b/zephyr/test/qcom_power/src/main.c
@@ -9,6 +9,7 @@
#include "gpio_signal.h"
#include "hooks.h"
#include "host_command.h"
+#include "include/power_button.h"
#include "lid_switch.h"
#include "power.h"
#include "power/qcom.h"
@@ -358,8 +359,10 @@ ZTEST(qcom_power, test_power_button)
zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_MSEC(100));
+ zassert_equal(power_button_signal_asserted(), 1);
zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
k_sleep(K_MSEC(500));
+ zassert_equal(power_button_signal_asserted(), 0);
zassert_equal(power_get_state(), POWER_S0);
}