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