File tree 13 files changed +183
-55
lines changed
13 files changed +183
-55
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ pub use self::{
13
13
run:: Run , tmin:: Tmin ,
14
14
} ;
15
15
16
- use std:: fmt as stdfmt;
17
16
use std:: str:: FromStr ;
17
+ use std:: { fmt as stdfmt, path:: PathBuf } ;
18
18
use structopt:: StructOpt ;
19
19
20
20
#[ derive( Debug , Clone , Copy , PartialEq ) ]
@@ -186,6 +186,23 @@ impl stdfmt::Display for BuildOptions {
186
186
}
187
187
}
188
188
189
+ #[ derive( Clone , Debug , StructOpt , PartialEq ) ]
190
+ pub struct FuzzDirWrapper {
191
+ /// The path to the fuzz project directory.
192
+ #[ structopt( long = "fuzz-dir" ) ]
193
+ pub fuzz_dir : Option < PathBuf > ,
194
+ }
195
+
196
+ impl stdfmt:: Display for FuzzDirWrapper {
197
+ fn fmt ( & self , f : & mut stdfmt:: Formatter ) -> stdfmt:: Result {
198
+ if let Some ( ref elem) = self . fuzz_dir {
199
+ write ! ( f, " --fuzz-dir={}" , elem. display( ) ) ?;
200
+ }
201
+
202
+ Ok ( ( ) )
203
+ }
204
+ }
205
+
189
206
#[ cfg( test) ]
190
207
mod test {
191
208
use super :: * ;
Original file line number Diff line number Diff line change 1
- use crate :: { project:: FuzzProject , RunCommand } ;
1
+ use crate :: { options :: FuzzDirWrapper , project:: FuzzProject , RunCommand } ;
2
2
use anyhow:: Result ;
3
3
use structopt:: StructOpt ;
4
4
5
5
#[ derive( Clone , Debug , StructOpt ) ]
6
6
pub struct Add {
7
+ #[ structopt( flatten) ]
8
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
9
+
7
10
/// Name of the new fuzz target
8
11
pub target : String ,
9
12
}
10
13
11
14
impl RunCommand for Add {
12
15
fn run_command ( & mut self ) -> Result < ( ) > {
13
- let project = FuzzProject :: find_existing ( ) ?;
16
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
14
17
project. add_target ( self )
15
18
}
16
19
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use structopt:: StructOpt ;
4
8
@@ -7,13 +11,16 @@ pub struct Build {
7
11
#[ structopt( flatten) ]
8
12
pub build : BuildOptions ,
9
13
14
+ #[ structopt( flatten) ]
15
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
16
+
10
17
/// Name of the fuzz target to build, or build all targets if not supplied
11
18
pub target : Option < String > ,
12
19
}
13
20
14
21
impl RunCommand for Build {
15
22
fn run_command ( & mut self ) -> Result < ( ) > {
16
- let project = FuzzProject :: find_existing ( ) ?;
23
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
17
24
project. exec_build ( & self . build , self . target . as_deref ( ) . map ( |s| s) )
18
25
}
19
26
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use std:: path:: PathBuf ;
4
8
use structopt:: StructOpt ;
@@ -8,6 +12,9 @@ pub struct Cmin {
8
12
#[ structopt( flatten) ]
9
13
pub build : BuildOptions ,
10
14
15
+ #[ structopt( flatten) ]
16
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
17
+
11
18
/// Name of the fuzz target
12
19
pub target : String ,
13
20
@@ -22,7 +29,7 @@ pub struct Cmin {
22
29
23
30
impl RunCommand for Cmin {
24
31
fn run_command ( & mut self ) -> Result < ( ) > {
25
- let project = FuzzProject :: find_existing ( ) ?;
32
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
26
33
project. exec_cmin ( self )
27
34
}
28
35
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use structopt:: StructOpt ;
4
8
@@ -7,6 +11,9 @@ pub struct Coverage {
7
11
#[ structopt( flatten) ]
8
12
pub build : BuildOptions ,
9
13
14
+ #[ structopt( flatten) ]
15
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
16
+
10
17
/// Name of the fuzz target
11
18
pub target : String ,
12
19
@@ -20,7 +27,7 @@ pub struct Coverage {
20
27
21
28
impl RunCommand for Coverage {
22
29
fn run_command ( & mut self ) -> Result < ( ) > {
23
- let project = FuzzProject :: find_existing ( ) ?;
30
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
24
31
self . build . coverage = true ;
25
32
project. exec_coverage ( self )
26
33
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use structopt:: StructOpt ;
4
8
@@ -9,6 +13,9 @@ pub struct Fmt {
9
13
#[ structopt( flatten) ]
10
14
pub build : BuildOptions ,
11
15
16
+ #[ structopt( flatten) ]
17
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
18
+
12
19
/// Name of fuzz target
13
20
pub target : String ,
14
21
@@ -18,7 +25,7 @@ pub struct Fmt {
18
25
19
26
impl RunCommand for Fmt {
20
27
fn run_command ( & mut self ) -> Result < ( ) > {
21
- let project = FuzzProject :: find_existing ( ) ?;
28
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
22
29
project. debug_fmt_input ( self )
23
30
}
24
31
}
Original file line number Diff line number Diff line change 1
- use crate :: { project:: FuzzProject , RunCommand } ;
1
+ use crate :: { options :: FuzzDirWrapper , project:: FuzzProject , RunCommand } ;
2
2
use anyhow:: Result ;
3
3
use structopt:: StructOpt ;
4
4
@@ -12,11 +12,14 @@ pub struct Init {
12
12
) ]
13
13
/// Name of the first fuzz target to create
14
14
pub target : String ,
15
+
16
+ #[ structopt( flatten) ]
17
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
15
18
}
16
19
17
20
impl RunCommand for Init {
18
21
fn run_command ( & mut self ) -> Result < ( ) > {
19
- FuzzProject :: init ( self ) ?;
22
+ FuzzProject :: init ( self , self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
20
23
Ok ( ( ) )
21
24
}
22
25
}
Original file line number Diff line number Diff line change 1
- use crate :: { project:: FuzzProject , RunCommand } ;
1
+ use crate :: { options :: FuzzDirWrapper , project:: FuzzProject , RunCommand } ;
2
2
use anyhow:: Result ;
3
3
use structopt:: StructOpt ;
4
4
5
5
#[ derive( Clone , Debug , StructOpt ) ]
6
- pub struct List { }
6
+ pub struct List {
7
+ #[ structopt( flatten) ]
8
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
9
+ }
7
10
8
11
impl RunCommand for List {
9
12
fn run_command ( & mut self ) -> Result < ( ) > {
10
- let project = FuzzProject :: find_existing ( ) ?;
13
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
11
14
project. list_targets ( )
12
15
}
13
16
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use structopt:: StructOpt ;
4
8
@@ -13,6 +17,9 @@ pub struct Run {
13
17
/// Custom corpus directories or artifact files.
14
18
pub corpus : Vec < String > ,
15
19
20
+ #[ structopt( flatten) ]
21
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
22
+
16
23
#[ structopt(
17
24
short = "j" ,
18
25
long = "jobs" ,
@@ -33,7 +40,7 @@ pub struct Run {
33
40
34
41
impl RunCommand for Run {
35
42
fn run_command ( & mut self ) -> Result < ( ) > {
36
- let project = FuzzProject :: find_existing ( ) ?;
43
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
37
44
project. exec_fuzz ( self )
38
45
}
39
46
}
Original file line number Diff line number Diff line change 1
- use crate :: { options:: BuildOptions , project:: FuzzProject , RunCommand } ;
1
+ use crate :: {
2
+ options:: { BuildOptions , FuzzDirWrapper } ,
3
+ project:: FuzzProject ,
4
+ RunCommand ,
5
+ } ;
2
6
use anyhow:: Result ;
3
7
use std:: path:: PathBuf ;
4
8
use structopt:: StructOpt ;
@@ -8,6 +12,9 @@ pub struct Tmin {
8
12
#[ structopt( flatten) ]
9
13
pub build : BuildOptions ,
10
14
15
+ #[ structopt( flatten) ]
16
+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
17
+
11
18
/// Name of the fuzz target
12
19
pub target : String ,
13
20
@@ -35,7 +42,7 @@ pub struct Tmin {
35
42
36
43
impl RunCommand for Tmin {
37
44
fn run_command ( & mut self ) -> Result < ( ) > {
38
- let project = FuzzProject :: find_existing ( ) ?;
45
+ let project = FuzzProject :: new ( self . fuzz_dir_wrapper . fuzz_dir . to_owned ( ) ) ?;
39
46
project. exec_tmin ( self )
40
47
}
41
48
}
You can’t perform that action at this time.
0 commit comments