diff options
author | Vic Yang <victoryang@chromium.org> | 2013-09-29 10:07:51 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-01 08:16:38 +0000 |
commit | bd74ad1e2008e31754718ecc1882a6ac98dbb11e (patch) | |
tree | d66b0c2c9fd5b3f8c4996bc19ea60dd1885d4648 /test/host_command.c | |
parent | c77575ac0daa5966772779cedbaab6f607cf9a98 (diff) | |
download | chrome-ec-bd74ad1e2008e31754718ecc1882a6ac98dbb11e.tar.gz |
Test more error cases of host command handling
This adds tests of invalid command version and invalid command.
BUG=chrome-os-partner:19236
TEST=Pass host_command test
BRANCH=None
Change-Id: I49ce1b4c8b31ef98d9ee8203e88adfa521471d6d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170935
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'test/host_command.c')
-rw-r--r-- | test/host_command.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/test/host_command.c b/test/host_command.c index 639b32ed8a..cd8d57413c 100644 --- a/test/host_command.c +++ b/test/host_command.c @@ -119,7 +119,29 @@ static int test_hostcmd_driver_error(void) return EC_SUCCESS; } -static int test_hostcmd_wrong_version(void) +static int test_hostcmd_invalid_command(void) +{ + hostcmd_fill_in_default(); + + req->command = 0xff; + hostcmd_send(); + TEST_ASSERT(resp->result == EC_RES_INVALID_COMMAND); + + return EC_SUCCESS; +} + +static int test_hostcmd_wrong_command_version(void) +{ + hostcmd_fill_in_default(); + + req->command_version = 1; + hostcmd_send(); + TEST_ASSERT(resp->result == EC_RES_INVALID_VERSION); + + return EC_SUCCESS; +} + +static int test_hostcmd_wrong_struct_version(void) { hostcmd_fill_in_default(); @@ -153,7 +175,9 @@ void run_test(void) RUN_TEST(test_hostcmd_too_short); RUN_TEST(test_hostcmd_too_long); RUN_TEST(test_hostcmd_driver_error); - RUN_TEST(test_hostcmd_wrong_version); + RUN_TEST(test_hostcmd_invalid_command); + RUN_TEST(test_hostcmd_wrong_command_version); + RUN_TEST(test_hostcmd_wrong_struct_version); RUN_TEST(test_hostcmd_invalid_checksum); test_print_result(); |