[zetasql] Correct fuzzer indexing (#4142)

* Correct fuzzer indexing

* Remove redundant -e option
This commit is contained in:
Zhengdai Hu 2020-07-16 20:31:09 +00:00 committed by GitHub
parent 32263d2b17
commit 9ba22659ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -25,7 +25,7 @@ RUN curl https://bazel.build/bazel-release.pub.gpg | apt-key add - && \
RUN apt-get update && apt-get -y install bazel-1.0.0 RUN apt-get update && apt-get -y install bazel-1.0.0
RUN git clone -b arithmetic_fuzzer --depth 1 \ RUN git clone -b master --depth 1 \
https://github.com/googleinterns/zetasql-fuzzing.git zetasql https://github.com/googleinterns/zetasql-fuzzing.git zetasql
COPY build.sh $SRC/ COPY build.sh $SRC/
WORKDIR zetasql WORKDIR zetasql

View File

@ -51,8 +51,10 @@ fi
# Temporary hack, see https://github.com/google/oss-fuzz/issues/383 # Temporary hack, see https://github.com/google/oss-fuzz/issues/383
readonly NO_VPTR='--copt=-fno-sanitize=vptr --linkopt=-fno-sanitize=vptr --cxxopt=-fno-sanitize=vptr' readonly NO_VPTR='--copt=-fno-sanitize=vptr --linkopt=-fno-sanitize=vptr --cxxopt=-fno-sanitize=vptr'
declare FUZZER_PATH=$(for path in $(find zetasql/fuzzing -name *_fuzzer.cc); do echo "${path%.*}"; done) # Get all fuzz targets via `bazal query` and output error info to stderr.
declare FUZZ_TARGET="$(for fuzzer in ${FUZZER_PATH}; do echo "//$(dirname ${fuzzer}):$(basename ${fuzzer})"; done)" # Exit status from `bazel query` is preserved from variable substitution.
exec {FD}>&2; FUZZ_TARGETS=($(bazel-1.0.0 query 'attr("tags", "fuzzer", //...)' 2>&${FD})); exec {FD}>&-
declare -ar FUZZ_TARGETS
# Build fuzz target # Build fuzz target
# see https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/ # see https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/
@ -69,7 +71,7 @@ bazel-1.0.0 build --verbose_failures --compilation_mode=dbg \
--linkopt="-rpath '\$ORIGIN\/lib'" \ --linkopt="-rpath '\$ORIGIN\/lib'" \
--define LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE} \ --define LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE} \
${EXTRA_BAZEL_FLAGS} ${NO_VPTR} \ ${EXTRA_BAZEL_FLAGS} ${NO_VPTR} \
${FUZZ_TARGET} "${FUZZ_TARGETS[@]}"
# Profiling with coverage requires that we resolve+copy all Bazel symlinks and # Profiling with coverage requires that we resolve+copy all Bazel symlinks and
# also remap everything under proc/self/cwd to correspond to Bazel build paths. # also remap everything under proc/self/cwd to correspond to Bazel build paths.
@ -109,9 +111,11 @@ cp -r /usr/share/zoneinfo $OUT/data/
ln -sf Etc/UTC $OUT/data/zoneinfo/localtime ln -sf Etc/UTC $OUT/data/zoneinfo/localtime
# Move out fuzz target # Move out fuzz target
for fuzzer in ${FUZZER_PATH}; for target in ${FUZZ_TARGETS[@]};
do do
cp bazel-bin/"${fuzzer}" "${OUT}"/ # Transform //foo/bar:baz to foo/bar/baz
relative_path=$(sed 's/^\/\/\(.*\):/\1\//' <<< "$target")
cp bazel-bin/"${relative_path}" "${OUT}"/
done done
# Cleanup bazel- symlinks to avoid oss-fuzz trying to copy out of the build # Cleanup bazel- symlinks to avoid oss-fuzz trying to copy out of the build