summaryrefslogtreecommitdiff
path: root/test/test_config.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-06-20 14:21:43 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-16 00:30:08 -0700
commit4a4e2c71a0f6aaa50e0728922f84a7d54c14380a (patch)
tree4bbc05387f7b479bc4a3dcb925174676f03d9356 /test/test_config.h
parent165ee29673b058ba5f4550d5b6e1dfecb179bb22 (diff)
downloadchrome-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 'test/test_config.h')
-rw-r--r--test/test_config.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_config.h b/test/test_config.h
index 76e071b556..8efe426e38 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -294,5 +294,23 @@ enum nvmem_vars {
#define CONFIG_CURVE25519
#endif /* TEST_X25519 */
+#ifdef TEST_FUZZ
+/* Disable hibernate: We never want to exit while fuzzing. */
+#undef CONFIG_HIBERNATE
+#endif
+
+#ifdef TEST_HOST_COMMAND_FUZZ
+#undef CONFIG_HOSTCMD_DEBUG_MODE
+
+/* Defining this make fuzzing slower, but exercises additional code paths. */
+#define FUZZ_HOSTCMD_VERBOSE
+
+#ifdef FUZZ_HOSTCMD_VERBOSE
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_PARAMS
+#else
+#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
+#endif /* ! FUZZ_HOSTCMD_VERBOSE */
+#endif /* TEST_HOST_COMMAND_FUZZ */
+
#endif /* TEST_BUILD */
#endif /* __TEST_TEST_CONFIG_H */