summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Ceballos <pceballos@google.com>2022-08-20 02:36:00 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-22 18:21:23 +0000
commitfd64db8d5b25a6f9405861691c3d8a2134a31b54 (patch)
treea31997d118b6ea74bde05bb1c74af9d19f6f5051
parentb4e35d905e8728b0e74f389527254a03e953f09b (diff)
downloadchrome-ec-fd64db8d5b25a6f9405861691c3d8a2134a31b54.tar.gz
ec: Add test for chipset_get_shutdown_reason
BRANCH=none BUG=b:242708232 TEST=make buildall -j Change-Id: Ic134433cb1a85be277806bf285656b12305c3c3b Signed-off-by: Pablo Ceballos <pceballos@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843066 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Pablo Ceballos <pceballos@chromium.org> Auto-Submit: Pablo Ceballos <pceballos@chromium.org> Tested-by: Pablo Ceballos <pceballos@chromium.org>
-rw-r--r--board/host/board.h2
-rw-r--r--test/build.mk2
-rw-r--r--test/chipset.c32
-rw-r--r--test/chipset.tasklist10
4 files changed, 46 insertions, 0 deletions
diff --git a/board/host/board.h b/board/host/board.h
index 97d9789f9a..fc7f9ea6af 100644
--- a/board/host/board.h
+++ b/board/host/board.h
@@ -30,6 +30,8 @@
#define CONFIG_USB_PD_CUSTOM_PDO
#define CONFIG_USB_PD_DUAL_ROLE
+#define CONFIG_CMD_AP_RESET_LOG
+
#include "gpio_signal.h"
enum temp_sensor_id {
diff --git a/test/build.mk b/test/build.mk
index 10e8f720f1..1a29f8111c 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -33,6 +33,7 @@ test-list-host += cec
test-list-host += charge_manager
test-list-host += charge_manager_drp_charging
test-list-host += charge_ramp
+test-list-host += chipset
test-list-host += compile_time_macros
test-list-host += console_edit
test-list-host += crc
@@ -170,6 +171,7 @@ cec-y=cec.o
charge_manager-y=charge_manager.o fake_usbc.o
charge_manager_drp_charging-y=charge_manager.o fake_usbc.o
charge_ramp-y+=charge_ramp.o
+chipset-y+=chipset.o
compile_time_macros-y=compile_time_macros.o
console_edit-y=console_edit.o
cortexm_fpu-y=cortexm_fpu.o
diff --git a/test/chipset.c b/test/chipset.c
new file mode 100644
index 0000000000..caad08b52e
--- /dev/null
+++ b/test/chipset.c
@@ -0,0 +1,32 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Test chipset
+ */
+
+#define CONFIG_CMD_AP_RESET_LOG
+
+#include "chipset.h"
+#include "test_util.h"
+
+static int test_get_shutdown_reason(void)
+{
+ enum chipset_shutdown_reason reason = chipset_get_shutdown_reason();
+
+ TEST_ASSERT(reason == 0);
+ report_ap_reset(CHIPSET_SHUTDOWN_POWERFAIL);
+ reason = chipset_get_shutdown_reason();
+ TEST_ASSERT(reason == CHIPSET_SHUTDOWN_POWERFAIL);
+
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, char **argv)
+{
+ test_reset();
+
+ RUN_TEST(test_get_shutdown_reason);
+
+ test_print_result();
+}
diff --git a/test/chipset.tasklist b/test/chipset.tasklist
new file mode 100644
index 0000000000..ea773a46ce
--- /dev/null
+++ b/test/chipset.tasklist
@@ -0,0 +1,10 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST \
+ TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE)