aklomp / base64

Fast Base64 stream encoder/decoder in C99, with SIMD acceleration
BSD 2-Clause "Simplified" License
865 stars 162 forks source link

Adds a roundtrip fuzz testing suite #119

Open silvergasp opened 1 year ago

silvergasp commented 1 year ago

This PR adds two fuzz testing harnesses to ensure roundtrip e.g. encode->decode reproduces the same input always. Decode only, this will take an arbitrary input and try and decode to ensure that the decoder can handle invalid inputs successfully.

How to test this out locally;

cd test
# Set clang as compiler (required)
export CC=clang
# Add sanitisation flags (required)
export CFLAGS=-fsanitize=fuzzer-no-link,address
# Build fuzzers
 AVX2_CFLAGS=-mavx2 SSSE3_CFLAGS=-mssse3 SSE41_CFLAGS=-msse4.1 SSE42_CFLAGS=-msse4.2 AVX_CFLAGS=-mavx make fuzz_roundtrip fuzz_decode fuzz_roundtrip
# Run a fuzzer
fuzz_roundtrip

You should expect the fuzzer to run forever or until;