diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-09-17 11:35:33 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-25 18:35:25 +0000 |
commit | 01b7d964e5afe94450548c05ca062c35ac5fdd89 (patch) | |
tree | 16689abd6fcdadcc122adbd024508ea58e28bd2b /test | |
parent | 6b9218bc0a595e3329aa9a805065ce53592e23b3 (diff) | |
download | chrome-ec-01b7d964e5afe94450548c05ca062c35ac5fdd89.tar.gz |
fpsensor: Fix buffer check to account for overflow
BRANCH=none
BUG=b:144957935
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I1b4fa0a715869ccc37e48d75316ef52c367aa64a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2417529
Reviewed-by: Craig Hesling <hesling@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/fpsensor.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/fpsensor.c b/test/fpsensor.c index d7a7cc6988..ff5a9a6c51 100644 --- a/test/fpsensor.c +++ b/test/fpsensor.c @@ -4,9 +4,31 @@ */ #include "test_util.h" +#include "common/fpsensor/fpsensor_private.h" + +test_static int test_validate_fp_buffer_offset_success(void) +{ + TEST_EQ(validate_fp_buffer_offset(1, 0, 1), EC_SUCCESS, "%d"); + return EC_SUCCESS; +} + +test_static int test_validate_fp_buffer_offset_failure_no_overflow(void) +{ + TEST_EQ(validate_fp_buffer_offset(1, 1, 1), EC_ERROR_INVAL, "%d"); + return EC_SUCCESS; +} + +test_static int test_validate_fp_buffer_offset_failure_overflow(void) +{ + TEST_EQ(validate_fp_buffer_offset(1, UINT32_MAX, 1), EC_ERROR_OVERFLOW, + "%d"); + return EC_SUCCESS; +} void run_test(int argc, char **argv) { - /* No tests yet */ + test_validate_fp_buffer_offset_success(); + test_validate_fp_buffer_offset_failure_no_overflow(); + test_validate_fp_buffer_offset_failure_overflow(); test_print_result(); } |