diff options
author | Firas Sammoura <fsammoura@google.com> | 2022-09-02 04:53:32 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-09 02:18:42 +0000 |
commit | 57b4d955180dbd43f429c7344e30334a4b39c772 (patch) | |
tree | 23057a4347d0e975540c973b8fe588db733389b2 /test | |
parent | a8c145f4ce9fff31441c095f873e87bef0101a3f (diff) | |
download | chrome-ec-57b4d955180dbd43f429c7344e30334a4b39c772.tar.gz |
test: Add tests for read_match_secret fail invalid param
Add tests for fp_command_read_match_secret function when the number of
fgr is outside the allowed limit [0 5[. The test should fail with the
error message EC_RES_INVALID_PARAM.
BRANCH=None
BUG=b:242720387
TEST=make run-fpsensor_state
TEST=make runhosttests
Signed-off-by: Firas Sammoura <fsammoura@google.com>
Change-Id: I578161d489610bacbb6ae223a159a99274bd2710
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3870027
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fpsensor_state.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/fpsensor_state.c b/test/fpsensor_state.c index 66936af7ca..993b692a10 100644 --- a/test/fpsensor_state.c +++ b/test/fpsensor_state.c @@ -186,6 +186,42 @@ test_static int test_fp_set_maintenance_mode(void) return EC_SUCCESS; } +test_static int test_fp_command_read_match_secret_fail_fgr_less_than_zero(void) +{ + /* Create invalid param with fgr < 0 */ + struct ec_params_fp_read_match_secret test_match_secret = { + .fgr = -1, + }; + + /* + * FP_COMMAND_READ_MATCH_SECRET should have if the finger number is < + * 0 + */ + TEST_ASSERT(test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, + &test_match_secret, + sizeof(test_match_secret), NULL, + 0) == EC_RES_INVALID_PARAM); + + return EC_SUCCESS; +} + +test_static int test_fp_command_read_match_secret_fail_fgr_large_than_max(void) +{ + /* Create invalid param with fgr = FP_MAX_FINGER_COUNT */ + struct ec_params_fp_read_match_secret test_match_secret = { + .fgr = FP_MAX_FINGER_COUNT, + }; + /* + * FP_COMMAND_READ_MATCH_SECRET should have if the finger number is < + * 0 + */ + TEST_ASSERT(test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, + &test_match_secret, + sizeof(test_match_secret), NULL, + 0) == EC_RES_INVALID_PARAM); + return EC_SUCCESS; +} + void run_test(int argc, const char **argv) { RUN_TEST(test_fp_enc_status_valid_flags); @@ -194,5 +230,7 @@ void run_test(int argc, const char **argv) RUN_TEST(test_set_fp_tpm_seed_again); RUN_TEST(test_fp_set_sensor_mode); RUN_TEST(test_fp_set_maintenance_mode); + RUN_TEST(test_fp_command_read_match_secret_fail_fgr_less_than_zero); + RUN_TEST(test_fp_command_read_match_secret_fail_fgr_large_than_max); test_print_result(); } |