diff options
author | Vic Yang <victoryang@chromium.org> | 2013-08-30 22:37:42 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-04 20:32:37 +0000 |
commit | 1764246ee90ccac33bc1e9242c030999c9130fbb (patch) | |
tree | 57780f4dc8dccb1ac2aacbfcf8c8638414521cb9 /test/console_edit.c | |
parent | 4bdfc7eb7b427a77b21779933831fd5e66d4772a (diff) | |
download | chrome-ec-1764246ee90ccac33bc1e9242c030999c9130fbb.tar.gz |
Add unit test for 'chan' command
Command 'chan' is used by servod. Let's add an unit test for it.
BUG=chrome-os-partner:19236
TEST=Pass console_edit test
BRANCH=None
Change-Id: If86e052fa6720d952a8d9fe8745432dc4a458869
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167614
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test/console_edit.c')
-rw-r--r-- | test/console_edit.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/test/console_edit.c b/test/console_edit.c index 5b4cc7944c..945e98b453 100644 --- a/test/console_edit.c +++ b/test/console_edit.c @@ -81,9 +81,11 @@ static int compare_multiline_string(const char *s1, const char *s2) ++s2; if (*s1 != *s2) return 1; + if (*s1 == 0 && *s2 == 0) + break; ++s1; ++s2; - } while (*s1 || *s2); + } while (1); return 0; } @@ -245,6 +247,32 @@ static int test_history_list(void) return EC_SUCCESS; } +static int test_output_channel(void) +{ + UART_INJECT("chan save\n"); + msleep(30); + UART_INJECT("chan 0\n"); + msleep(30); + test_capture_console(1); + cprintf(CC_CHARGER, "shouldn't see this\n"); + cputs(CC_CHIPSET, "shouldn't see this either\n"); + cflush(); + test_capture_console(0); + TEST_ASSERT(compare_multiline_string(test_get_captured_console(), + "") == 0); + UART_INJECT("chan restore\n"); + msleep(30); + test_capture_console(1); + cprintf(CC_CHARGER, "see me\n"); + cputs(CC_CHIPSET, "me as well\n"); + cflush(); + test_capture_console(0); + TEST_ASSERT(compare_multiline_string(test_get_captured_console(), + "see me\nme as well\n") == 0); + + return EC_SUCCESS; +} + void run_test(void) { test_reset(); @@ -261,6 +289,7 @@ void run_test(void) RUN_TEST(test_history_edit); RUN_TEST(test_history_stash); RUN_TEST(test_history_list); + RUN_TEST(test_output_channel); test_print_result(); } |