]>
Commit | Line | Data |
---|---|---|
ccdc47b7 EV |
1 | #!/usr/bin/env bash |
2 | ||
3 | set -ex | |
4 | ||
5 | export LC_CTYPE=C.UTF-8 | |
6 | ||
7 | export CC=${CC:-clang} | |
8 | export CXX=${CXX:-clang++} | |
9 | export LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE:--fsanitize=fuzzer} | |
10 | ||
11 | SANITIZER=${SANITIZER:-address -fsanitize-address-use-after-scope} | |
12 | flags="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER -fsanitize=fuzzer-no-link" | |
13 | ||
14 | export CFLAGS=${CFLAGS:-$flags} | |
15 | export CXXFLAGS=${CXXFLAGS:-$flags} | |
16 | ||
17 | export OUT=${OUT:-$(pwd)/out} | |
18 | mkdir -p $OUT | |
19 | ||
665c938b EV |
20 | if [[ "$SANITIZER" == undefined ]]; then |
21 | additional_ubsan_checks=alignment | |
22 | UBSAN_FLAGS="-fsanitize=$additional_ubsan_checks -fno-sanitize-recover=$additional_ubsan_checks" | |
23 | CFLAGS+=" $UBSAN_FLAGS" | |
24 | CXXFLAGS+=" $UBSAN_FLAGS" | |
25 | fi | |
26 | ||
f6e7a21c TW |
27 | CONFIGURE_ARGS="--disable-all-programs --enable-libuuid --enable-libfdisk --enable-last --enable-fuzzing-engine --enable-libmount --enable-libblkid" |
28 | ||
29 | LIBC_VERSION="$(dpkg -s libc6 | grep Version | cut -d' ' -f2)" | |
30 | ||
31 | # Ubuntu focal uses glibc 2.31 but 2.34 is necessary | |
32 | if dpkg --compare-versions "$LIBC_VERSION" 'lt' '2.34'; then | |
33 | CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-year2038" | |
34 | fi | |
35 | ||
ccdc47b7 | 36 | ./autogen.sh |
f6e7a21c | 37 | ./configure $CONFIGURE_ARGS |
ccdc47b7 EV |
38 | make -j$(nproc) V=1 check-programs |
39 | ||
6e277b7a EV |
40 | for d in "$(dirname $0)"/../tests/ts/fuzzers/test_*_fuzz_files; do |
41 | bd=$(basename "$d") | |
42 | fuzzer=${bd%_files} | |
43 | zip -jqr $OUT/${fuzzer}_seed_corpus.zip "$d" | |
44 | done | |
45 | ||
1ba4085e DF |
46 | # create seed corpus for blkid fuzzing |
47 | unxz -k "$(dirname $0)"/../tests/ts/blkid/images-*/*.xz | |
48 | zip -jqrm $OUT/test_blkid_fuzz_seed_corpus.zip "$(dirname $0)"/../tests/ts/blkid/images-*/*.img | |
49 | ||
ccdc47b7 EV |
50 | find . -maxdepth 1 -type f -executable -name "test_*_fuzz" -exec mv {} $OUT \; |
51 | find . -type f -name "fuzz-*.dict" -exec cp {} $OUT \; |