Skip to content

Commit

Permalink
simplify building of fuzzer
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 545950923
  • Loading branch information
eustas committed Jul 10, 2023
1 parent 413b098 commit 70e7b1a
Show file tree
Hide file tree
Showing 26 changed files with 65 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
pull_request:
types: [opened, reopened, labeled, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
ubuntu_build:
name: Build and test ${{ matrix.name }}
Expand Down Expand Up @@ -288,8 +292,15 @@ jobs:
- name: Quick Fuzz
if: ${{ matrix.build_system == 'fuzz' }}
run: |
export ASAN_OPTIONS=detect_leaks=0
./c/fuzz/test_fuzzer.sh
mkdir ${RUNNER_TEMP}/decode_corpora
unzip java/org/brotli/integration/fuzz_data.zip -d ${RUNNER_TEMP}/decode_corpora
cd ${GITHUB_WORKSPACE}/c/fuzz
bazelisk build --config=asan-libfuzzer :decode_fuzzer
for f in `ls ${RUNNER_TEMP}/decode_corpora`
do
echo "Testing $f"
./bazel-bin/decode_fuzzer_bin ${RUNNER_TEMP}/decode_corpora/$f
done
- name: Build with Bazel
if: ${{ matrix.build_system == 'bazel' }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
schedule:
- cron: '18 15 * * 0'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
analyze:
name: Analyze
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

name: CIFuzz
on: [pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
Fuzzing:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
release:
types: [ published ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
windows_build:
name: Windows Build (vcpkg / ${{ matrix.triplet }})
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
push:
branches: [ "master" ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

# Declare default permissions as read only.
permissions: read-all

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions WORKSPACE → WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
workspace(name = "org_brotli")

local_repository(
name = "ignore_org_brotli_fuzz",
path = "c/fuzz",
)

local_repository(
name = "ignore_org_brotli_go",
path = "go",
Expand Down
18 changes: 18 additions & 0 deletions c/fuzz/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Force the use of Clang for C++ builds.
build --action_env=CC=clang
build --action_env=CXX=clang++

# Define the --config=asan-libfuzzer configuration.
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan

# Define the --config=msan-libfuzzer configuration.
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:msan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=msan

# Define the --config=ubsan-libfuzzer configuration.
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:ubsan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=ubsan
12 changes: 12 additions & 0 deletions c/fuzz/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"]) # MIT

# To start fuzzing run: bazel run --config=asan-libfuzzer //:fuzz_config_run
cc_fuzz_test(
name = "decode_fuzzer",
srcs = ["decode_fuzzer.c"],
deps = ["@org_brotli//:brotlidec"],
)
Empty file added c/fuzz/WORKSPACE.bazel
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 70e7b1a

Please sign in to comment.