diff --git a/.bazelrc b/.bazelrc index 3f2fab533837e..7832a4b801265 100644 --- a/.bazelrc +++ b/.bazelrc @@ -277,22 +277,18 @@ build:remote-ci --remote_cache=grpcs://remotebuildexecution.googleapis.com build:remote-ci --remote_executor=grpcs://remotebuildexecution.googleapis.com # Fuzz builds -# -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is passed in in the bazel build target -# rules for fuzz tests. Passing it in the CLI will cause dependencies to be build -# with the macro. Causing issues in RouteMatcherTest.TestRoutes that expect prod -# behavior from RE2 library. -build:asan-fuzzer --config=asan -build:asan-fuzzer --define=FUZZING_ENGINE=libfuzzer -build:asan-fuzzer --copt=-fsanitize=fuzzer-no-link -build:asan-fuzzer --copt=-fno-omit-frame-pointer -# Remove UBSAN halt_on_error to avoid crashing on protobuf errors. -build:asan-fuzzer --test_env=UBSAN_OPTIONS=print_stacktrace=1 - # Fuzzing without ASAN. This is useful for profiling fuzzers without any ASAN artifacts. build:plain-fuzzer --define=FUZZING_ENGINE=libfuzzer build:plain-fuzzer --define ENVOY_CONFIG_ASAN=1 build:plain-fuzzer --copt=-fsanitize=fuzzer-no-link build:plain-fuzzer --linkopt=-fsanitize=fuzzer-no-link +build:plain-fuzzer --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + +build:asan-fuzzer --config=plain-fuzzer +build:asan-fuzzer --config=asan +build:asan-fuzzer --copt=-fno-omit-frame-pointer +# Remove UBSAN halt_on_error to avoid crashing on protobuf errors. +build:asan-fuzzer --test_env=UBSAN_OPTIONS=print_stacktrace=1 # Compile database generation config build:compdb --build_tag_filters=-nocompdb diff --git a/test/test_runner.cc b/test/test_runner.cc index 727268ffc4f19..e966cfcb15cd0 100644 --- a/test/test_runner.cc +++ b/test/test_runner.cc @@ -152,7 +152,17 @@ int TestRunner::RunTests(int argc, char** argv) { file_logger = std::make_unique( TestEnvironment::getOptions().logPath(), access_log_manager, Logger::Registry::getSink()); } + +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + // Fuzz tests may run Envoy tests in fuzzing mode to generate corpora. In this case, we do not + // want to fail building the fuzz test because of a failed test run, which can happen when testing + // functionality in fuzzing test mode. Dependencies (like RE2) change behavior when in fuzzing + // mode, so we do not want to rely on a behavior test when generating a corpus. + (void)RUN_ALL_TESTS(); + return 0; +#else return RUN_ALL_TESTS(); +#endif } } // namespace Envoy