[infra] moving test command into base-runner, using it on jenkins

This commit is contained in:
Mike Aizatsky 2016-11-18 16:46:26 -08:00
parent 456e952486
commit 0b58d66e89
6 changed files with 5 additions and 103 deletions

View File

@ -23,7 +23,7 @@ ENV COV_FLAGS="-fsanitize-coverage=edge,indirect-calls,8bit-counters"
ENV ASAN_OPTIONS="symbolize=1:detect_leaks=0"
ENV FUZZER_LDFLAGS ""
COPY coverage_report compile srcmap reproduce run just_run test \
COPY coverage_report compile srcmap reproduce run just_run \
/usr/local/bin/
WORKDIR $SRC

View File

@ -10,7 +10,6 @@
| `compile` (default) | build all fuzzers
| `reproduce <fuzzer_name> <fuzzer_options>` | build all fuzzers and run specified one with `/testcase` content.
| `run <fuzzer_name> <fuzzer_options...>` | build all fuzzers and run specified one with given options.
| `test` | build all fuzzers and run each one for a little while to verify it is working correctly.
| `/bin/bash` | drop into shell, execute `compile` script to start build.
# Image Files Layout

View File

@ -1,57 +0,0 @@
#!/bin/bash -eu
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# Test fuzzers
compile
REPORT_DIR="/junit_reports"
mkdir -p $REPORT_DIR
set -o pipefail
DIR="$OUT"
N=0
for FUZZER_BINARY in $(find $DIR -executable -type f); do
FUZZER=$(basename $FUZZER_BINARY)
echo "testing $FUZZER"
ldd $FUZZER_BINARY
out=$(tempfile)
just_run $FUZZER -runs=32 | tee $out
N=$[$N+1]
REPORT_TEXT=$(cat <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="$FUZZER" tests="1" skipped="0" failures="0" errors="0" timestamp="2016-10-25T02:57:01" hostname="box678.localdomain" time="1">
<properties/>
<testcase name="$FUZZER" classname="$FUZZER" time="1"/>
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
EOF
)
echo $REPORT_TEXT > /junit_reports/$FUZZER.xml
done
if [ "$N" -eq "0" ]; then
echo "ERROR: no fuzzers found in $DIR"
ls -al $OUT
exit 1
fi
echo "$N fuzzers total"

View File

@ -14,9 +14,9 @@
#
################################################################################
FROM ossfuzz/base
FROM ossfuzz/base-runner
MAINTAINER mike.aizatsky@gmail.com
RUN apt-get install -y gdb zip
COPY llvm-symbolizer run_fuzzer /usr/local/bin/
COPY llvm-symbolizer /usr/local/bin/
ENV ASAN_OPTIONS="symbolize=1:detect_leaks=0"

View File

@ -1,41 +0,0 @@
#!/bin/bash -eu
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
# Fuzzer runner. Appends .options arguments and seed corpus to users args.
# Usage: $0 <fuzzer_name> <fuzzer_args>
cd $OUT
FUZZER=$1
shift
CMD_LINE="$FUZZER $@"
OPTIONS_FILE="${FUZZER}.options"
if [ -f $OPTIONS_FILE ]; then
OPTIONS_ARGS=$(grep "=" $OPTIONS_FILE | sed 's/\(\w*\)\W*=\W*\(.*\)/-\1=\2 /g' | tr '\n' ' ')
CMD_LINE="$CMD_LINE $OPTIONS_ARGS"
fi
SEED_CORPUS="${FUZZER}_seed_corpus.zip"
if [ -f $SEED_CORPUS ]; then
rm -rf /tmp/seed_corpus/ && mkdir /tmp/seed_corpus/
unzip -d /tmp/seed_corpus/ $SEED_CORPUS
CMD_LINE="$CMD_LINE /tmp/seed_corpus/"
fi
echo $CMD_LINE
bash -c "$CMD_LINE"

View File

@ -102,7 +102,8 @@ def call(body) {
stage("$sanitizer sanitizer") {
// Run image to produce fuzzers
def flags = sanitizerFlags[sanitizer]
sh "docker run --rm --user $uid -v $out:/out -v $junit_reports:/junit_reports -e SANITIZER_FLAGS=\"${flags}\" -t $dockerTag test"
sh "docker run --rm --user $uid -v $out:/out -e SANITIZER_FLAGS=\"${flags}\" -t $dockerTag compile"
sh "docker run --rm --user $uid -v $out:/out -v $junit_reports:/junit_reports -t ossfuzz/base-runner test_all"
sh "ls -al $junit_reports/"
}
}