Skip to content

Commit

Permalink
review comment: condiionally include main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldreik committed Jun 17, 2019
1 parent be0bdae commit 7683d7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 5 additions & 6 deletions test/fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ sprintf.cpp
two_args.cpp
)

if(FMT_FUZZ_LINKMAIN)
add_definitions(-DFMT_FUZZ_IMPLEMENT_MAIN=1)
endif()

macro(implement_fuzzer sourcefile)
get_filename_component(basename ${sourcefile} NAME_WE)
set(name fuzzer_${basename})
add_executable(${name} ${sourcefile} fuzzer_common.h main.cpp)
target_link_libraries(${name} PRIVATE fmt)
add_executable(${name} ${sourcefile} fuzzer_common.h)
if(FMT_FUZZ_LINKMAIN)
target_sources(${name} PRIVATE main.cpp)
endif()
target_link_libraries(${name} PRIVATE fmt)
if(FMT_FUZZ_LDFLAGS)
target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS})
endif()
Expand Down
12 changes: 5 additions & 7 deletions test/fuzzing/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// if an int main() is needed.
#if FMT_FUZZ_IMPLEMENT_MAIN
# include <cassert>
# include <fstream>
# include <sstream>
# include <vector>
#include <cassert>
#include <fstream>
#include <sstream>
#include <vector>
#include "fuzzer_common.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, std::size_t Size);
int main(int argc, char* argv[]) {
for (int i = 1; i < argc; ++i) {
Expand All @@ -20,4 +19,3 @@ int main(int argc, char* argv[]) {
LLVMFuzzerTestOneInput(fmt_fuzzer::as_bytes(buf.data()), buf.size());
}
}
#endif

0 comments on commit 7683d7f

Please sign in to comment.