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>
This commit is contained in:
Vic Yang
2013-09-29 10:07:51 +08:00
committed by chrome-internal-fetch
parent c77575ac0d
commit bd74ad1e20

View File

@@ -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();