Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,13 @@ install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND OJPH_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

################################################################################################
# Testing and fuzzing (OJPH_BUILD_FUZZER)
################################################################################################

if(OJPH_BUILD_FUZZER)
add_subdirectory(fuzzing)
endif()

14 changes: 6 additions & 8 deletions docs/fuzzing.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Fuzzer Target #

Fuzzer targets can be build using the `OJPH_BUILD_FUZZER` build option. The Dockerfile in the `fuzzing directory` allows local testing:
Fuzzer targets intended for use with [oss-fuzz](https://oss-fuzz.com/) can be build using the `OJPH_BUILD_FUZZER` build option.

The targets can be run locally as follows:

```sh
podman build -t openjph-fuzz -f fuzzing/Dockerfile
podman run -it --rm -v $(pwd):/app/ojph/ openjph-fuzz bash
image# mkdir /app/build/
image# cd /app/build/
image# cmake /app/ojph -DCMAKE_CXX_FLAGS="-fsanitize=fuzzer,address" -DOJPH_BUILD_FUZZER=ON -DBUILD_SHARED_LIBS=OFF
image# make
image# ./fuzzing/ojph_expand_fuzz_target /app/jp2k_test_codestreams/openjph/*.j2c
cd build
cmake .. -DOJPH_BUILD_FUZZER=ON
./fuzzing/ojph_expand_fuzz_target <test case>
```
3 changes: 3 additions & 0 deletions fuzzing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# detect whether we are within the oss fuzz environment
if(DEFINED ENV{LIB_FUZZING_ENGINE})
# if yes, we can link against the main function of the fuzzing engine
link_libraries($ENV{LIB_FUZZING_ENGINE})
else()
# if not, we need to define our main function
add_compile_definitions(OJPH_FUZZ_TARGET_MAIN)
endif()

Expand Down
8 changes: 0 additions & 8 deletions fuzzing/Dockerfile

This file was deleted.

Loading