diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-06-20 14:21:43 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-16 00:30:08 -0700 |
commit | 4a4e2c71a0f6aaa50e0728922f84a7d54c14380a (patch) | |
tree | 4bbc05387f7b479bc4a3dcb925174676f03d9356 /chip/host/system.c | |
parent | 165ee29673b058ba5f4550d5b6e1dfecb179bb22 (diff) | |
download | chrome-ec-4a4e2c71a0f6aaa50e0728922f84a7d54c14380a.tar.gz |
test: host_command_fuzz: fuzzing test
Writing fuzzing tests is a little tricky, as clang takes over the main
function. Instead, we start the test main function in a thread, and
have LLVMFuzzerTestOneInput prepare the host command buffer, and
wake the TEST_RUNNER task.
To make fuzzing faster, we only send somehow correctly formed requests,
with a valid checksum and length (this can be disabled with an option).
We also make sure that the emulator does not hibernate, reboot or jump
to a different image when fuzzing is enabled.
BRANCH=none
BUG=chromium:854975
TEST=make buildfuzztests -j
ASAN_OPTIONS="log_path=stderr" \
build/host/host_command_fuzz/host_command_fuzz.exe -timeout=5
Change-Id: I27b25e44c405f118dfc1296247479245e15e54b4
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1107523
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Jonathan Metzman <metzman@chromium.org>
Diffstat (limited to 'chip/host/system.c')
-rw-r--r-- | chip/host/system.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/chip/host/system.c b/chip/host/system.c index 69ed1c83a1..cc0c307d95 100644 --- a/chip/host/system.c +++ b/chip/host/system.c @@ -173,6 +173,15 @@ test_mockable int system_is_locked(void) return 0; } +#ifdef TEST_FUZZ +/* When fuzzing, do not allow sysjumps. */ +int system_run_image_copy(enum system_image_copy_t copy) +{ + ccprints("Emulator would sysjump here. Fuzzing: doing nothing."); + return EC_ERROR_UNKNOWN; +} +#endif + const char *system_get_chip_vendor(void) { return "chromeos"; |