Skip to content

Commit

Permalink
Add simple fuzzing
Browse files Browse the repository at this point in the history
Related to #124
  • Loading branch information
dpc committed Oct 13, 2019
1 parent 3ee6d1e commit 7e9a865
Show file tree
Hide file tree
Showing 7 changed files with 521 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
target
Cargo.lock
./Cargo.lock
34 changes: 28 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
language: rust
rust:
- 1.20.0
- nightly
- beta
- stable
addons:
apt:
update: true
packages:
- binutils-dev
- libunwind8-dev
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
- cmake
- gcc
- libiberty-dev
matrix:
include:
- rust: 1.20.0
- rust: nightly
- rust: beta
env: DO_FUZZ=true
- rust: stable
env: DO_FUZZ=true
script: |
cargo build --verbose &&
cargo test --verbose &&
cargo test --verbose --features serde &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo check --verbose --no-default-features) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --features union) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose --all-features) &&
([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench)
([ $TRAVIS_RUST_VERSION != nightly ] || cargo bench --verbose bench) &&
if [ "$DO_FUZZ" = true ]
then
(
cd fuzz
./travis-fuzz.sh
)
fi
192 changes: 192 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "smallvec-fuzz"
version = "0.1.0"
authors = ["Dawid Ciężarkiewicz <[email protected]>"]
edition = "2018"
publish = false

[package.metadata]
cargo-fuzz = true

[features]
afl_fuzz = ["afl"]
honggfuzz_fuzz = ["honggfuzz"]


[dependencies]
honggfuzz = { version = "0.5.45", optional = true }
afl = { version = "0.4", optional = true }
smallvec = { path = ".." }

[workspace]
members = ["."]

[[bin]]
name = "smallvec_ops"
path = "fuzz_targets/smallvec_ops.rs"
12 changes: 12 additions & 0 deletions fuzz/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Fuzzer for smallvec

Based on fuzzing in [rust-bitcoin](https://github.com/rust-bitcoin/rust-bitcoin/tree/c8ac25219a09bf9d017f1b05abe3e746e2136f73/fuzz)

## Running manually with afl

```
cargo afl build --release --bin smallvec_ops --features afl && cargo afl fuzz -i in -o out target/release/smallvec_ops
```

# Useful links:
* https://rust-fuzz.github.io/book/afl.html
Loading

0 comments on commit 7e9a865

Please sign in to comment.