Skip to content

Commit

Permalink
💚 test fuzzing pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan committed Jun 26, 2024
1 parent 9fa4623 commit 1cc34a4
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/actions/setup-honggfuzz/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Setup Honggfuzz"
description: "Setup Honggfuzz"

runs:
using: "composite"
steps:
- uses: actions/cache@v3
name: Cache Honggfuzz
id: cache-honggfuzz
with:
path: |
~/.cache/honggfuzz/
~/.local/share/honggfuzz/
key: honggfuzz-${{ runner.os }}-v0000-${{ env.HONGGFUZZ_VERSION }}
- name: Install honggfuzz
run: cargo install honggfuzz --version ${{ env.HONGGFUZZ_VERSION }}
shell: bash
- name: Install binutils-dev
run: sudo apt-get install binutils-dev
shell: bash
- name: Install libunwind-dev
run: sudo apt-get install libunwind-dev
shell: bash
25 changes: 25 additions & 0 deletions .github/workflows/run_fuzz_example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test Fuzz Tests

on:
workflow_dispatch:
pull_request:

env:
SOLANA_CLI_VERSION: 1.18.12
ANCHOR_VERSION: 0.29.0
HONGGFUZZ_VERSION: 0.5.55

jobs:
run_fuzz_example:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-rust/
- uses: ./.github/actions/setup-solana/
- uses: ./.github/actions/setup-honggfuzz/
id: rust-setup
- uses: Swatinem/rust-cache@v2
name: Cache Rust and it's packages
- name: Test Fuzz
working-directory: examples/fuzz-tests/unchecked-arithmetic-0
run: cargo run --manifest-path ../../../Cargo.toml fuzz run fuzz_0
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
incremented upon a breaking change and the patch version will be incremented for features.

## [dev] - Unreleased
- del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171))
- fix/in case of fuzzing failure throw error instead of only printing message([#167](https://github.com/Ackee-Blockchain/trident/pull/167))
- del/remove Trident explorer ([#171](https://github.com/Ackee-Blockchain/trident/pull/171))
- fix/snapshot's zeroed account as optional ([#170](https://github.com/Ackee-Blockchain/trident/pull/170))
- feat/fuzzer-stats-logging, an optional statistics output for fuzzing session ([#144](https://github.com/Ackee-Blockchain/trident/pull/144))

Expand Down
7 changes: 3 additions & 4 deletions crates/client/src/commander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Commander {
"The crash directory {} contains new fuzz test crashes. Exiting!",
crash_dir.to_string_lossy()
);
process::exit(1);
process::exit(99);
}
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ impl Commander {
res = child.wait() =>
match res {
Ok(status) => if !status.success() {
println!("Honggfuzz exited with an error!");
throw!(Error::FuzzingFailed);
},
Err(_) => throw!(Error::FuzzingFailed),
},
Expand Down Expand Up @@ -358,7 +358,7 @@ impl Commander {
match res {
Ok(status) => {
if !status.success() {
println!("Honggfuzz exited with an error!");
throw!(Error::FuzzingFailed);
}
},
Err(_) => throw!(Error::FuzzingFailed),
Expand All @@ -367,7 +367,6 @@ impl Commander {
_ = signal::ctrl_c() => {
fuzz_end.store(true, std::sync::atomic::Ordering::SeqCst);
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;

},
}
let stats_result = stats_handle
Expand Down
6 changes: 3 additions & 3 deletions examples/fuzz-tests/unchecked-arithmetic-0/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ validator_startup_timeout = 15000
# Timeout in seconds (default: 10)
timeout = 10
# Number of fuzzing iterations (default: 0 [no limit])
iterations = 0
iterations = 100
# Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2])
threads = 0
# Don't close children's stdin, stdout, stderr; can be noisy (default: false)
keep_output = false
# Disable ANSI console; use simple log output (default: false)
verbose = false
# Exit upon seeing the first crash (default: false)
exit_upon_crash = false
exit_upon_crash = true
# Maximal number of mutations per one run (default: 6)
mutations_per_run = 6
# Target compilation directory, (default: "" ["trident-tests/fuzz_tests/fuzzing/hfuzz_target"]).
Expand All @@ -38,4 +38,4 @@ save_all = false
allow_duplicate_txs = false
# Trident will show statistics after the fuzzing session. This option forces use of honggfuzz parameter
# `keep_output` as true in order to be able to catch fuzzer stdout. (default: false)
fuzzing_with_stats = false
fuzzing_with_stats = true

0 comments on commit 1cc34a4

Please sign in to comment.