Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Run the fuzz targets on every pull request and every night

The four libFuzzer targets (test specs, project configuration, runner
JSON, runner options) had no CI. Build them with ASan and UBSan on
Ubuntu 26.04 and run each for two minutes on a pull request and on
devel, and for thirty minutes every night. The corpus each run grows is
kept in the cache of devel, so the next run starts from it; a crash
uploads its input as an artifact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit
d10868c9d0324f1817a67d5f3529b5d86050fb39
Author
Leitwolf11 ·
Parents
d06447420eca

Files · Download .tar.gz

Changes

 .github/workflows/fuzzing.yml | 96 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/.github/workflows/fuzzing.yml b/.github/workflows/fuzzing.yml
new file mode 100644
index 00000000..c6a1e596
--- /dev/null
+++ b/.github/workflows/fuzzing.yml
@@ -0,0 +1,96 @@
+# SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
+# SPDX-License-Identifier: LGPL-3.0-or-later
+
+name: Fuzzing
+
+# Each fuzz target reads input from outside: test specs, the project
+# configuration, the runner's JSON and its command line. A pull request runs
+# each for two minutes; every night each runs for thirty. The corpus each run
+# grows is kept in the cache of the devel branch, so the next run starts from
+# it, and a crash uploads its input. A crash input becomes a regression test.
+
+on:
+  push:
+    branches: [devel]
+  pull_request:
+  schedule:
+    - cron: '17 2 * * *'
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+concurrency:
+  group: fuzzing-${{ github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  fuzz:
+    name: Fuzz ${{matrix.target}}
+    runs-on: ubuntu-26.04
+    timeout-minutes: 50
+    strategy:
+      fail-fast: false
+      matrix:
+        target: [TestSpecParser, ProjectConfig, RunnerJson, RunnerOptions]
+
+    steps:
+    - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
+      with:
+        persist-credentials: false
+
+    - name: Install Clang, CMake and Ninja
+      run: |
+        sudo apt-get update
+        sudo apt-get install -y clang cmake ninja-build
+
+    - name: Configure
+      run: |
+        cmake -S . -B build-fuzzers -GNinja \
+              -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+              -DCMAKE_CXX_COMPILER=clang++ \
+              -DCMAKE_CXX_FLAGS="-fsanitize=fuzzer-no-link,address,undefined -fno-sanitize-recover=undefined" \
+              -DCATCH3_DEVELOPMENT_BUILD=ON \
+              -DCATCH3_BUILD_FUZZERS=ON \
+              -DCATCH3_BUILD_TESTING=OFF \
+              -DCATCH3_BUILD_EXAMPLES=OFF \
+              -DCATCH3_BUILD_EXTRA_TESTS=OFF \
+              -DCATCH3_ENABLE_WERROR=OFF \
+              -DBUILD_TESTING=OFF
+
+    - name: Build
+      run: cmake --build build-fuzzers --target fuzz_${{matrix.target}}
+
+    - name: Restore the corpus
+      uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
+      with:
+        path: corpus/${{matrix.target}}
+        key: fuzz-corpus-${{matrix.target}}-${{github.run_id}}
+        restore-keys: fuzz-corpus-${{matrix.target}}-
+
+    - name: Fuzz
+      env:
+        TARGET: ${{matrix.target}}
+        SECONDS_PER_TARGET: ${{ github.event_name == 'schedule' && 1800 || 120 }}
+        ASAN_OPTIONS: detect_leaks=1:abort_on_error=1
+        UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
+      run: |
+        mkdir -p "corpus/$TARGET" crashes
+        binary=$(find build-fuzzers -type f -name "fuzz_$TARGET" -perm -u+x | head -n 1)
+        "$binary" -max_total_time="$SECONDS_PER_TARGET" -timeout=10 -rss_limit_mb=2048 \
+                  -artifact_prefix=crashes/ -print_final_stats=1 "corpus/$TARGET"
+
+    - name: Upload crash inputs
+      if: failure()
+      uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+      with:
+        name: fuzz-crashes-${{matrix.target}}
+        path: crashes/
+        if-no-files-found: ignore
+
+    - name: Keep the corpus
+      if: success() && github.event_name != 'pull_request'
+      uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
+      with:
+        path: corpus/${{matrix.target}}
+        key: fuzz-corpus-${{matrix.target}}-${{github.run_id}}