diff options
author | Vic Yang <victoryang@chromium.org> | 2013-09-02 13:55:02 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-05 07:20:56 +0000 |
commit | b448746bace6d021343bfec615d1cf98f7be17bb (patch) | |
tree | 839a25cfa03d6114a225d88fa324fe2b51598cda /test/kb_scan.c | |
parent | 6c3be20539a3b336e2c1c83181ea6f9b0c1506d2 (diff) | |
download | chrome-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/kb_scan.c')
-rw-r--r-- | test/kb_scan.c | 83 |
1 files changed, 81 insertions, 2 deletions
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); } |