8181 let init () = Hashtbl.create ~random:false 42
8282 let cleanup _ = ()
8383
84- open Lin_api
84+ open Lin_base
8585 let a,b = char_printable,nat_small
8686 let api =
8787 [ val_ "Hashtbl.add" Hashtbl.add (t @-> a @-> b @-> returning unit);
9191 val_ "Hashtbl.length" Hashtbl.length (t @-> returning int); ]
9292end
9393
94- module HT = Lin_api .Make(HashtblSig)
94+ module HT = Lin_domain .Make(HashtblSig)
9595;;
9696QCheck_base_runner.run_tests_main [
9797 HT.lin_test `Domain ~count:1000 ~name:"Hashtbl DSL test";
@@ -103,7 +103,7 @@ bindings `init` and `cleanup` for setting it up and tearing it down.
103103The ` api ` then contains a list of type signature descriptions using
104104combinators ` unit ` , ` bool ` , ` int ` , ` returning ` , ` returning_or_exc ` ,
105105... in the style of [ Ctypes] ( https://github.com/ocamllabs/ocaml-ctypes ) .
106- The functor ` Lin_api .Make` expects a description of the tested
106+ The functor ` Lin_domain .Make` expects a description of the tested
107107commands and outputs a module with a QCheck test ` lin_test ` that
108108performs the linearizability test.
109109
@@ -164,7 +164,7 @@ given below:
164164
165165``` ocaml
166166open QCheck
167- open STM
167+ open STM_base
168168
169169(** parallel STM tests of Hashtbl *)
170170
@@ -222,12 +222,13 @@ struct
222222 | _ -> false
223223end
224224
225- module HTest = STM.Make(HashtblModel)
225+ module HT_seq = STM_sequential.Make(HashtblModel)
226+ module HT_dom = STM_domain.Make(HashtblModel)
226227;;
227228QCheck_base_runner.run_tests_main
228229 (let count = 200 in
229- [HTest .agree_test ~count ~name:"Hashtbl test";
230- HTest .agree_test_par ~count ~name:"Hashtbl test"; ])
230+ [HT_seq .agree_test ~count ~name:"Hashtbl test sequential ";
231+ HT_dom .agree_test_par ~count ~name:"Hashtbl test parallel "; ])
231232```
232233
233234Again this requires a type ` sut ` for the system under test, and
@@ -257,18 +258,19 @@ example, this compares the Boolean result `r` from `Hashtbl.mem` with
257258the result from ` List.mem_assoc ` . Similarly ` precond ` expresses a
258259pre-condition.
259260
260- The module is phrased as a functor ` STM.Make ` and the resulting module
261- contains functions
262- - ` agree_test ` to test whether the model agrees with the ` sut ` across
261+ The module is phrased as functors:
262+ - the functor ` STM_sequential.Make ` produces a module with a function
263+ ` agree_test ` to test whether the model agrees with the ` sut ` across
263264 a sequential run of an arbitrary command sequence and
264- - ` agree_test_par ` which tests in parallel by ` spawn ` ing two domains
265+ - the functor ` STM_domain.Make ` produces a module with a function
266+ ` agree_test_par ` which tests in parallel by ` spawn ` ing two domains
265267 with ` Domain ` similarly to ` Lin ` and searches for a sequential
266268 interleaving over the model.
267269
268270When running the above with the command ` dune exec doc/example/stm_tests.exe `
269271one may obtain the following output:
270272```
271- Messages for test parallel Hashtbl test:
273+ Messages for test Hashtbl test parallel :
272274
273275 Results incompatible with linearized model
274276
@@ -313,11 +315,6 @@ property can be done in two different ways:
313315 cheaper so we can run more, Con: more tests are required to trigger a race)
314316
315317
316- In ` STM ` a functor ` STM.AddGC ` is also available. It inserts calls to
317- ` Gc.minor() ` at random points between the executed commands.
318-
319-
320-
321318Issues
322319======
323320
0 commit comments