Skip to content

Commit d495b7f

Browse files
committed
[Fuzzer] refactor
1 parent a548ae0 commit d495b7f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/fuzzer.ml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ let change_suffix filename suffix =
7575
let base = Filename.chop_suffix filename (Filename.extension filename) in
7676
base ^ suffix
7777

78-
let mutate_seed llctx llset seed =
78+
let run_mutator llctx seed =
7979
let muts = !Config.muts_dir in
8080
let seedfile =
8181
ALlvm.save_ll muts (F.sprintf "id:%010d.ll" (ALlvm.hash_llm seed)) seed
8282
in
8383
let mutant_file = change_suffix seedfile ".mut.ll" |> Filename.basename in
84-
let mut_parts = change_suffix seedfile ".mutated" in
8584
let llmutate_args =
8685
if !Config.mutation = Config.FuzzingMode.Uniform then
8786
[ "llmutate"; seedfile; muts; mutant_file; "-no-focus"; ">> log.txt" ]
@@ -90,16 +89,19 @@ let mutate_seed llctx llset seed =
9089

9190
AUtil.cmd llmutate_args |> ignore;
9291

93-
let mutant = ALlvm.read_ll llctx (Filename.concat muts mutant_file) in
94-
match mutant with
95-
| Ok mutant when ALlvm.LLModuleSet.mem llset mutant -> None
92+
match ALlvm.read_ll llctx (Filename.concat muts mutant_file) with
9693
| Ok mutant ->
97-
let importants =
98-
In_channel.with_open_text mut_parts In_channel.input_all
99-
in
100-
Some (mutant, importants)
94+
let mutated = change_suffix seedfile ".mutated" in
95+
let neighbors = In_channel.with_open_text mutated In_channel.input_all in
96+
Some (mutant, neighbors)
10197
| Error _ -> None
10298

99+
let mutate_seed llctx llset seed =
100+
match run_mutator llctx seed with
101+
| Some (mutant, neighbors) when not (ALlvm.LLModuleSet.mem llset mutant) ->
102+
Some (mutant, neighbors)
103+
| _ -> None
104+
103105
let update_progress progress seed =
104106
let cov_set = Seedpool.Seed.edge_cov seed in
105107
progress |> Progress.add_cov cov_set |> Progress.inc_gen

0 commit comments

Comments
 (0)