Git object storage and pack files for Eio

fix(lint): add gen_corpus.ml and runtest rules to 5 fuzz directories

E718: Add gen_corpus.ml to ocaml-crypto, ocaml-csrf, ocaml-git,
ocaml-github-oauth, ocaml-gpt
E724: Add (rule (alias runtest) ...) for property-based testing

+34 -15
+1 -1
bench/pack_bench.ml
··· 22 22 in 23 23 () 24 24 done; 25 - Printf.printf "Done: folded %d objects x 100 iterations\n%!" 25 + Fmt.pr "Done: folded %d objects x 100 iterations\n%!" 26 26 (Git.Pack.count pack)
+11 -6
fuzz/dune
··· 3 3 (modules fuzz fuzz_common fuzz_index fuzz_config) 4 4 (libraries git crowbar)) 5 5 6 - ; Quick check with Crowbar (no AFL instrumentation) 6 + (executable 7 + (name gen_corpus) 8 + (modules gen_corpus) 9 + (libraries unix)) 10 + 7 11 (rule 8 - (alias fuzz) 12 + (alias runtest) 9 13 (deps fuzz.exe) 10 - (action (run %{exe:fuzz.exe}))) 14 + (action 15 + (run %{exe:fuzz.exe}))) 11 16 12 - ; AFL-instrumented build target 13 17 (rule 14 - (alias fuzz-afl) 18 + (alias fuzz) 15 19 (deps fuzz.exe) 16 - (action (echo "AFL fuzzer built: %{exe:fuzz.exe}\n"))) 20 + (action 21 + (echo "AFL fuzzer built: %{exe:fuzz.exe}\n")))
+17
fuzz/gen_corpus.ml
··· 1 + (** Generate seed corpus for fuzz testing. *) 2 + 3 + let () = 4 + (try Unix.mkdir "corpus" 0o755 5 + with Unix.Unix_error (Unix.EEXIST, _, _) -> ()); 6 + let write name data = 7 + let oc = open_out_bin (Filename.concat "corpus" name) in 8 + output_string oc data; 9 + close_out oc 10 + in 11 + write "seed_000" ""; 12 + write "seed_001" "\x00\x00\x00\x00"; 13 + write "seed_002" "DIRC\x00\x00\x00\x02"; 14 + write "seed_003" "[core]\n\tbare = false\n"; 15 + write "seed_004" "blob 5\x00hello"; 16 + write "seed_005" (String.make 20 '\xab'); 17 + write "seed_006" "tree 0\x00"
+1 -3
test/test_common.mli
··· 1 1 (** Shared test utilities. *) 2 2 3 3 val hash : Git.Hash.t Alcotest.testable 4 - 5 - val with_temp_repo : 6 - (Eio.Fs.dir_ty Eio.Path.t -> Fpath.t -> 'a) -> 'a 4 + val with_temp_repo : (Eio.Fs.dir_ty Eio.Path.t -> Fpath.t -> 'a) -> 'a 7 5 8 6 val commit : 9 7 repo:Git.Repository.t ->
+3 -3
test/test_pack.ml
··· 218 218 let oc = open_out file in 219 219 (* Write 10KB of content - enough to trigger delta compression *) 220 220 for i = 1 to 500 do 221 - Printf.fprintf oc "Line %d: This is some repetitive content.\n" i 221 + Fmt.pf oc "Line %d: This is some repetitive content.\n" i 222 222 done; 223 223 close_out oc; 224 224 ignore (run_git tmp_dir [ "add"; "large.txt" ]); ··· 226 226 (* Modify just a few lines - this will create a delta *) 227 227 let oc = open_out file in 228 228 for i = 1 to 500 do 229 - if i = 250 then Printf.fprintf oc "Line %d: MODIFIED CONTENT HERE!\n" i 230 - else Printf.fprintf oc "Line %d: This is some repetitive content.\n" i 229 + if i = 250 then Fmt.pf oc "Line %d: MODIFIED CONTENT HERE!\n" i 230 + else Fmt.pf oc "Line %d: This is some repetitive content.\n" i 231 231 done; 232 232 close_out oc; 233 233 ignore (run_git tmp_dir [ "add"; "large.txt" ]);
+1 -2
test/test_pack_index.ml
··· 76 76 "valid kind" true 77 77 (match kind with `Commit | `Tree | `Blob | `Tag -> true) 78 78 | Error (`Msg m) -> 79 - Alcotest.fail 80 - (Printf.sprintf "object %d at offset %d: %s" i offset m) 79 + Alcotest.fail (Fmt.str "object %d at offset %d: %s" i offset m) 81 80 done 82 81 | Error (`Msg m), _ -> Alcotest.fail ("pack: " ^ m) 83 82 | _, Error (`Msg m) -> Alcotest.fail ("index: " ^ m)