Debian Codegraph @

tests/test-fuzz-targets.t

raw
1 #require test-repo py3
2
3 $ cd $TESTDIR/../contrib/fuzz
4 $ OUT=$TESTTMP ; export OUT
5
6 which(1) could exit nonzero, but that's fine because we'll still end
7 up without a valid executable, so we don't need to check $? here.
8
9 $ if which gmake >/dev/null 2>&1; then
10 > MAKE=gmake
11 > else
12 > MAKE=make
13 > fi
14
15 $ havefuzz() {
16 > cat > $TESTTMP/dummy.cc <<EOF
17 > #include <stdlib.h>
18 > #include <stdint.h>
19 > int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
20 > int main(int argc, char **argv) {
21 > const char data[] = "asdf";
22 > return LLVMFuzzerTestOneInput((const uint8_t *)data, 4);
23 > }
24 > EOF
25 > $CXX $TESTTMP/dummy.cc -o $TESTTMP/dummy \
26 > -fsanitize=fuzzer-no-link,address || return 1
27 > }
28
29 Try to find a python3-config that's next to our sys.executable. If
30 that doesn't work, fall back to looking for a global python3-config
31 and hope that works out for the best.
32 $ PYBIN=`"$PYTHON" -c 'import sys, os; print(os.path.dirname(sys.executable))'`
33 $ if [ -x "$PYBIN/python3-config" ] ; then
34 > PYTHON_CONFIG="$PYBIN/python3-config"
35 > else
36 > PYTHON_CONFIG="`which python3-config`"
37 > fi
38
39 #if clang-libfuzzer
40 $ CXX=clang++ havefuzz || exit 80
41 $ $MAKE -s clean all PYTHON_CONFIG="$PYTHON_CONFIG"
42 #endif
43 #if no-clang-libfuzzer clang-6.0
44 $ CXX=clang++-6.0 havefuzz || exit 80
45 $ $MAKE -s clean all CC=clang-6.0 CXX=clang++-6.0 PYTHON_CONFIG="$PYTHON_CONFIG"
46 #endif
47 #if no-clang-libfuzzer no-clang-6.0
48 $ exit 80
49 #endif
50
51 $ cd $TESTTMP
52
53 Run each fuzzer using dummy.cc as a fake input, to make sure it runs
54 at all. In the future we should instead unpack the corpus for each
55 fuzzer and use that instead.
56
57 $ for fuzzer in `ls *_fuzzer | sort` ; do
58 > echo run $fuzzer...
59 > ./$fuzzer dummy.cc > /dev/null 2>&1
60 > done
61 run bdiff_fuzzer...
62 run dirs_fuzzer...
63 run dirstate_fuzzer...
64 run fm1readmarkers_fuzzer...
65 run fncache_fuzzer...
66 run jsonescapeu8fast_fuzzer...
67 run manifest_fuzzer...
68 run mpatch_fuzzer...
69 run revlog_fuzzer...
70 run xdiff_fuzzer...
71
72 Clean up.
73 $ cd $TESTDIR/../contrib/fuzz
74 $ $MAKE -s clean