File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -3,5 +3,13 @@ name = "example"
3
3
version = " 0.0.0"
4
4
authors = [
" Paul Grandperrin <[email protected] >" ]
5
5
6
+ [[bin ]]
7
+ name = " example"
8
+ path = " src/main.rs"
9
+
10
+ [[bin ]]
11
+ name = " arbitrary-example"
12
+ path = " src/arbitrary_main.rs"
13
+
6
14
[dependencies ]
7
15
honggfuzz = {path = " .." }
Original file line number Diff line number Diff line change
1
+ #[ macro_use] extern crate honggfuzz;
2
+
3
+ fn main ( ) {
4
+ // Here you can parse `std::env::args and
5
+ // setup / initialize your project
6
+
7
+ // You have full control over the loop but
8
+ // you're supposed to call `fuzz` ad vitam aeternam
9
+ loop {
10
+ // The fuzz macro gives an arbitrary object (see `arbitrary crate`)
11
+ // to a closure-like block of code.
12
+ // For performance, it is recommended that you use the native type
13
+ // `&[u8]` when possible.
14
+ // Here, this tuple will contain three "random" values of different type.
15
+ fuzz ! ( |data: ( bool , i32 , f32 ) | {
16
+
17
+ if data. 0 == false { return }
18
+ if data. 1 < 0 { return }
19
+ if data. 2 > 1.0 { return }
20
+ panic!( "BOOM" )
21
+
22
+ } ) ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ RUSTFLAGS="" cargo build
82
82
83
83
# but when we run it, it should fail with a useful error message and status 17
84
84
set +e
85
- RUSTFLAGS=" " cargo run
85
+ RUSTFLAGS=" " cargo run --bin example
86
86
status=$?
87
87
set -e
88
88
test $status -eq 17
You can’t perform that action at this time.
0 commit comments