File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
gix-ref/fuzz/fuzz_targets Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 1
1
#![ no_main]
2
2
3
3
use anyhow:: Result ;
4
+ use arbitrary:: Arbitrary ;
4
5
use gix_ref:: file:: log;
5
6
use libfuzzer_sys:: fuzz_target;
6
7
use std:: hint:: black_box;
7
8
8
- fn fuzz ( line : & [ u8 ] ) -> Result < ( ) > {
9
- let line = log:: LineRef :: from_bytes ( line) ?;
9
+ #[ derive( Arbitrary , Debug ) ]
10
+ struct Ctx < ' a > {
11
+ line_ref : & ' a [ u8 ] ,
12
+ multi_line_reverse : & ' a [ u8 ] ,
13
+ multi_line_forward : & ' a [ u8 ] ,
14
+ }
15
+
16
+ fn fuzz ( ctx : Ctx ) -> Result < ( ) > {
17
+ let line = log:: LineRef :: from_bytes ( ctx. line_ref ) ?;
10
18
_ = black_box ( line. previous_oid ( ) ) ;
11
19
_ = black_box ( line. new_oid ( ) ) ;
20
+
21
+ let mut buf = [ 0u8 ; 1024 ] ;
22
+ let read = std:: io:: Cursor :: new ( ctx. multi_line_reverse ) ;
23
+ let mut iter = gix_ref:: file:: log:: iter:: reverse ( read, & mut buf) ?;
24
+ _ = black_box ( iter. map ( |x| black_box ( x) ) . count ( ) ) ;
25
+
26
+ let mut iter = gix_ref:: file:: log:: iter:: forward ( ctx. multi_line_forward ) ;
27
+ _ = black_box ( iter. map ( |x| black_box ( x) ) . count ( ) ) ;
28
+
12
29
Ok ( ( ) )
13
30
}
14
31
15
- fuzz_target ! ( |ctx: & [ u8 ] | {
32
+ fuzz_target ! ( |ctx: Ctx | {
16
33
_ = black_box( fuzz( ctx) ) ;
17
34
} ) ;
You can’t perform that action at this time.
0 commit comments