Skip to content

Commit b3d4eee

Browse files
committed
Nicify README
1 parent 57cb48b commit b3d4eee

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,44 @@ libFuzzer relies on LLVM sanitizer support. The Rust compiler has built-in suppo
66

77
# How to use
88

9-
“Manual” usage of this library looks like this:
9+
Use [cargo-fuzz].
10+
11+
[cargo-fuzz]: https://github.com/rust-fuzz/cargo-fuzz
12+
13+
This crate can also be used manually as following:
14+
15+
First create a new cargo project:
1016

1117
```
1218
$ cargo new --bin fuzzed
1319
$ cd fuzzed
20+
```
21+
22+
Then add a dependency on the fuzzer-sys crate and your own crate:
1423

15-
$ tail Cargo.toml -n2 # add libfuzzer-sys dependency
24+
```toml
1625
[dependencies]
17-
fuzzer-sys = { path = "../libfuzzer-sys" } # or something
26+
fuzzer-sys = { path = "../libfuzzer-sys" } # or something, will eventually publish to crates.io
27+
your_crate = "*" # or something
28+
```
1829

19-
$ cat src/main.rs
30+
and change the `src/main.rs` to fuzz your code:
31+
32+
```rust
2033
#![no_main]
2134

2235
#[macro_use]
2336
extern crate fuzzer_sys;
37+
extern crate your_crate;
2438

2539
fuzz_target!(|data| {
2640
// code to fuzz goes here
2741
});
42+
```
2843

44+
Finally, run the following commands:
45+
46+
```
2947
$ cargo rustc -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=3' -Z sanitizer=address -Cpanic=abort
3048
$ ./target/debug/fuzzed # runs fuzzing
3149
```
32-
33-
For a nice wrapper see [cargo-fuzz].
34-
35-
[cargo-fuzz]: https://github.com/rust-fuzz/cargo-fuzz

0 commit comments

Comments
 (0)