From 40aace59cc58ca438060cf4dfd97ba01ff4f0ebc Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Thu, 23 Jun 2022 11:38:18 -0400 Subject: [PATCH] [lldb/Fuzzer] Have fuzzers write artifacts to specific directory This makes the LLDB fuzzers write their fuzzer artifacts to their own directory in the build directory. It also adds an artifact prefix to the target fuzzer to make it easier to tell which fuzzer wrote the artifact. Differential revision: https://reviews.llvm.org/D128450 --- .../CMakeLists.txt | 18 +++++++++++------- .../lldb-target-fuzzer/CMakeLists.txt | 7 ++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lldb/tools/lldb-fuzzer/lldb-commandinterpreter-fuzzer/CMakeLists.txt b/lldb/tools/lldb-fuzzer/lldb-commandinterpreter-fuzzer/CMakeLists.txt index 5bfae5b574e9..7eb85ba91670 100644 --- a/lldb/tools/lldb-fuzzer/lldb-commandinterpreter-fuzzer/CMakeLists.txt +++ b/lldb/tools/lldb-fuzzer/lldb-commandinterpreter-fuzzer/CMakeLists.txt @@ -14,15 +14,19 @@ if(TARGET lldb-commandinterpreter-fuzzer) liblldb ) - # This will create a directory specifically for the fuzzer's artifacts, go to that - # directory and run the fuzzer from there. When the fuzzer exits the input - # artifact that caused it to exit will be written to a directory within the - # build directory + # A directory in the build directory is created to hold the fuzzer's + # artifacts as a pre-build command for the command interpreter's executable + # target. When the fuzzer exits the input artifact that caused it to exit + # will be written to this directory. + + add_custom_command(TARGET lldb-commandinterpreter-fuzzer PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/fuzzer-artifacts/commandinterpreter-artifacts + ) + add_custom_target(fuzz-lldb-commandinterpreter COMMENT "Running the LLDB command interpreter fuzzer..." - COMMAND mkdir -p ${CMAKE_BINARY_DIR}/fuzzer-artifacts/commandinterpreter-artifacts && - cd ${CMAKE_BINARY_DIR}/fuzzer-artifacts/commandinterpreter-artifacts - && $ -dict=${CMAKE_CURRENT_SOURCE_DIR}/inputdictionary.txt -only_ascii=1 -artifact_prefix=commandinterpreter- + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/fuzzer-artifacts/commandinterpreter-artifacts + COMMAND $ -dict=${CMAKE_CURRENT_SOURCE_DIR}/inputdictionary.txt -only_ascii=1 -artifact_prefix=commandinterpreter- USES_TERMINAL ) endif() diff --git a/lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt b/lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt index 06df06c07d92..6876945c08da 100644 --- a/lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt +++ b/lldb/tools/lldb-fuzzer/lldb-target-fuzzer/CMakeLists.txt @@ -15,9 +15,14 @@ if(TARGET lldb-target-fuzzer) lldbFuzzerUtils ) + add_custom_command(TARGET lldb-target-fuzzer PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/fuzzer-artifacts/target-artifacts + ) + add_custom_target(fuzz-lldb-target COMMENT "Running the LLDB target fuzzer..." - COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/fuzzer-artifacts/target-artifacts + COMMAND $ -artifact_prefix=target- USES_TERMINAL ) endif()