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