Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add fuzz test targets to ci #7949

Merged
merged 8 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure-pipelines/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
CI_TARGET: 'bazel.gcc'
compile_time_options:
CI_TARGET: 'bazel.compile_time_options'
fuzz:
CI_TARGET: 'bazel.fuzz'
dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel.
timeoutInMinutes: 360
pool:
Expand Down
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ build:remote-ci --remote_executor=grpcs://remotebuildexecution.googleapis.com
build:asan-fuzzer --config=asan
build:asan-fuzzer --define=FUZZING_ENGINE=libfuzzer
build:asan-fuzzer --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
build:asan-fuzzer --copt=-fsanitize-coverage=trace-pc-guard
build:asan-fuzzer --copt=-fsanitize-coverage=trace-pc-guard
build:asan-fuzzer --test_env=UBSAN_OPTIONS=print_stacktrace=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment why this is overridden and perhaps link to protobuf issue (is that a real issue in protobuf?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I haven't seen anyone make an issue about this, although some of the protobuf code isn't tested with UBSan, it might need a fix upstream there + patch until release.

4 changes: 2 additions & 2 deletions bazel/envoy_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ def envoy_cc_fuzz_test(name, corpus, deps = [], tags = [], **kwargs):
tags = ["manual"] + tags,
)

native.cc_binary(
native.cc_test(
name = name + "_with_libfuzzer",
copts = envoy_copts("@envoy", test = True),
linkopts = ["-fsanitize=fuzzer"] + _envoy_test_linkopts(),
linkstatic = 1,
testonly = 1,
data = [corpus_name],
deps = [":" + test_lib_name],
tags = ["manual"] + tags,
tags = ["manual", "fuzzer"] + tags,
)

# Envoy C++ test targets should be specified with this function.
Expand Down
2 changes: 2 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ The `./ci/run_envoy_docker.sh './ci/do_ci.sh <TARGET>'` targets are:
* `bazel.coverity` &mdash; build Envoy static binary and run Coverity Scan static analysis.
* `bazel.tsan` &mdash; build and run tests under `-c dbg --config=clang-tsan` with clang.
* `bazel.tsan <test>` &mdash; build and run a specified test or test dir under `-c dbg --config=clang-tsan` with clang.
* `bazel.fuzz` &mdash; build and run fuzz tests under `-c dbg --config=asan-fuzzer` with clang.
* `bazel.fuzz <test>` &mdash; build and run a specified fuzz test or test dir under `-c dbg --config=asan-fuzzer` with clang. If specifying a single fuzz test, must use the full target name with "_with_libfuzzer" for `<test>`.
* `bazel.compile_time_options` &mdash; build Envoy and run tests with various compile-time options toggled to their non-default state, to ensure they still build.
* `bazel.compile_time_options <test>` &mdash; build Envoy and run a specified test or test dir with various compile-time options toggled to their non-default state, to ensure they still build.
* `bazel.clang_tidy` &mdash; build and run clang-tidy over all source files.
Expand Down
10 changes: 10 additions & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ else
TEST_TARGETS=//test/...
fi

if [[ "$CI_TARGET" == "bazel.fuzz" ]]; then
FUZZ_TEST_TARGETS="$(bazel query "attr('tags','fuzzer',${TEST_TARGETS})")"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant put this in below (around line 260).

fi

if [[ "$CI_TARGET" == "bazel.release" ]]; then
# When testing memory consumption, we want to test against exact byte-counts
# where possible. As these differ between platforms and compile options, we
Expand Down Expand Up @@ -252,6 +256,12 @@ elif [[ "$CI_TARGET" == "bazel.coverity" ]]; then
"${ENVOY_BUILD_DIR}"/envoy-coverity-output.tgz \
"${ENVOY_DELIVERY_DIR}"/envoy-coverity-output.tgz
exit 0
elif [[ "$CI_TARGET" == "bazel.fuzz" ]]; then
setup_clang_toolchain
echo "bazel ASAN libFuzzer build with fuzz tests ${FUZZ_TEST_TARGETS}"
echo "Building envoy fuzzers and executing 100 fuzz iterations..."
bazel_with_collection test ${BAZEL_BUILD_OPTIONS} --config=asan-fuzzer ${FUZZ_TEST_TARGETS} --test_arg="-runs=10"
exit 0
elif [[ "$CI_TARGET" == "fix_format" ]]; then
echo "fix_format..."
./tools/check_format.py fix
Expand Down