summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-09-02 13:55:02 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-09-05 07:20:56 +0000
commitb448746bace6d021343bfec615d1cf98f7be17bb (patch)
tree839a25cfa03d6114a225d88fa324fe2b51598cda /test
parent6c3be20539a3b336e2c1c83181ea6f9b0c1506d2 (diff)
downloadchrome-ec-b448746bace6d021343bfec615d1cf98f7be17bb.tar.gz
Add boot key test
This checks boot key combination like Power-F3-ESC and Power-F3-Down can be properly detected. BUG=chrome-os-partner:19236 TEST=Pass kb_scan test BRANCH=None Change-Id: I180918977299219a8421798dac2ab9fed84ef9a2 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/167802
Diffstat (limited to 'test')
-rw-r--r--test/hooks.c4
-rw-r--r--test/kb_scan.c83
-rw-r--r--test/kb_scan.tasklist3
3 files changed, 85 insertions, 5 deletions
diff --git a/test/hooks.c b/test/hooks.c
index 679cf584d3..e688e610c2 100644
--- a/test/hooks.c
+++ b/test/hooks.c
@@ -61,7 +61,7 @@ static void non_deferred_func(void)
deferred_call_count++;
}
-static int test_init(void)
+static int test_init_hook(void)
{
TEST_ASSERT(init_hook_count == 1);
return EC_SUCCESS;
@@ -133,7 +133,7 @@ void run_test(void)
{
test_reset();
- RUN_TEST(test_init);
+ RUN_TEST(test_init_hook);
RUN_TEST(test_ticks);
RUN_TEST(test_priority);
RUN_TEST(test_deferred);
diff --git a/test/kb_scan.c b/test/kb_scan.c
index 79dcd79576..a273a20466 100644
--- a/test/kb_scan.c
+++ b/test/kb_scan.c
@@ -13,6 +13,7 @@
#include "keyboard_raw.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
+#include "system.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -340,7 +341,34 @@ static int lid_test(void)
}
#endif
-void run_test(void)
+static int test_check_boot_esc(void)
+{
+ TEST_CHECK(keyboard_scan_get_boot_key() == BOOT_KEY_ESC);
+}
+
+static int test_check_boot_down(void)
+{
+ TEST_CHECK(keyboard_scan_get_boot_key() == BOOT_KEY_DOWN_ARROW);
+}
+
+void test_init(void)
+{
+ uint32_t state = system_get_scratchpad();
+
+ if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) {
+ /* Power-F3-ESC */
+ system_set_reset_flags(system_get_reset_flags() |
+ RESET_FLAG_RESET_PIN);
+ mock_key(1, 1, 1);
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3)) {
+ /* Power-F3-Down */
+ system_set_reset_flags(system_get_reset_flags() |
+ RESET_FLAG_RESET_PIN);
+ mock_key(6, 11, 1);
+ }
+}
+
+static void run_test_step1(void)
{
lid_open = 1;
test_reset();
@@ -355,5 +383,56 @@ void run_test(void)
RUN_TEST(lid_test);
#endif
- test_print_result();
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_2);
+}
+
+static void run_test_step2(void)
+{
+ lid_open = 1;
+ test_reset();
+
+ RUN_TEST(test_check_boot_esc);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_3);
+}
+
+static void run_test_step3(void)
+{
+ lid_open = 1;
+ test_reset();
+
+ RUN_TEST(test_check_boot_down);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_PASSED);
+}
+
+void test_run_step(uint32_t state)
+{
+ if (state & TEST_STATE_MASK(TEST_STATE_STEP_1))
+ run_test_step1();
+ else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2))
+ run_test_step2();
+ else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3))
+ run_test_step3();
+}
+
+int test_task(void *data)
+{
+ test_run_multistep();
+ return EC_SUCCESS;
+}
+
+void run_test(void)
+{
+ msleep(30); /* Wait for TASK_ID_TEST to initialize */
+ task_wake(TASK_ID_TEST);
}
diff --git a/test/kb_scan.tasklist b/test/kb_scan.tasklist
index 2368d7bc52..85aee504fa 100644
--- a/test/kb_scan.tasklist
+++ b/test/kb_scan.tasklist
@@ -16,4 +16,5 @@
*/
#define CONFIG_TEST_TASK_LIST \
TASK_TEST(KEYSCAN, keyboard_scan_task, NULL, 256) \
- TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE)
+ TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \
+ TASK_TEST(TEST, test_task, NULL, TASK_STACK_SIZE)