diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-02 00:37:07 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-07 09:09:50 -0700 |
commit | 0a45fa17086d4556b7cb4ea0a9f53894197bc897 (patch) | |
tree | f2363f2a2320000404125bb36225e1420929d45d /test | |
parent | b02c7b461740c457c6904a5d9d9f445afaa849cb (diff) | |
download | chrome-ec-0a45fa17086d4556b7cb4ea0a9f53894197bc897.tar.gz |
Pthread-based emulator for unit testingstabilize-4100.38.B
This is the first version of pthread-based RTOS emulator. With this, we
will be able to test high-level modules entirely on the host machine.
BUG=chrome-os-partner:19325
TEST='make runtests' and see tests passing.
BRANCH=None
Change-Id: I1f5fcd76aa84bdb46c7d35c5e60ae5d92fd3a319
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49954
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/build.mk | 3 | ||||
-rw-r--r-- | test/kb_scan.c | 15 | ||||
-rw-r--r-- | test/mutex.c | 7 | ||||
-rw-r--r-- | test/pingpong.c | 7 | ||||
-rw-r--r-- | test/timer_dos.c | 7 | ||||
-rw-r--r-- | test/utils.c | 17 |
6 files changed, 40 insertions, 16 deletions
diff --git a/test/build.mk b/test/build.mk index 7adf96f441..2c61e80e7d 100644 --- a/test/build.mk +++ b/test/build.mk @@ -24,6 +24,9 @@ test-list-$(BOARD_spring)+=kb_scan flash stress test-list-$(BOARD_link)= test-list-$(BOARD_slippy)= +# Emulator tests +test-list-host=mutex pingpong utils kb_scan + flash-y=flash.o kb_mkbp-y=kb_mkbp.o kb_scan-y=kb_scan.o diff --git a/test/kb_scan.c b/test/kb_scan.c index 32822d689d..c242c43e09 100644 --- a/test/kb_scan.c +++ b/test/kb_scan.c @@ -257,7 +257,7 @@ int lid_test(void) } #endif -static int command_run_test(int argc, char **argv) +void run_test(void) { error_count = 0; lid_open = 1; @@ -268,13 +268,16 @@ static int command_run_test(int argc, char **argv) RUN_TEST(lid_test); #endif - if (error_count == 0) { + if (error_count == 0) ccprintf("Pass!\n"); - return EC_SUCCESS; - } else { + else ccprintf("Fail!\n"); - return EC_ERROR_UNKNOWN; - } +} + +static int command_run_test(int argc, char **argv) +{ + run_test(); + return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(runtest, command_run_test, NULL, NULL, NULL); diff --git a/test/mutex.c b/test/mutex.c index 47f7fa97c4..bc20062d89 100644 --- a/test/mutex.c +++ b/test/mutex.c @@ -114,9 +114,14 @@ int mutex_main_task(void *unused) return EC_SUCCESS; } -static int command_run_test(int argc, char **argv) +void run_test(void) { task_wake(TASK_ID_MTX1); +} + +static int command_run_test(int argc, char **argv) +{ + run_test(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(runtest, command_run_test, diff --git a/test/pingpong.c b/test/pingpong.c index f9266da26e..4cf5d53ced 100644 --- a/test/pingpong.c +++ b/test/pingpong.c @@ -58,10 +58,15 @@ int TaskTick(void *data) return EC_SUCCESS; } -static int command_run_test(int argc, char **argv) +void run_test(void) { task_wake(TASK_ID_TICK); task_wake(TASK_ID_TESTA); +} + +static int command_run_test(int argc, char **argv) +{ + run_test(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(runtest, command_run_test, diff --git a/test/timer_dos.c b/test/timer_dos.c index 5ac7cad5df..327206e6df 100644 --- a/test/timer_dos.c +++ b/test/timer_dos.c @@ -46,12 +46,17 @@ int TaskTimer(void *seed) return EC_SUCCESS; } -static int command_run_test(int argc, char **argv) +void run_test(void) { task_wake(TASK_ID_TMRD); task_wake(TASK_ID_TMRC); task_wake(TASK_ID_TMRB); task_wake(TASK_ID_TMRA); +} + +static int command_run_test(int argc, char **argv) +{ + run_test(); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(runtest, command_run_test, diff --git a/test/utils.c b/test/utils.c index 1c04c0d06d..559e8a0d94 100644 --- a/test/utils.c +++ b/test/utils.c @@ -89,7 +89,7 @@ static int test_shared_mem(void) for (i = 0; i < 256; ++i) { memset(mem, i, sz); for (j = 0; j < sz; ++j) - TEST_ASSERT(mem[j] == i); + TEST_ASSERT(mem[j] == (char)i); if ((i & 0xf) == 0) msleep(20); /* Yield to other tasks */ @@ -100,7 +100,7 @@ static int test_shared_mem(void) return EC_SUCCESS; } -static int command_run_test(int argc, char **argv) +void run_test(void) { error_count = 0; @@ -111,13 +111,16 @@ static int command_run_test(int argc, char **argv) RUN_TEST(test_uint64divmod); RUN_TEST(test_shared_mem); - if (error_count) { + if (error_count) ccprintf("Failed %d tests!\n", error_count); - return EC_ERROR_UNKNOWN; - } else { + else ccprintf("Pass!\n"); - return EC_SUCCESS; - } +} + +static int command_run_test(int argc, char **argv) +{ + run_test(); + return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(runtest, command_run_test, NULL, NULL, NULL); |