Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monolith
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POTTIER Francois
monolith
Commits
49b308c9
Commit
49b308c9
authored
1 month ago
by
POTTIER Francois
Browse files
Options
Downloads
Patches
Plain Diff
[main_random]: take an optional parameter [timeout]; return number of discovered failures.
parent
4b998f60
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Engine.ml
+28
-15
28 additions, 15 deletions
src/Engine.ml
with
28 additions
and
15 deletions
src/Engine.ml
+
28
−
15
View file @
49b308c9
...
...
@@ -1419,8 +1419,8 @@ let log scenario fuel =
(* -------------------------------------------------------------------------- *)
(* [main_random_loop prologue clock fuel] performs an unbounded number of
test
runs in random mode. *)
(* [main_random_loop prologue clock fuel
accu
] 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
...
...
@@ -1435,7 +1435,14 @@ let log scenario fuel =
(* For each value of [fuel], we use an explicit infinite loop to perform an
unbounded number of runs. *)
let
rec
main_random_loop
prologue
clock
fuel
=
(* If the clock [clock] has no time limit, then [main_random_loop] never
terminates. If this clock has a time limit then [main_random_loop]
terminates once the time limit has been reached, and it returns the number
of failure scenarios that have been discovered and logged along the way.
The accumulator [accu] records the number of failure scenarios discovered
so far. *)
let
rec
main_random_loop
prologue
clock
fuel
(
accu
:
int
)
:
int
=
try
(* An infinite loop. *)
while
true
do
...
...
@@ -1443,14 +1450,19 @@ let rec main_random_loop prologue clock fuel =
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
prologue
clock
fuel
done
;
(* This cannot happen. *)
assert
false
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
prologue
clock
fuel
(
accu
+
1
)
|
Clock
.
Timeout
->
accu
(* [main_random prologue fuel] performs an unbounded number of test
runs in random mode. *)
...
...
@@ -1464,12 +1476,12 @@ let rec main_random_loop prologue clock fuel =
The main reason for this change is to allow imposing a time limit
on the whole process. *)
let
main_random
prologue
fuel
=
let
main_random
?
timeout
prologue
fuel
:
int
=
let
source
=
None
in
Gen
.
with_source
source
@@
fun
()
->
let
granularity
=
1000
in
let
clock
=
Clock
.
make
granularity
in
main_random_loop
prologue
clock
fuel
let
clock
=
Clock
.
make
?
timeout
granularity
in
main_random_loop
prologue
clock
fuel
0
(* -------------------------------------------------------------------------- *)
...
...
@@ -1505,4 +1517,5 @@ let main ?prologue:(prologue=none) fuel =
|
Some
_
->
main_afl
source
prologue
fuel
|
None
->
main_random
prologue
fuel
let
(
failures
:
int
)
=
main_random
prologue
fuel
in
ignore
failures
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment