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/utils.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/utils.c')
-rw-r--r-- | test/utils.c | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/test/utils.c b/test/utils.c index 81fe2ef072..1aabbb81d7 100644 --- a/test/utils.c +++ b/test/utils.c @@ -9,37 +9,10 @@ #include "console.h" #include "shared_mem.h" #include "system.h" +#include "test_util.h" #include "timer.h" #include "util.h" -static int error_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) - -#define TEST_CHECK(n) \ - do { \ - if (n) \ - return EC_SUCCESS; \ - else \ - return EC_ERROR_UNKNOWN; \ - } while (0) - static int test_strlen(void) { TEST_CHECK(strlen("this is a string") == 16); @@ -111,7 +84,7 @@ static int test_scratchpad(void) void run_test(void) { - error_count = 0; + test_reset(); RUN_TEST(test_strlen); RUN_TEST(test_strcasecmp); @@ -121,16 +94,5 @@ void run_test(void) RUN_TEST(test_shared_mem); RUN_TEST(test_scratchpad); - if (error_count) - ccprintf("Failed %d tests!\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); |