Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions .github/workflows/bazel_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

name: Bazel Test

Check warning on line 15 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

bazel_test.yml:15: overly broad permissions: default permissions used due to no permissions: block

on:
push:
Expand All @@ -25,7 +25,7 @@
workflow_dispatch:

jobs:
run_unit_tests:

Check warning on line 28 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

bazel_test.yml:28: overly broad permissions: default permissions used due to no permissions: block
name: Run unit tests
# TODO(xinhaoyuan): Bump to 24.04 after https://github.com/llvm/llvm-project/issues/102443
# is fixed.
Expand All @@ -36,13 +36,13 @@
compilation_mode: ['fastbuild', 'opt', 'dbg']
steps:
- name: Checkout repository
uses: actions/checkout@v4

Check failure on line 39 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 39 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:39: unpinned action reference: action is not pinned to a hash (required by blanket policy)
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq \
clang
- name: Restore latest cache
uses: actions/cache/restore@v4

Check failure on line 45 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 45 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:45: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
path: "~/.cache/bazel"
key: bazel-cache-unit-${{ matrix.compilation_mode }}
Expand All @@ -53,11 +53,11 @@
-c ${{ matrix.compilation_mode }} -- //... -//e2e_tests/... -//centipede/...
- name: Save new cache based on main
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4

Check failure on line 56 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 56 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:56: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
path: "~/.cache/bazel"
key: bazel-cache-unit-${{ matrix.compilation_mode }}-${{ github.run_id }}
run_e2e_tests:

Check warning on line 60 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

excessive-permissions

bazel_test.yml:60: overly broad permissions: default permissions used due to no permissions: block
name: Run e2e tests
# TODO(xinhaoyuan): Bump to 24.04 after https://github.com/llvm/llvm-project/issues/102443
# is fixed.
Expand All @@ -71,7 +71,7 @@
run: |
sudo sysctl -w kernel.core_pattern=""
- name: Checkout repository
uses: actions/checkout@v4

Check failure on line 74 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 74 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:74: unpinned action reference: action is not pinned to a hash (required by blanket policy)
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq \
Expand All @@ -80,7 +80,7 @@
run: |
EXTRA_CONFIGS=libfuzzer bazel run //bazel:setup_configs > fuzztest.bazelrc
- name: Restore latest cache
uses: actions/cache/restore@v4

Check failure on line 83 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 83 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:83: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
path: "~/.cache/bazel"
key: bazel-cache-e2e-${{ matrix.config }}
Expand All @@ -95,16 +95,15 @@
if: matrix.config == 'fuzztest'
run: |
bazel test --build_tests_only --test_output=errors \
-c opt --config=fuzztest //e2e_tests:all
-c opt --config=fuzztest-legacy //e2e_tests:all
- name: Run end-to-end tests with --config=fuzztest-experimental
if: matrix.config == 'fuzztest-experimental'
# TODO: Add other e2e tests and resolve any issues.
run: |
bazel test --build_tests_only --test_output=errors \
-c opt \
--config=fuzztest-experimental --config=asan \
--config=fuzztest \
--platform_suffix=fuzztest-experimental-asan \
//e2e_tests:corpus_database_test
//e2e_tests:all
- name: Run end-to-end tests with --config=libfuzzer
if: matrix.config == 'libfuzzer'
run: |
Expand All @@ -114,7 +113,7 @@
//e2e_tests:compatibility_mode_test
- name: Save new cache based on main
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4

Check failure on line 116 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

zizmor/unpinned-uses

unpinned action reference: action is not pinned to a hash (required by blanket policy)

Check failure on line 116 in .github/workflows/bazel_test.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

unpinned-uses

bazel_test.yml:116: unpinned action reference: action is not pinned to a hash (required by blanket policy)
with:
path: "~/.cache/bazel"
key: bazel-cache-e2e-${{ matrix.config }}-${{ github.run_id }}
58 changes: 29 additions & 29 deletions bazel/setup_configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,27 @@ EOF
cat <<EOF
### FuzzTest build configuration.
#
# Use with: --config=fuzztest
#
# Note that this configuration includes the ASan configuration.
# Use with: --config=fuzztest (with asan)
# or --config=fuzztest-nosan (without asan)

build:fuzztest --config=asan
build:fuzztest --config=fuzztest-common
build:fuzztest-nosan --config=fuzztest-common
build:fuzztest-nosan --@com_google_fuzztest//fuzztest:centipede_integration

# Generate line tables for debugging.
build:fuzztest-nosan --copt=-gline-tables-only
build:fuzztest-nosan --strip=never

# Prevent memcmp & co from being inlined.
build:fuzztest-nosan --copt=-fno-builtin

# Disable heap checking.
build:fuzztest-nosan --copt=-DHEAPCHECK_DISABLE

# Link statically.
build:fuzztest --dynamic_mode=off
build:fuzztest-nosan --dynamic_mode=off

build:fuzztest --config=fuzztest-nosan
build:fuzztest --config=asan

EOF

Expand All @@ -79,43 +91,31 @@ fi
cat <<EOF
# We apply coverage tracking instrumentation to everything but Centipede and the
# FuzzTest framework itself (including GoogleTest and GoogleMock).
build:fuzztest --copt=-fsanitize-coverage=inline-8bit-counters,trace-cmp,pc-table
# TODO(b/374840534): Add -fsanitize-coverage=control-flow once we start building
# with clang 16+.
build:fuzztest --copt=-fsanitize-coverage=trace-pc-guard,pc-table,trace-loads,trace-cmp
build:fuzztest --per_file_copt=${COMMON_FILTER},${FUZZTEST_FILTER},${CENTIPEDE_FILTER},googletest/.*,googlemock/.*@-fsanitize-coverage=0

EOF

cat <<EOF
### Experimental FuzzTest build configuration.
### Legacy FuzzTest build configuration.
#
# Use with: --config=fuzztest-experimental
# Use with: --config=fuzztest-legacy
#
# Use this instead of --config=fuzztest when building test binaries to run with
# Centipede. Eventually, this will be consolidated with --config=fuzztest.
# Note that this configuration doesn't include the ASan configuration. If you
# want to use both, you can use --config=fuzztest-experimental --config=asan.

build:fuzztest-experimental --config=fuzztest-common
build:fuzztest-experimental --@com_google_fuzztest//fuzztest:centipede_integration

# Generate line tables for debugging.
build:fuzztest-experimental --copt=-gline-tables-only
build:fuzztest-experimental --strip=never
# the legacy fuzz engine.

# Prevent memcmp & co from being inlined.
build:fuzztest-experimental --copt=-fno-builtin

# Disable heap checking.
build:fuzztest-experimental --copt=-DHEAPCHECK_DISABLE
build:fuzztest-legacy --config=asan
build:fuzztest-legacy --config=fuzztest-common

# Link statically.
build:fuzztest-experimental --dynamic_mode=off
build:fuzztest-legacy --dynamic_mode=off

# We apply coverage tracking instrumentation to everything but Centipede and the
# FuzzTest framework itself (including GoogleTest and GoogleMock).
# TODO(b/374840534): Add -fsanitize-coverage=control-flow once we start building
# with clang 16+.
build:fuzztest-experimental --copt=-fsanitize-coverage=trace-pc-guard,pc-table,trace-loads,trace-cmp
build:fuzztest-experimental --per_file_copt=${COMMON_FILTER},${FUZZTEST_FILTER},${CENTIPEDE_FILTER},googletest/.*,googlemock/.*@-fsanitize-coverage=0
build:fuzztest-legacy --copt=-fsanitize-coverage=inline-8bit-counters,trace-cmp,pc-table
build:fuzztest-legacy --per_file_copt=${COMMON_FILTER},${FUZZTEST_FILTER},${CENTIPEDE_FILTER},googletest/.*,googlemock/.*@-fsanitize-coverage=0

EOF

Expand Down
14 changes: 10 additions & 4 deletions e2e_tests/functional_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ class GenericCommandLineInterfaceTest : public ::testing::Test {
const absl::flat_hash_map<std::string, std::string>& non_fuzztest_flags =
{}) {
flags["print_subprocess_log"] = "true";
(void)flags.try_emplace("corpus_database", "");
return RunBinary(BinaryPath(binary),
RunOptions{/*flags=*/non_fuzztest_flags,
/*fuzztest_flags=*/flags,
Expand Down Expand Up @@ -1422,7 +1423,8 @@ class FuzzingModeFixtureTest
case ExecutionModelParam::kTestBinary: {
RunOptions run_options;
run_options.fuzztest_flags = {{"fuzz", std::string(test_name)},
{"print_subprocess_log", "true"}};
{"print_subprocess_log", "true"},
{"corpus_database", ""}};
run_options.env = {
{"FUZZTEST_MAX_FUZZING_RUNS", absl::StrCat(iterations)}};
run_options.timeout = absl::InfiniteDuration();
Expand All @@ -1432,6 +1434,7 @@ class FuzzingModeFixtureTest
RunOptions run_options;
run_options.fuzztest_flags = {
{"fuzz", std::string(test_name)},
{"corpus_database", ""},
{"print_subprocess_log", "true"},
{"internal_centipede_command", ShellEscape(CentipedePath())}};
run_options.env = {
Expand All @@ -1449,7 +1452,8 @@ class FuzzingModeFixtureTest
{"populate_binary_info", "false"},
{"workdir", workdir.path()},
{"binary", absl::StrCat(BinaryPath(kDefaultTargetBinary), " ",
CreateFuzzTestFlag("fuzz", test_name))},
CreateFuzzTestFlag("fuzz", test_name), " ",
CreateFuzzTestFlag("corpus_database", ""))},
{"num_runs", absl::StrCat(iterations)}};
run_options.timeout = absl::InfiniteDuration();
return RunBinary(CentipedePath(), run_options);
Expand Down Expand Up @@ -1601,14 +1605,16 @@ class FuzzingModeCrashFindingTest
{"stop_at", absl::StrCat(absl::Now() + timeout)},
{"workdir", workdir.path()},
{"binary", absl::StrCat(BinaryPath(target_binary), " ",
CreateFuzzTestFlag("fuzz", test_name))}};
CreateFuzzTestFlag("fuzz", test_name), " ",
CreateFuzzTestFlag("corpus_database", ""))}};
run_options.env = std::move(env);
run_options.timeout = timeout + absl::Seconds(10);
return RunBinary(CentipedePath(), run_options);
}
RunOptions run_options;
run_options.fuzztest_flags = {{"fuzz", std::string(test_name)},
{"fuzz_for", absl::StrCat(timeout)}};
{"fuzz_for", absl::StrCat(timeout)},
{"corpus_database", ""}};
run_options.env = std::move(env);
run_options.timeout = timeout + absl::Seconds(10);
if (GetParam() == ExecutionModelParam::kTestBinaryInvokingCentipedeBinary) {
Expand Down
3 changes: 1 addition & 2 deletions e2e_tests/test_binary_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ std::string GetFullPath(const std::filesystem::path& relative_path) {

std::string CreateFuzzTestFlag(absl::string_view flag_name,
absl::string_view flag_value) {
return absl::StrCat("--", FUZZTEST_FLAG_PREFIX, flag_name,
(flag_value.empty() ? "" : "="), flag_value);
return absl::StrCat("--", FUZZTEST_FLAG_PREFIX, flag_name, "=", flag_value);
}

std::string BinaryPath(const absl::string_view relative_path) {
Expand Down
Loading