Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💚 test fuzzing pipeline #167

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
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
Loading