|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +REPO_DIR=$(git rev-parse --show-toplevel) |
| 6 | + |
| 7 | +# shellcheck source=./fuzz-util.sh |
| 8 | +source "$REPO_DIR/fuzz/fuzz-util.sh" |
| 9 | + |
| 10 | +# 1. Generate fuzz/Cargo.toml |
| 11 | +cat > "$REPO_DIR/fuzz/Cargo.toml" <<EOF |
| 12 | +[package] |
| 13 | +name = "descriptor-fuzz" |
| 14 | +edition = "2018" |
| 15 | +version = "0.0.1" |
| 16 | +authors = ["Generated by fuzz/generate-files.sh"] |
| 17 | +publish = false |
| 18 | +
|
| 19 | +[package.metadata] |
| 20 | +cargo-fuzz = true |
| 21 | +
|
| 22 | +[dependencies] |
| 23 | +honggfuzz = { version = "0.5.55", default-features = false } |
| 24 | +miniscript = { path = "..", features = [ "compiler" ] } |
| 25 | +
|
| 26 | +regex = "1.4" |
| 27 | +EOF |
| 28 | + |
| 29 | +for targetFile in $(listTargetFiles); do |
| 30 | + targetName=$(targetFileToName "$targetFile") |
| 31 | + cat >> "$REPO_DIR/fuzz/Cargo.toml" <<EOF |
| 32 | +
|
| 33 | +[[bin]] |
| 34 | +name = "$targetName" |
| 35 | +path = "$targetFile" |
| 36 | +EOF |
| 37 | +done |
| 38 | + |
| 39 | +# 2. Generate .github/workflows/fuzz.yml |
| 40 | +cat > "$REPO_DIR/.github/workflows/fuzz.yml" <<EOF |
| 41 | +# Automatically generated by fuzz/generate-files.sh |
| 42 | +name: Fuzz |
| 43 | +
|
| 44 | +on: |
| 45 | + push: |
| 46 | + branches: |
| 47 | + - master |
| 48 | + - 'test-ci/**' |
| 49 | + pull_request: |
| 50 | +
|
| 51 | +jobs: |
| 52 | + fuzz: |
| 53 | + if: \${{ !github.event.act }} |
| 54 | + runs-on: ubuntu-20.04 |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + fuzz_target: [ |
| 59 | +$(for name in $(listTargetNames); do echo "$name,"; done) |
| 60 | + ] |
| 61 | + steps: |
| 62 | + - name: Install test dependencies |
| 63 | + run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - uses: actions/cache@v2 |
| 66 | + id: cache-fuzz |
| 67 | + with: |
| 68 | + path: | |
| 69 | + ~/.cargo/bin |
| 70 | + fuzz/target |
| 71 | + target |
| 72 | + key: cache-\${{ matrix.target }}-\${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }} |
| 73 | + - uses: actions-rs/toolchain@v1 |
| 74 | + with: |
| 75 | + toolchain: 1.58 |
| 76 | + override: true |
| 77 | + profile: minimal |
| 78 | + - name: fuzz |
| 79 | + run: cd fuzz && ./fuzz.sh "\${{ matrix.fuzz_target }}" |
| 80 | + - run: echo "\${{ matrix.fuzz_target }}" >executed_\${{ matrix.fuzz_target }} |
| 81 | + - uses: actions/upload-artifact@v2 |
| 82 | + with: |
| 83 | + name: executed_\${{ matrix.fuzz_target }} |
| 84 | + path: executed_\${{ matrix.fuzz_target }} |
| 85 | +
|
| 86 | + verify-execution: |
| 87 | + if: \${{ !github.event.act }} |
| 88 | + needs: fuzz |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v2 |
| 92 | + - uses: actions/download-artifact@v2 |
| 93 | + - name: Display structure of downloaded files |
| 94 | + run: ls -R |
| 95 | + - run: find executed_* -type f -exec cat {} + | sort > executed |
| 96 | + - run: source ./fuzz/fuzz-util.sh && listTargetNames | sort | diff - executed |
| 97 | +EOF |
| 98 | + |
0 commit comments