From e71f008388b3c69cf01a534c5084d7e3a441149b Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Thu, 9 May 2013 07:16:01 +0800 Subject: 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 Reviewed-on: https://gerrit.chromium.org/gerrit/50513 Reviewed-by: Vincent Palatin --- test/lid_sw.c | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'test/lid_sw.c') diff --git a/test/lid_sw.c b/test/lid_sw.c index 4993147dcb..cf04d91efb 100644 --- a/test/lid_sw.c +++ b/test/lid_sw.c @@ -10,32 +10,13 @@ #include "hooks.h" #include "host_command.h" #include "lid_switch.h" +#include "test_util.h" #include "timer.h" #include "util.h" -static int error_count; - static int mock_lid; static int lid_hook_count; -#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) - int gpio_get_level(enum gpio_signal signal) { if (signal == GPIO_LID_OPEN) @@ -107,21 +88,10 @@ static int test_debounce(void) void run_test(void) { - error_count = 0; + test_reset(); RUN_TEST(test_hook); RUN_TEST(test_debounce); - if (error_count) - ccprintf("Fail!\n", error_count); - else - ccprintf("Pass!\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); -- cgit v1.2.1