Merge pull request #12515 from evverx/fix-fuzzers-in-local-mode

travis: make sure the fuzzers can be built in "local" mode
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-05-16 23:04:45 +02:00 committed by GitHub
commit 5cef20c80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 4 deletions

View File

@ -3,6 +3,7 @@
<a href="https://in.waw.pl/systemd-github-state/systemd-systemd-issues.svg"><img align="right" src="https://in.waw.pl/systemd-github-state/systemd-systemd-issues-small.svg" alt="Count of open issues over time"></a>
<a href="https://in.waw.pl/systemd-github-state/systemd-systemd-pull-requests.svg"><img align="right" src="https://in.waw.pl/systemd-github-state/systemd-systemd-pull-requests-small.svg" alt="Count of open pull requests over time"></a>
[![Semaphore CI Build Status](https://semaphoreci.com/api/v1/projects/28a5a3ca-3c56-4078-8b5e-7ed6ef912e14/443470/shields_badge.svg)](https://semaphoreci.com/systemd/systemd)<br/>
[![Coverity Scan Status](https://scan.coverity.com/projects/350/badge.svg)](https://scan.coverity.com/projects/350)<br/>
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1369/badge)](https://bestpractices.coreinfrastructure.org/projects/1369)<br/>
[![Travis CI Build Status](https://travis-ci.org/systemd/systemd.svg?branch=master)](https://travis-ci.org/systemd/systemd)<br/>
[![Language Grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/systemd/systemd.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/systemd/systemd/context:cpp)<br/>

View File

@ -303,7 +303,14 @@ else
endif
if want_libfuzzer
fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false)
if fuzzing_engine.found()
add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c')
elif cc.has_argument('-fsanitize=fuzzer-no-link')
add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c')
else
error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported')
endif
elif want_ossfuzz
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
elif want_fuzzbuzz
@ -2825,9 +2832,16 @@ foreach tuple : fuzzers
dependencies = tuple[2]
defs = tuple.length() >= 4 ? tuple[3] : []
incs = tuple.length() >= 5 ? tuple[4] : includes
link_args = []
if fuzzer_build
if want_ossfuzz or want_fuzzbuzz
dependencies += fuzzing_engine
elif want_libfuzzer
if fuzzing_engine.found()
dependencies += fuzzing_engine
else
link_args += ['-fsanitize=fuzzer']
endif
else
sources += 'src/fuzz/fuzz-main.c'
endif
@ -2845,6 +2859,7 @@ foreach tuple : fuzzers
link_with : link_with,
dependencies : dependencies,
c_args : defs,
link_args: link_args,
install : false)
endforeach
endif

View File

@ -10,7 +10,7 @@ export CXX=${CXX:-clang++}
clang_version="$($CC --version | sed -nr 's/.*version ([^ ]+?) .*/\1/p' | sed -r 's/-$//')"
SANITIZER=${SANITIZER:-address -fsanitize-address-use-after-scope}
flags="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER -fsanitize-coverage=trace-pc-guard,trace-cmp"
flags="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER"
clang_lib="/usr/lib64/clang/${clang_version}/lib/linux"
[ -d "$clang_lib" ] || clang_lib="/usr/lib/clang/${clang_version}/lib/linux"
@ -33,7 +33,7 @@ if [ -z "$FUZZING_ENGINE" ]; then
fi
meson $build -D$fuzzflag -Db_lundef=false
ninja -C $build fuzzers
ninja -v -C $build fuzzers
# The seed corpus is a separate flat archive for each fuzzer,
# with a fixed name ${fuzzer}_seed_corpus.zip.

View File

@ -6,7 +6,18 @@ set -u
REPO_ROOT=${REPO_ROOT:-$(pwd)}
sudo bash -c "echo 'deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse' >>/etc/apt/sources.list"
sudo apt-get update -y
sudo apt-get build-dep systemd -y
sudo apt-get install -y ninja-build python3-pip python3-setuptools
pip3 install meson
cd $REPO_ROOT
export PATH="$HOME/.local/bin/:$PATH"
tools/oss-fuzz.sh
timeout --preserve-status 5 ./out/fuzz-unit-file
git clean -dxff
wget https://app.fuzzbuzz.io/releases/cli/latest/linux/fuzzbuzz
chmod +x fuzzbuzz
./fuzzbuzz validate