summaryrefslogtreecommitdiff
path: root/test/lid_sw.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-09 07:16:01 +0800
committerChromeBot <chrome-bot@google.com>2013-05-08 18:11:01 -0700
commite71f008388b3c69cf01a534c5084d7e3a441149b (patch)
treec68a0ba7443eef434ca3799ae85b4207ccfbc68c /test/lid_sw.c
parent4f463ebc46463d397e8a4c5296ad2168ce881bde (diff)
downloadchrome-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/lid_sw.c')
-rw-r--r--test/lid_sw.c36
1 files changed, 3 insertions, 33 deletions
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);