git repos / blockattack-game

blame: source/misc/embedded_libs/fmt-8.1.1/test/fuzzing/README.md

normal view · raw

f8deb5b9 Poul Sander 2022-01-15 13:55 1
# Running the fuzzers locally
f8deb5b9 Poul Sander 2022-01-15 13:55 2
f8deb5b9 Poul Sander 2022-01-15 13:55 3
There is a [helper script](build.sh) to build the fuzzers, which has only been
f8deb5b9 Poul Sander 2022-01-15 13:55 4
tested on Debian and Ubuntu linux so far. There should be no problems fuzzing on
f8deb5b9 Poul Sander 2022-01-15 13:55 5
Windows (using clang>=8) or on Mac, but the script will probably not work out of
f8deb5b9 Poul Sander 2022-01-15 13:55 6
the box.
f8deb5b9 Poul Sander 2022-01-15 13:55 7
f8deb5b9 Poul Sander 2022-01-15 13:55 8
Something along
f8deb5b9 Poul Sander 2022-01-15 13:55 9
```sh
f8deb5b9 Poul Sander 2022-01-15 13:55 10
mkdir build
f8deb5b9 Poul Sander 2022-01-15 13:55 11
cd build
f8deb5b9 Poul Sander 2022-01-15 13:55 12
export CXX=clang++
f8deb5b9 Poul Sander 2022-01-15 13:55 13
export CXXFLAGS="-fsanitize=fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION= -g"
f8deb5b9 Poul Sander 2022-01-15 13:55 14
cmake .. -DFMT_SAFE_DURATION_CAST=On -DFMT_FUZZ=On -DFMT_FUZZ_LINKMAIN=Off -DFMT_FUZZ_LDFLAGS="-fsanitize=fuzzer"
f8deb5b9 Poul Sander 2022-01-15 13:55 15
cmake --build .
f8deb5b9 Poul Sander 2022-01-15 13:55 16
```
f8deb5b9 Poul Sander 2022-01-15 13:55 17
should work to build the fuzzers for all platforms which clang supports.
f8deb5b9 Poul Sander 2022-01-15 13:55 18
f8deb5b9 Poul Sander 2022-01-15 13:55 19
Execute a fuzzer with for instance
f8deb5b9 Poul Sander 2022-01-15 13:55 20
```sh
f8deb5b9 Poul Sander 2022-01-15 13:55 21
cd build
f8deb5b9 Poul Sander 2022-01-15 13:55 22
export UBSAN_OPTIONS=halt_on_error=1
f8deb5b9 Poul Sander 2022-01-15 13:55 23
mkdir out_chrono
f8deb5b9 Poul Sander 2022-01-15 13:55 24
bin/fuzzer_chrono_duration out_chrono
f8deb5b9 Poul Sander 2022-01-15 13:55 25
```
1970-01-01 00:00 26