diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-09 07:16:01 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-08 18:11:01 -0700 |
commit | e71f008388b3c69cf01a534c5084d7e3a441149b (patch) | |
tree | c68a0ba7443eef434ca3799ae85b4207ccfbc68c /test/kb_mkbp.c | |
parent | 4f463ebc46463d397e8a4c5296ad2168ce881bde (diff) | |
download | chrome-ec-e71f008388b3c69cf01a534c5084d7e3a441149b.tar.gz |
Put test utility macros in header
Several test utility macros have been duplicated across tests. Let's put
them in a single place.
BUG=chrome-os-partner:19236
TEST='make runtests', 'BOARD=spring make tests'
BRANCH=None
Change-Id: Ib0c9f829715425cc23e33b8ef456b17dfadab13c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50513
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'test/kb_mkbp.c')
-rw-r--r-- | test/kb_mkbp.c | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/test/kb_mkbp.c b/test/kb_mkbp.c index a8e57bfe57..fc7a9255de 100644 --- a/test/kb_mkbp.c +++ b/test/kb_mkbp.c @@ -13,10 +13,9 @@ #include "keyboard_mkbp.h" #include "keyboard_protocol.h" #include "keyboard_scan.h" +#include "test_util.h" #include "util.h" -static int error_count; - static uint8_t state[KEYBOARD_COLS]; static int ec_int_level; @@ -44,24 +43,6 @@ int lid_is_open(void) /*****************************************************************************/ /* Test utilities */ -#define RUN_TEST(n) \ - do { \ - ccprintf("Running %s...", #n); \ - cflush(); \ - if (n() == EC_SUCCESS) { \ - ccputs("OK\n"); \ - } else { \ - ccputs("Fail\n"); \ - error_count++; \ - } \ - } while (0) - -#define TEST_ASSERT(n) \ - do { \ - if (!(n)) \ - return EC_ERROR_UNKNOWN; \ - } while (0) - #define FIFO_EMPTY() (ec_int_level == 1) #define FIFO_NOT_EMPTY() (ec_int_level == 0) @@ -227,24 +208,13 @@ int fifo_underrun(void) void run_test(void) { - error_count = 0; ec_int_level = 1; + test_reset(); RUN_TEST(single_key_press); RUN_TEST(test_fifo_size); RUN_TEST(test_enable); RUN_TEST(fifo_underrun); - if (error_count == 0) - ccprintf("Pass!\n"); - else - ccprintf("Fail!\n"); -} - -static int command_run_test(int argc, char **argv) -{ - run_test(); - return EC_SUCCESS; + test_print_result(); } -DECLARE_CONSOLE_COMMAND(runtest, command_run_test, - NULL, NULL, NULL); |