Commit 19a43c2 1 parent 47b70fe commit 19a43c2 Copy full SHA for 19a43c2
File tree 6 files changed +48
-5
lines changed
6 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 108
108
Note: [s] is in this case the model's state prior to command execution. *)
109
109
end
110
110
111
+ module type SpecExt =
112
+ sig
113
+ include Spec
114
+
115
+ val wrap : (unit -> 'a ) -> 'a
116
+ end
117
+
118
+ module SpecDefaults =
119
+ struct
120
+ let cleanup = ignore
121
+ let precond _ _ = true
122
+ let wrap th = th ()
123
+ end
111
124
112
125
module Internal =
113
126
struct
Original file line number Diff line number Diff line change 126
126
This is helpful to model, e.g., a [remove] [cmd] that returns the removed element. *)
127
127
end
128
128
129
+ module type SpecExt =
130
+ sig
131
+ include Spec
132
+
133
+ val wrap : (unit -> 'a ) -> 'a
134
+ end
135
+
136
+ module SpecDefaults : sig
137
+ val cleanup : 'sut -> unit
138
+ val precond : 'cmd -> 'state -> bool
139
+ val wrap : (unit -> 'a ) -> 'a
140
+ end
129
141
130
142
module Internal : sig
131
143
open QCheck
Original file line number Diff line number Diff line change 1
1
open STM
2
2
3
- module Make (Spec : Spec ) = struct
3
+ module MakeExt (Spec : SpecExt ) = struct
4
4
5
5
open Util
6
6
open QCheck
@@ -24,9 +24,9 @@ module Make (Spec: Spec) = struct
24
24
25
25
let run_par seq_pref cmds1 cmds2 =
26
26
let sut = Spec. init_sut () in
27
- let pref_obs = interp_sut_res sut seq_pref in
27
+ let pref_obs = Spec. wrap @@ fun () -> interp_sut_res sut seq_pref in
28
28
let barrier = Atomic. make 2 in
29
- let main cmds () =
29
+ let main cmds () = Spec. wrap @@ fun () ->
30
30
Atomic. decr barrier;
31
31
while Atomic. get barrier <> 0 do Domain. cpu_relax() done ;
32
32
try Ok (interp_sut_res sut cmds) with exn -> Error exn
@@ -125,3 +125,9 @@ module Make (Spec: Spec) = struct
125
125
assume (all_interleavings_ok triple);
126
126
repeat rep_count agree_prop_par_asym triple) (* 25 times each, then 25 * 10 times when shrinking *)
127
127
end
128
+
129
+ module Make (Spec : Spec ) =
130
+ MakeExt (struct
131
+ include SpecDefaults
132
+ include Spec
133
+ end )
Original file line number Diff line number Diff line change @@ -96,3 +96,6 @@ module Make : functor (Spec : STM.Spec) ->
96
96
interleaving search like {!agree_test_par} and {!neg_agree_test_par}. *)
97
97
98
98
end
99
+
100
+ module MakeExt : functor (Spec : STM.SpecExt ) ->
101
+ module type of Make (Spec )
Original file line number Diff line number Diff line change 1
1
open STM
2
2
3
- module Make (Spec : Spec ) = struct
3
+ module MakeExt (Spec : SpecExt ) = struct
4
4
5
5
open QCheck
6
6
open Internal.Make (Spec)
@@ -18,7 +18,7 @@ module Make (Spec: Spec) = struct
18
18
let agree_prop cs =
19
19
assume (cmds_ok Spec. init_state cs);
20
20
let sut = Spec. init_sut () in (* reset system's state *)
21
- let res = try Ok (check_disagree Spec. init_state sut cs) with exn -> Error exn in
21
+ let res = try Ok (Spec. wrap @@ fun () -> check_disagree Spec. init_state sut cs) with exn -> Error exn in
22
22
let () = Spec. cleanup sut in
23
23
let res = match res with Ok res -> res | Error exn -> raise exn in
24
24
match res with
@@ -34,3 +34,9 @@ module Make (Spec: Spec) = struct
34
34
Test. make_neg ~name ~count (arb_cmds Spec. init_state) agree_prop
35
35
36
36
end
37
+
38
+ module Make (Spec : Spec ) =
39
+ MakeExt (struct
40
+ include SpecDefaults
41
+ include Spec
42
+ end )
Original file line number Diff line number Diff line change @@ -25,3 +25,6 @@ module Make : functor (Spec : STM.Spec) ->
25
25
(* * A negative agreement test (for convenience). Accepts two labeled parameters:
26
26
[count] is the test count and [name] is the printed test name. *)
27
27
end
28
+
29
+ module MakeExt : functor (Spec : STM.SpecExt ) ->
30
+ module type of Make (Spec )
You can’t perform that action at this time.
0 commit comments