diff --git a/src/Engine.ml b/src/Engine.ml index 88444867c5ee4e23ca6b34650b717cb0890b5e3e..68f3a591189d89cba65529d9b70ce49b8a3cd886 100644 --- a/src/Engine.ml +++ b/src/Engine.ml @@ -1419,8 +1419,8 @@ let log scenario fuel = (* -------------------------------------------------------------------------- *) -(* [main_random_loop source prologue fuel] performs an unbounded number of - test runs in random mode. *) +(* [main_random_loop prologue fuel] performs an unbounded number of test runs + in random mode. *) (* While the tests run, we print information roughly every second. We print how many tests have been performed so far, our overall average speed, and @@ -1433,37 +1433,37 @@ let log scenario fuel = scenario. *) (* For each value of [fuel], we use an explicit infinite loop to perform an - unbounded number of runs. The source of random bits, which is specified by - the parameter [source], is opened just once, as it would be pointless to - close it and reopen it many times. *) + unbounded number of runs. *) -let rec main_random_loop source prologue fuel = +let rec main_random_loop prologue fuel = try - assert (source = None); - Gen.with_source source begin fun () -> - let granularity = 1000 in - let clock = Clock.make granularity in - (* An infinite loop. *) - while true do - (* Perform one run. *) - run prologue fuel; - (* Tick the clock and, once in a while, display statistics. *) - tick clock fuel - done - end + let granularity = 1000 in + let clock = Clock.make granularity in + (* An infinite loop. *) + while true do + (* Perform one run. *) + run prologue fuel; + (* Tick the clock and, once in a while, display statistics. *) + tick clock fuel + done with Abort (scenario, fuel) -> log scenario fuel; (* We have been able to find a problem with a certain amount of fuel. Try again, with this amount. This restricts our search space, and (with luck) we might now be able to find an even shorter scenario. *) - main_random_loop source prologue fuel + main_random_loop prologue fuel -(* [main_random source prologue fuel] performs an unbounded number of test +(* [main_random prologue fuel] performs an unbounded number of test runs in random mode. *) -let main_random source prologue fuel = - main_random_loop source prologue fuel +(* The source of random bits, /dev/urandom, is opened just once; + it would be pointless to close it and reopen it many times. *) + +let main_random prologue fuel = + let source = None in + Gen.with_source source @@ fun () -> + main_random_loop prologue fuel (* -------------------------------------------------------------------------- *) @@ -1499,4 +1499,4 @@ let main ?prologue:(prologue=none) fuel = | Some _ -> main_afl source prologue fuel | None -> - main_random source prologue fuel + main_random prologue fuel