Coverage Report

Created: 2026-07-14 07:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gitoxide/gix-merge/fuzz/fuzz_targets/blob.rs
Line
Count
Source
1
#![no_main]
2
use anyhow::Result;
3
use arbitrary::Arbitrary;
4
use gix_merge::blob::builtin_driver::text::{self, Conflict, ConflictStyle};
5
use gix_merge::blob::Resolution;
6
use libfuzzer_sys::fuzz_target;
7
use std::hint::black_box;
8
use std::num::NonZero;
9
10
5.11k
fn fuzz_text_merge(
11
5.11k
    Ctx {
12
5.11k
        base,
13
5.11k
        ours,
14
5.11k
        theirs,
15
5.11k
        marker_size,
16
5.11k
    }: Ctx,
17
5.11k
) -> Result<()> {
18
5.11k
    let mut buf = Vec::new();
19
5.11k
    let mut input = imara_diff::InternedInput::default();
20
    // Fuzz this merge entrypoint with Histogram only. Repetitive adversarial text can drive the
21
    // Myers-family algorithms into pathological runtimes under sanitizer and coverage
22
    // instrumentation, which makes them unsuitable for this libFuzzer target and obscures
23
    // gix-merge-specific bugs behind diff-algorithm timeouts.
24
10.2k
    for (left, right) in [(ours, theirs), (theirs, ours)] {
25
10.2k
        input.clear();
26
10.2k
        let prepared = text::Merge::new(&mut input, left, base, right, imara_diff::Algorithm::Histogram);
27
10.2k
        let resolution = prepared.run(&mut buf, Default::default(), Conflict::default());
28
10.2k
        if resolution == Resolution::Conflict {
29
46.6k
            for conflict in [
30
9.33k
                Conflict::ResolveWithOurs,
31
9.33k
                Conflict::ResolveWithTheirs,
32
9.33k
                Conflict::ResolveWithUnion,
33
9.33k
                Conflict::Keep {
34
9.33k
                    style: ConflictStyle::Diff3,
35
9.33k
                    marker_size,
36
9.33k
                },
37
9.33k
                Conflict::Keep {
38
9.33k
                    style: ConflictStyle::ZealousDiff3,
39
9.33k
                    marker_size,
40
9.33k
                },
41
46.6k
            ] {
42
46.6k
                prepared.run(&mut buf, Default::default(), conflict);
43
46.6k
            }
44
896
        }
45
    }
46
5.11k
    Ok(())
47
5.11k
}
48
49
#[derive(Debug, Arbitrary)]
50
struct Ctx<'a> {
51
    base: &'a [u8],
52
    ours: &'a [u8],
53
    theirs: &'a [u8],
54
    marker_size: NonZero<u8>,
55
}
56
57
fuzz_target!(|ctx: Ctx<'_>| {
58
    _ = black_box(fuzz_text_merge(ctx));
59
});