test-fuzz-targets.t
74 lines
| 2.1 KiB
| text/troff
|
Tads3Lexer
/ tests / test-fuzz-targets.t
Augie Fackler
|
r46883 | #require test-repo py3 | ||
Yuya Nishihara
|
r38238 | |||
Augie Fackler
|
r35688 | $ cd $TESTDIR/../contrib/fuzz | ||
Augie Fackler
|
r44267 | $ OUT=$TESTTMP ; export OUT | ||
Yuya Nishihara
|
r38238 | |||
Augie Fackler
|
r40799 | which(1) could exit nonzero, but that's fine because we'll still end | ||
up without a valid executable, so we don't need to check $? here. | ||||
$ if which gmake >/dev/null 2>&1; then | ||||
> MAKE=gmake | ||||
> else | ||||
> MAKE=make | ||||
> fi | ||||
Augie Fackler
|
r40800 | $ havefuzz() { | ||
> cat > $TESTTMP/dummy.cc <<EOF | ||||
> #include <stdlib.h> | ||||
> #include <stdint.h> | ||||
> int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } | ||||
> int main(int argc, char **argv) { | ||||
> const char data[] = "asdf"; | ||||
> return LLVMFuzzerTestOneInput((const uint8_t *)data, 4); | ||||
> } | ||||
> EOF | ||||
> $CXX $TESTTMP/dummy.cc -o $TESTTMP/dummy \ | ||||
> -fsanitize=fuzzer-no-link,address || return 1 | ||||
> } | ||||
Augie Fackler
|
r46883 | Try to find a python3-config that's next to our sys.executable. If | ||
that doesn't work, fall back to looking for a global python3-config | ||||
and hope that works out for the best. | ||||
Matt Harbison
|
r47858 | $ PYBIN=`"$PYTHON" -c 'import sys, os; print(os.path.dirname(sys.executable))'` | ||
Augie Fackler
|
r46883 | $ if [ -x "$PYBIN/python3-config" ] ; then | ||
> PYTHON_CONFIG="$PYBIN/python3-config" | ||||
> else | ||||
> PYTHON_CONFIG="`which python3-config`" | ||||
> fi | ||||
Yuya Nishihara
|
r38238 | #if clang-libfuzzer | ||
Augie Fackler
|
r40800 | $ CXX=clang++ havefuzz || exit 80 | ||
Augie Fackler
|
r46883 | $ $MAKE -s clean all PYTHON_CONFIG="$PYTHON_CONFIG" | ||
Yuya Nishihara
|
r38238 | #endif | ||
#if no-clang-libfuzzer clang-6.0 | ||||
Augie Fackler
|
r40800 | $ CXX=clang++-6.0 havefuzz || exit 80 | ||
Augie Fackler
|
r46883 | $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0 PYTHON_CONFIG="$PYTHON_CONFIG" | ||
Yuya Nishihara
|
r38238 | #endif | ||
#if no-clang-libfuzzer no-clang-6.0 | ||||
$ exit 80 | ||||
#endif | ||||
Augie Fackler
|
r44267 | $ cd $TESTTMP | ||
Run each fuzzer using dummy.cc as a fake input, to make sure it runs | ||||
at all. In the future we should instead unpack the corpus for each | ||||
fuzzer and use that instead. | ||||
$ for fuzzer in `ls *_fuzzer | sort` ; do | ||||
> echo run $fuzzer... | ||||
> ./$fuzzer dummy.cc > /dev/null 2>&1 | ||||
> done | ||||
run bdiff_fuzzer... | ||||
run dirs_fuzzer... | ||||
run dirstate_fuzzer... | ||||
run fm1readmarkers_fuzzer... | ||||
run fncache_fuzzer... | ||||
run jsonescapeu8fast_fuzzer... | ||||
run manifest_fuzzer... | ||||
run mpatch_fuzzer... | ||||
run revlog_fuzzer... | ||||
run xdiff_fuzzer... | ||||
Augie Fackler
|
r43218 | |||
Clean up. | ||||
Augie Fackler
|
r44267 | $ cd $TESTDIR/../contrib/fuzz | ||
Augie Fackler
|
r43218 | $ $MAKE -s clean | ||