diff options
author | Firas Sammoura <fsammoura@google.com> | 2022-09-02 21:12:19 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-12 17:25:12 +0000 |
commit | b5c0f7c078c94caa75e0303d797b0ec3e589455f (patch) | |
tree | 6ad3393b799687ba96cbb07307223dd8b973809d /test/fpsensor_state.c | |
parent | 758c32cb93264f371a945efe5a2d036851202af5 (diff) | |
download | chrome-ec-b5c0f7c078c94caa75e0303d797b0ec3e589455f.tar.gz |
test: Add test for read_match_secret resp error
Add a test for fp_command_read_match_secret when the number of matched
finger is within the allowed range of [0 5[, the state deadline value is
valid, the state is readable with the correct matched finger number, and
and a trivial positive_match_salt. The test should fail with the error
message EC_RES_ERROR.
Add a trivial mock value for the positive_match_salt and a default fake
value for the positive_match_salt in the fpsensor_state_mock library.
BRANCH=None
BUG=b:242720387
TEST=make run-fpsensor_state
TEST=make runhosttests
Signed-off-by: Firas Sammoura <fsammoura@google.com>
Change-Id: I9af4cb13a1b6f63049205cad9684050d5eb1f885
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872553
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Diffstat (limited to 'test/fpsensor_state.c')
-rw-r--r-- | test/fpsensor_state.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/fpsensor_state.c b/test/fpsensor_state.c index 78958fd77c..75a72d6afe 100644 --- a/test/fpsensor_state.c +++ b/test/fpsensor_state.c @@ -298,6 +298,37 @@ test_static int test_fp_command_read_match_secret_unreadable_state(void) return EC_SUCCESS; } +test_static int test_fp_command_read_match_secret_derive_fail(void) +{ + struct ec_response_fp_read_match_secret response = { 0 }; + /* Create valid param with 0 <= fgr < 5 */ + uint16_t matched_fgr = 1; + struct ec_params_fp_read_match_secret test_match_secret_1 = { + .fgr = matched_fgr, + }; + /* Create positive secret match state with valid deadline value, + * readable state, and correct template matched + */ + struct positive_match_secret_state test_state_1 = { + .deadline.val = 5000000, + .readable = true, + .template_matched = matched_fgr, + }; + positive_match_secret_state = test_state_1; + /* Set fp_positive_match_salt to the trivial value */ + memcpy(fp_positive_match_salt, trivial_fp_positive_match_salt, + sizeof(trivial_fp_positive_match_salt)); + + /* Test with the correct matched finger state and a trivial + * fp_positive_match_salt + */ + TEST_ASSERT(test_send_host_command( + EC_CMD_FP_READ_MATCH_SECRET, 0, + &test_match_secret_1, sizeof(test_match_secret_1), + &response, sizeof(response)) == EC_RES_ERROR); + return EC_SUCCESS; +} + void run_test(int argc, const char **argv) { RUN_TEST(test_fp_enc_status_valid_flags); @@ -311,5 +342,6 @@ void run_test(int argc, const char **argv) RUN_TEST(test_fp_command_read_match_secret_fail_timeout); RUN_TEST(test_fp_command_read_match_secret_unmatched_fgr); RUN_TEST(test_fp_command_read_match_secret_unreadable_state); + RUN_TEST(test_fp_command_read_match_secret_derive_fail); test_print_result(); } |