-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
stm_run
private lib (from Picos) with time based deadline
Some of the tests just take too much time on some of the OCaml CI machines.
- Loading branch information
Showing
10 changed files
with
147 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(rule | ||
(enabled_if %{lib-available:qcheck-stm.domain}) | ||
(action | ||
(copy stm_run.ocaml5.ml stm_run.ml))) | ||
|
||
(rule | ||
(enabled_if | ||
(not %{lib-available:qcheck-stm.domain})) | ||
(action | ||
(copy stm_run.ocaml4.ml stm_run.ml))) | ||
|
||
(library | ||
(name stm_run) | ||
(package kcas_data) | ||
(libraries | ||
qcheck-core | ||
qcheck-core.runner | ||
qcheck-stm.stm | ||
qcheck-stm.sequential | ||
qcheck-stm.thread | ||
unix | ||
(select | ||
empty.ml | ||
from | ||
(qcheck-stm.domain -> empty.ocaml5.ml) | ||
(-> empty.ocaml4.ml)))) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module type STM_domain = sig | ||
module Spec : STM.Spec | ||
|
||
val check_obs : | ||
(Spec.cmd * STM.res) list -> | ||
(Spec.cmd * STM.res) list -> | ||
(Spec.cmd * STM.res) list -> | ||
Spec.state -> | ||
bool | ||
|
||
val all_interleavings_ok : | ||
Spec.cmd list * Spec.cmd list * Spec.cmd list -> bool | ||
|
||
val arb_cmds_triple : | ||
int -> | ||
int -> | ||
(Spec.cmd list * Spec.cmd list * Spec.cmd list) QCheck.arbitrary | ||
|
||
val arb_triple : | ||
int -> | ||
int -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.cmd list * Spec.cmd list * Spec.cmd list) QCheck.arbitrary | ||
|
||
val arb_triple_asym : | ||
int -> | ||
int -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.state -> Spec.cmd QCheck.arbitrary) -> | ||
(Spec.cmd list * Spec.cmd list * Spec.cmd list) QCheck.arbitrary | ||
|
||
val interp_sut_res : Spec.sut -> Spec.cmd list -> (Spec.cmd * STM.res) list | ||
val agree_prop_par : Spec.cmd list * Spec.cmd list * Spec.cmd list -> bool | ||
|
||
val agree_prop_par_asym : | ||
Spec.cmd list * Spec.cmd list * Spec.cmd list -> bool | ||
|
||
val agree_test_par : count:int -> name:string -> QCheck.Test.t | ||
val neg_agree_test_par : count:int -> name:string -> QCheck.Test.t | ||
val agree_test_par_asym : count:int -> name:string -> QCheck.Test.t | ||
val neg_agree_test_par_asym : count:int -> name:string -> QCheck.Test.t | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
include Intf | ||
|
||
let count = | ||
let factor b = if b then 10 else 1 in | ||
factor (64 <= Sys.word_size) * factor (Sys.backend_type = Native) * 10 | ||
|
||
let run ?(verbose = true) ?(count = count) ?(budgetf = 60.0) ~name ?make_domain | ||
(module Spec : STM.Spec) = | ||
let module Seq = STM_sequential.Make (Spec) in | ||
let module Con = STM_thread.Make (Spec) [@alert "-experimental"] in | ||
Util.run_with_budget ~budgetf ~count @@ fun count -> | ||
[ | ||
[ Seq.agree_test ~count ~name:(name ^ " sequential") ]; | ||
(match make_domain with | ||
| None -> [ Con.agree_test_conc ~count ~name:(name ^ " concurrent") ] | ||
| Some _ -> []); | ||
] | ||
|> List.concat | ||
|> QCheck_base_runner.run_tests ~verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
include Intf | ||
|
||
let count = | ||
let factor b = if b then 10 else 1 in | ||
factor (64 <= Sys.word_size) | ||
* factor (Sys.backend_type = Native) | ||
* factor (1 < Domain.recommended_domain_count ()) | ||
|
||
let run (type cmd state sut) ?(verbose = true) ?(count = count) | ||
?(budgetf = 60.0) ~name ?make_domain | ||
(module Spec : STM.Spec | ||
with type cmd = cmd | ||
and type state = state | ||
and type sut = sut) = | ||
let module Seq = STM_sequential.Make (Spec) in | ||
let module Dom = struct | ||
module Spec = Spec | ||
include STM_domain.Make (Spec) | ||
end in | ||
Util.run_with_budget ~budgetf ~count @@ fun count -> | ||
[ | ||
[ Seq.agree_test ~count ~name:(name ^ " sequential") ]; | ||
(match make_domain with | ||
| None -> [ Dom.agree_test_par ~count ~name:(name ^ " parallel") ] | ||
| Some make_domain -> | ||
make_domain ~count ~name | ||
(module Dom : STM_domain | ||
with type Spec.cmd = cmd | ||
and type Spec.state = state | ||
and type Spec.sut = sut)); | ||
] | ||
|> List.concat | ||
|> QCheck_base_runner.run_tests ~verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let run_with_budget ~budgetf ~count run = | ||
let state = Random.State.make_self_init () in | ||
let start = Unix.gettimeofday () in | ||
let rec loop ~total n = | ||
let current = Unix.gettimeofday () in | ||
if current -. start <= budgetf && total < count then begin | ||
let count = | ||
if total = 0 then n | ||
else | ||
let per_test = (current -. start) /. Float.of_int total in | ||
let max_count = | ||
Float.to_int ((start +. budgetf -. current) /. per_test) | ||
in | ||
Int.min (Int.min n (count - total)) max_count |> Int.max 32 | ||
in | ||
let seed = Random.State.full_int state Int.max_int in | ||
QCheck_base_runner.set_seed seed; | ||
let error_code = run count in | ||
if error_code = 0 then loop ~total:(total + count) (n * 2) else error_code | ||
end | ||
else 0 | ||
in | ||
loop ~total:0 32 |