Skip to content

Commit

Permalink
CMake: build fuzzers in standalone mode as part of BUILD_TESTING
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jun 17, 2023
1 parent 7e10ddc commit 718a528
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ proj_add_gie_test("GIGS-5208" "gigs/5208.gie")
add_subdirectory(cli)
add_subdirectory(unit)
add_subdirectory(benchmark)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fuzzers")
add_subdirectory(fuzzers)
endif()


3 changes: 3 additions & 0 deletions test/fuzzers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(proj_crs_to_crs_fuzzer proj_crs_to_crs_fuzzer.cpp)
target_compile_definitions(proj_crs_to_crs_fuzzer PRIVATE -DSTANDALONE)
target_link_libraries(proj_crs_to_crs_fuzzer PRIVATE ${PROJ_LIBRARIES})
11 changes: 5 additions & 6 deletions test/fuzzers/README.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ and call scripts in this directory.
The list of issues is in:
https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj4

- Build standard_fuzzer in a standalone mode:

$ g++ -g -std=c++11 standard_fuzzer.cpp -o standard_fuzzer -fvisibility=hidden -DSTANDALONE ../../build/lib/libproj.a -lpthread -lsqlite3 -I../../src -I../../include
- Build proj_crs_to_crs_fuzzer in a standalone mode with the
-DBUILD_TESTING=ON CMake options

Run it:
$ PROJ_DATA=../../data ./standard_fuzzer {file_generated_by_oss_fuzz}
$ bin/proj_crs_to_crs_fuzzer {file_generated_by_oss_fuzz}

- Run locally OSS Fuzz:
$ git clone https://github.com/google/oss-fuzz.git
Expand All @@ -24,8 +23,8 @@ https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj4
Build fuzzers with the address sanitizer (could use undefined, etc...)
$ python infra/helper.py build_fuzzers --sanitizer address $PROJECT_NAME

Test a particular fuzzer (replace standard_fuzzer by other fuzzers)
$ python infra/helper.py run_fuzzer $PROJECT_NAME standard_fuzzer
Test a particular fuzzer (replace proj_crs_to_crs_fuzzer by other fuzzers)
$ python infra/helper.py run_fuzzer $PROJECT_NAME proj_crs_to_crs_fuzzer


How to deal with issues reported in https://bugs.chromium.org/p/oss-fuzz/issues/list?q=proj4 ?
Expand Down

0 comments on commit 718a528

Please sign in to comment.