diff options
Diffstat (limited to 'test/fpsensor.c')
-rw-r--r-- | test/fpsensor.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/test/fpsensor.c b/test/fpsensor.c index 81441295ae..490c903ba3 100644 --- a/test/fpsensor.c +++ b/test/fpsensor.c @@ -603,6 +603,21 @@ test_static int test_fp_set_sensor_mode(void) return EC_SUCCESS; } +static int test_enable_positive_match_secret_once( + struct positive_match_secret_state *dumb_state) +{ + const int8_t kIndexToEnable = 0; + timestamp_t now = get_time(); + + TEST_ASSERT(fp_enable_positive_match_secret( + kIndexToEnable, dumb_state) == EC_SUCCESS); + TEST_ASSERT(dumb_state->template_matched == kIndexToEnable); + TEST_ASSERT(dumb_state->readable); + TEST_ASSERT(dumb_state->deadline.val == now.val + (5 * SECOND)); + + return EC_SUCCESS; +} + test_static int test_enable_positive_match_secret(void) { struct positive_match_secret_state dumb_state = { @@ -610,19 +625,15 @@ test_static int test_enable_positive_match_secret(void) .readable = false, .deadline.val = 0, }; - timestamp_t now = get_time(); - TEST_ASSERT(fp_enable_positive_match_secret(0, &dumb_state) == - EC_SUCCESS); - TEST_ASSERT(dumb_state.template_matched == 0); - TEST_ASSERT(dumb_state.readable == true); - TEST_ASSERT(dumb_state.deadline.val == now.val + (5 * SECOND)); + TEST_ASSERT(test_enable_positive_match_secret_once(&dumb_state) + == EC_SUCCESS); /* Trying to enable again before reading secret should fail. */ TEST_ASSERT(fp_enable_positive_match_secret(0, &dumb_state) == EC_ERROR_UNKNOWN); TEST_ASSERT(dumb_state.template_matched == FP_NO_SUCH_TEMPLATE); - TEST_ASSERT(dumb_state.readable == false); + TEST_ASSERT(!dumb_state.readable); TEST_ASSERT(dumb_state.deadline.val == 0); return EC_SUCCESS; @@ -630,13 +641,18 @@ test_static int test_enable_positive_match_secret(void) test_static int test_disable_positive_match_secret(void) { - struct positive_match_secret_state dumb_state; + struct positive_match_secret_state dumb_state = { + .template_matched = FP_NO_SUCH_TEMPLATE, + .readable = false, + .deadline.val = 0, + }; + + TEST_ASSERT(test_enable_positive_match_secret_once(&dumb_state) + == EC_SUCCESS); - TEST_ASSERT(fp_enable_positive_match_secret(0, &dumb_state) == - EC_SUCCESS); fp_disable_positive_match_secret(&dumb_state); TEST_ASSERT(dumb_state.template_matched == FP_NO_SUCH_TEMPLATE); - TEST_ASSERT(dumb_state.readable == false); + TEST_ASSERT(!dumb_state.readable); TEST_ASSERT(dumb_state.deadline.val == 0); return EC_SUCCESS; |