Coverage Report

Created: 2026-03-31 07:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gitoxide/gix-attributes/fuzz/fuzz_targets/fuzz_search.rs
Line
Count
Source
1
#![no_main]
2
3
use anyhow::Result;
4
use libfuzzer_sys::fuzz_target;
5
6
use std::hint::black_box;
7
8
use arbitrary::{Arbitrary, Unstructured};
9
use gix_attributes::{
10
    search::{MetadataCollection, Outcome},
11
    Search,
12
};
13
use gix_glob::pattern::Case;
14
15
7.87k
fn arbitrary_case(u: &mut Unstructured) -> arbitrary::Result<Case> {
16
7.87k
    Ok(*u.choose(&[Case::Sensitive, Case::Fold])?)
17
7.87k
}
18
19
#[derive(Debug, Arbitrary)]
20
struct Ctx<'a> {
21
    pattern: &'a str,
22
    #[arbitrary(with = arbitrary_case)]
23
    case: Case,
24
}
25
26
7.87k
fn fuzz(Ctx { pattern, case }: Ctx) -> Result<()> {
27
7.87k
    let mut search = Search::default();
28
7.87k
    let mut collection = MetadataCollection::default();
29
7.87k
    search.add_patterns_buffer(
30
7.87k
        format!("{pattern} attr").as_bytes(),
31
7.87k
        Default::default(),
32
7.87k
        None,
33
7.87k
        &mut collection,
34
        true,
35
    );
36
7.87k
    let mut out = Outcome::default();
37
7.87k
    out.initialize(&collection);
38
7.87k
    _ = black_box(search.pattern_matching_relative_path("relative/path".into(), case, None, &mut out));
39
7.87k
    Ok(())
40
7.87k
}
41
42
fuzz_target!(|ctx: Ctx| {
43
    _ = black_box(fuzz(ctx));
44
});