File tree 12 files changed +156
-30
lines changed
12 files changed +156
-30
lines changed Original file line number Diff line number Diff line change 48
48
( and
49
49
( >= 1 .8.0)
50
50
:with -test) )
51
+ ( qcheck-core
52
+ ( and
53
+ ( >= 0 .21.2)
54
+ :with -test) )
55
+ ( qcheck-stm
56
+ ( and
57
+ ( >= 0 .3)
58
+ :with -test) )
51
59
( mdx
52
60
( and
53
61
( >= 2 .4.1)
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ depends: [
24
24
"multicore-magic" {>= "2.3.0"}
25
25
"domain_shims" {>= "0.1.0" & with-test}
26
26
"alcotest" {>= "1.8.0" & with-test}
27
+ "qcheck-core" {>= "0.21.2" & with-test}
28
+ "qcheck-stm" {>= "0.3" & with-test}
27
29
"mdx" {>= "2.4.1" & with-test}
28
30
"sherlodoc" {>= "0.2" & with-doc}
29
31
"odoc" {>= "2.4.2" & with-doc}
Original file line number Diff line number Diff line change 1
- (rule
2
- (enabled_if %{lib-available:qcheck-stm.domain})
3
- (action
4
- (copy stm_run.ocaml5.ml stm_run.ml)))
5
-
6
- (rule
7
- (enabled_if
8
- (not %{lib-available:qcheck-stm.domain}))
9
- (action
10
- (copy stm_run.ocaml4.ml stm_run.ml)))
11
-
12
1
(tests
13
2
(names
14
3
accumulator_test_stm
30
19
kcas_data
31
20
domain_shims
32
21
qcheck-core
33
- qcheck-core.runner
34
22
qcheck-stm.stm
35
- qcheck-stm.sequential
36
- qcheck-stm.thread
23
+ stm_run
37
24
(select
38
25
empty.ml
39
26
from
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ (rule
2
+ (enabled_if %{lib-available:qcheck-stm.domain})
3
+ (action
4
+ (copy stm_run.ocaml5.ml stm_run.ml)))
5
+
6
+ (rule
7
+ (enabled_if
8
+ (not %{lib-available:qcheck-stm.domain}))
9
+ (action
10
+ (copy stm_run.ocaml4.ml stm_run.ml)))
11
+
12
+ (library
13
+ (name stm_run)
14
+ (libraries
15
+ qcheck-core
16
+ qcheck-core.runner
17
+ qcheck-stm.stm
18
+ qcheck-stm.sequential
19
+ qcheck-stm.thread
20
+ unix
21
+ (select
22
+ empty.ml
23
+ from
24
+ (qcheck-stm.domain -> empty.ocaml5.ml)
25
+ (-> empty.ocaml4.ml))))
Original file line number Diff line number Diff line change
1
+ module type STM_domain = sig
2
+ module Spec : STM .Spec
3
+
4
+ val check_obs :
5
+ (Spec .cmd * STM .res ) list ->
6
+ (Spec .cmd * STM .res ) list ->
7
+ (Spec .cmd * STM .res ) list ->
8
+ Spec .state ->
9
+ bool
10
+
11
+ val all_interleavings_ok :
12
+ Spec .cmd list * Spec .cmd list * Spec .cmd list -> bool
13
+
14
+ val arb_cmds_triple :
15
+ int ->
16
+ int ->
17
+ (Spec .cmd list * Spec .cmd list * Spec .cmd list ) QCheck .arbitrary
18
+
19
+ val arb_triple :
20
+ int ->
21
+ int ->
22
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
23
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
24
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
25
+ (Spec .cmd list * Spec .cmd list * Spec .cmd list ) QCheck .arbitrary
26
+
27
+ val arb_triple_asym :
28
+ int ->
29
+ int ->
30
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
31
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
32
+ (Spec .state -> Spec .cmd QCheck .arbitrary ) ->
33
+ (Spec .cmd list * Spec .cmd list * Spec .cmd list ) QCheck .arbitrary
34
+
35
+ val interp_sut_res : Spec .sut -> Spec .cmd list -> (Spec .cmd * STM .res ) list
36
+ val agree_prop_par : Spec .cmd list * Spec .cmd list * Spec .cmd list -> bool
37
+
38
+ val agree_prop_par_asym :
39
+ Spec .cmd list * Spec .cmd list * Spec .cmd list -> bool
40
+
41
+ val agree_test_par : count :int -> name :string -> QCheck.Test .t
42
+ val neg_agree_test_par : count :int -> name :string -> QCheck.Test .t
43
+ val agree_test_par_asym : count :int -> name :string -> QCheck.Test .t
44
+ val neg_agree_test_par_asym : count :int -> name :string -> QCheck.Test .t
45
+ end
Original file line number Diff line number Diff line change
1
+ include Intf
2
+
3
+ let count =
4
+ let factor b = if b then 10 else 1 in
5
+ factor (64 < = Sys. word_size) * factor (Sys. backend_type = Native ) * 10
6
+
7
+ let run ?(verbose = true ) ?(count = count) ?(budgetf = 60.0 ) ~name ?make_domain
8
+ (module Spec : STM.Spec ) =
9
+ let module Seq = STM_sequential. Make (Spec ) in
10
+ let module Con = STM_thread. Make (Spec ) [@ alert " -experimental" ] in
11
+ Util. run_with_budget ~budgetf ~count @@ fun count ->
12
+ [
13
+ [ Seq. agree_test ~count ~name: (name ^ " sequential" ) ];
14
+ (match make_domain with
15
+ | None -> [ Con. agree_test_conc ~count ~name: (name ^ " concurrent" ) ]
16
+ | Some _ -> [] );
17
+ ]
18
+ |> List. concat
19
+ |> QCheck_base_runner. run_tests ~verbose
Original file line number Diff line number Diff line change
1
+ include Intf
2
+
3
+ let count =
4
+ let factor b = if b then 10 else 1 in
5
+ factor (64 < = Sys. word_size)
6
+ * factor (Sys. backend_type = Native )
7
+ * factor (1 < Domain. recommended_domain_count () )
8
+
9
+ let run (type cmd state sut ) ?(verbose = true ) ?(count = count)
10
+ ?(budgetf = 60.0 ) ~name ?make_domain
11
+ (module Spec : STM.Spec
12
+ with type cmd = cmd
13
+ and type state = state
14
+ and type sut = sut ) =
15
+ let module Seq = STM_sequential. Make (Spec ) in
16
+ let module Dom = struct
17
+ module Spec = Spec
18
+ include STM_domain. Make (Spec )
19
+ end in
20
+ Util. run_with_budget ~budgetf ~count @@ fun count ->
21
+ [
22
+ [ Seq. agree_test ~count ~name: (name ^ " sequential" ) ];
23
+ (match make_domain with
24
+ | None -> [ Dom. agree_test_par ~count ~name: (name ^ " parallel" ) ]
25
+ | Some make_domain ->
26
+ make_domain ~count ~name
27
+ (module Dom : STM_domain
28
+ with type Spec. cmd = cmd
29
+ and type Spec. state = state
30
+ and type Spec. sut = sut));
31
+ ]
32
+ |> List. concat
33
+ |> QCheck_base_runner. run_tests ~verbose
Original file line number Diff line number Diff line change
1
+ let run_with_budget ~budgetf ~count run =
2
+ let state = Random.State. make_self_init () in
3
+ let start = Unix. gettimeofday () in
4
+ let rec loop ~total n =
5
+ let current = Unix. gettimeofday () in
6
+ if current -. start < = budgetf && total < count then begin
7
+ let count =
8
+ if total = 0 then n
9
+ else
10
+ let per_test = (current -. start) /. Float. of_int total in
11
+ let max_count =
12
+ Float. to_int ((start +. budgetf -. current) /. per_test)
13
+ in
14
+ Int. min (Int. min n (count - total)) max_count |> Int. max 32
15
+ in
16
+ let seed = Random.State. full_int state Int. max_int in
17
+ QCheck_base_runner. set_seed seed;
18
+ let error_code = run count in
19
+ if error_code = 0 then loop ~total: (total + count) (n * 2 ) else error_code
20
+ end
21
+ else 0
22
+ in
23
+ loop ~total: 0 32
You can’t perform that action at this time.
0 commit comments