Skip to content

Commit

Permalink
Adapt the multicore tests to the new Lin interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shym committed Oct 19, 2022
1 parent dd8fd76 commit 6a78c51
Show file tree
Hide file tree
Showing 34 changed files with 170 additions and 143 deletions.
4 changes: 2 additions & 2 deletions src/array/dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(name lin_tests)
(modules lin_tests)
(flags (:standard -w -27))
(libraries lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq)))

; (rule
Expand All @@ -37,7 +37,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

(rule
(alias runtest)
Expand Down
6 changes: 3 additions & 3 deletions src/array/lin_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct
(* note to self:
- generate one t_var per input [t] parameter and
- record [Env.next] for each resulting [t] in an option *)
open Lin
open Lin_base.Lin_internal
type cmd =
| Length of Var.t
| Get of Var.t * int
Expand Down Expand Up @@ -113,10 +113,10 @@ struct
let cleanup _ = ()
end

module AT = Lin.Make(AConf)
module AT_domain = Lin_domain.Make_internal(AConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
AT.neg_lin_test `Domain ~count:1000 ~name:"Lin Array test with Domain";
AT_domain.neg_lin_test ~count:1000 ~name:"Lin Array test with Domain";
]
6 changes: 3 additions & 3 deletions src/array/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct
let init () = Array.make array_size 'a'
let cleanup _ = ()

open Lin_api
open Lin_base
let int,char = nat_small,char_printable
let array_to_seq a = List.to_seq (List.of_seq (Array.to_seq a)) (* workaround: Array.to_seq is lazy and will otherwise see and report later Array.set state changes... *)
let api =
Expand All @@ -29,10 +29,10 @@ struct
]
end

module AT = Lin_api.Make(AConf)
module AT_domain = Lin_domain.Make(AConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
AT.neg_lin_test `Domain ~count:1000 ~name:"Lin_api Array test with Domain";
AT_domain.neg_lin_test ~count:1000 ~name:"Lin_api Array test with Domain";
]
4 changes: 2 additions & 2 deletions src/atomic/dune
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(name lin_tests)
(modules lin_tests)
(flags (:standard -w -27))
(libraries lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq)))

; (rule
Expand All @@ -40,7 +40,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

(rule
(alias runtest)
Expand Down
6 changes: 3 additions & 3 deletions src/atomic/lin_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open QCheck
module AConf =
struct
type t = int Atomic.t
open Lin
open Lin_base.Lin_internal
type cmd =
| Make of int
| Get of Var.t
Expand Down Expand Up @@ -68,7 +68,7 @@ struct
let cleanup _ = ()
end

module AT = Lin.Make(AConf)
module AT_domain = Lin_domain.Make_internal(AConf)

(*
(** A variant of the above with 3 Atomics *)
Expand Down Expand Up @@ -118,6 +118,6 @@ module A3T = Lin.Make(A3Conf)
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
AT.lin_test `Domain ~count:1000 ~name:"Lin Atomic test with Domain";
AT_domain.lin_test ~count:1000 ~name:"Lin Atomic test with Domain";
(* A3T.lin_test `Domain ~count:1000 ~name:"Lin Atomic3 test with Domain"; *)
]
8 changes: 4 additions & 4 deletions src/atomic/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Atomic_spec : Lin_api.ApiSpec = struct
open Lin_api (* FIXME add Gen.nat *)
module Atomic_spec : Lin_base.Spec = struct
open Lin_base (* FIXME add Gen.nat *)
type t = int Atomic.t
let init () = Atomic.make 0
let cleanup _ = ()
Expand All @@ -15,10 +15,10 @@ module Atomic_spec : Lin_api.ApiSpec = struct
val_ "Atomic.decr" Atomic.decr (t @-> returning unit) ]
end

module Lin_atomic = Lin_api.Make (Atomic_spec)
module Lin_atomic_domain = Lin_domain.Make (Atomic_spec)

let () = Util.set_ci_printing ()
let () =
QCheck_base_runner.run_tests_main
[ Lin_atomic.lin_test `Domain ~count:1000 ~name:"Lin_api Atomic test with Domain";
[ Lin_atomic_domain.lin_test ~count:1000 ~name:"Lin_api Atomic test with Domain";
]
2 changes: 1 addition & 1 deletion src/bigarray/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

(executable
(name stm_tests)
Expand Down
6 changes: 3 additions & 3 deletions src/bigarray/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct
let init () = array_create array_size
let cleanup _ = ()

open Lin_api
open Lin_base
let int = int_small

let api =
Expand All @@ -61,10 +61,10 @@ struct
]
end

module BA1T = Lin_api.Make(BA1Conf)
module BA1T = Lin_domain.Make(BA1Conf)

let _ =
Util.set_ci_printing () ;
QCheck_base_runner.run_tests_main [
BA1T.neg_lin_test `Domain ~count:5000 ~name:"Lin_api Bigarray.Array1 (of ints) test with Domain";
BA1T.neg_lin_test ~count:5000 ~name:"Lin_api Bigarray.Array1 (of ints) test with Domain";
]
4 changes: 2 additions & 2 deletions src/bytes/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
(alias
(name default)
(package multicoretests)
(deps lin_tests_dsl.exe))
(deps lin_tests_dsl.exe stm_tests.exe))

;; Linearizability tests

(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain qcheck-lin.thread))

(executable
(name stm_tests)
Expand Down
10 changes: 6 additions & 4 deletions src/bytes/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module BConf = struct
let init () = Bytes.make 42 '0'
let cleanup _ = ()

open Lin_api
open Lin_base

let int = nat_small
(*let int = int_bound 10*)

Expand All @@ -29,11 +30,12 @@ module BConf = struct
val_ "Bytes.index_from" Bytes.index_from (t @-> int @-> char @-> returning_or_exc int)]
end

module BT = Lin_api.Make(BConf)
module BT_domain = Lin_domain.Make(BConf)
module BT_thread = Lin_thread.Make(BConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
BT.neg_lin_test `Domain ~count:1000 ~name:"Lin_api Bytes test with Domain";
BT.lin_test `Thread ~count:250 ~name:"Lin_api Bytes test with Thread";
BT_domain.neg_lin_test ~count:1000 ~name:"Lin_api Bytes test with Domain";
BT_thread.lin_test ~count:250 ~name:"Lin_api Bytes test with Thread";
]
2 changes: 1 addition & 1 deletion src/ephemeron/dune
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain qcheck-lin.thread))

(rule
(alias runtest)
Expand Down
9 changes: 5 additions & 4 deletions src/ephemeron/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module EConf =
let init () = E.create 42
let cleanup _ = ()

open Lin_api
open Lin_base
let int,string = nat_small, string_small_printable
let api =
[ val_ "Ephemeron.clear" E.clear (t @-> returning unit);
Expand All @@ -38,11 +38,12 @@ module EConf =
]
end

module ET = Lin_api.Make(EConf)
module ET_domain = Lin_domain.Make(EConf)
module ET_thread = Lin_thread.Make(EConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
ET.neg_lin_test `Domain ~count:1000 ~name:"Lin_api Ephemeron test with Domain";
ET.lin_test `Thread ~count:250 ~name:"Lin_api Ephemeron test with Thread";
ET_domain.neg_lin_test ~count:1000 ~name:"Lin_api Ephemeron test with Domain";
ET_thread.lin_test ~count:250 ~name:"Lin_api Ephemeron test with Thread";
]
2 changes: 1 addition & 1 deletion src/floatarray/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

(rule
(alias runtest)
Expand Down
6 changes: 3 additions & 3 deletions src/floatarray/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct
let init () = Float.Array.make array_size 0.0
let cleanup _ = ()

open Lin_api
open Lin_base
let int = int_small

(* fully evaluate the iterator, otherwise we get too many
Expand All @@ -33,10 +33,10 @@ struct
]
end

module FAT = Lin_api.Make(FAConf)
module FAT = Lin_domain.Make(FAConf)

let _ =
Util.set_ci_printing () ;
QCheck_base_runner.run_tests_main [
FAT.neg_lin_test `Domain ~count:1000 ~name:"Lin_api Float.Array test with Domain";
FAT.neg_lin_test ~count:1000 ~name:"Lin_api Float.Array test with Domain";
]
4 changes: 2 additions & 2 deletions src/hashtbl/dune
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(name lin_tests)
(modules lin_tests)
(flags (:standard -w -27))
(libraries lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq)))

; (rule
Expand All @@ -37,7 +37,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

(rule
(alias runtest)
Expand Down
6 changes: 3 additions & 3 deletions src/hashtbl/lin_tests.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open QCheck
open Lin
open Lin_base.Lin_internal

(** ********************************************************************** *)
(** Tests of thread-unsafe [Hashtbl] *)
Expand Down Expand Up @@ -95,10 +95,10 @@ struct
let cleanup _ = ()
end

module HT = Lin.Make(HConf)
module HT_domain = Lin_domain.Make_internal(HConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
HT.neg_lin_test `Domain ~count:1000 ~name:"Lin Hashtbl test with Domain";
HT_domain.neg_lin_test ~count:1000 ~name:"Lin Hashtbl test with Domain";
]
6 changes: 3 additions & 3 deletions src/hashtbl/lin_tests_dsl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct
let init () = Hashtbl.create ~random:false 42
let cleanup _ = ()

open Lin_api
open Lin_base
let int,char = nat_small,char_printable
let api =
[ val_ "Hashtbl.clear" Hashtbl.clear (t @-> returning unit);
Expand All @@ -24,10 +24,10 @@ struct
]
end

module HT = Lin_api.Make(HConf)
module HT_domain = Lin_domain.Make(HConf)
;;
Util.set_ci_printing ()
;;
QCheck_base_runner.run_tests_main [
HT.neg_lin_test `Domain ~count:1000 ~name:"Lin_api Hashtbl test with Domain";
HT_domain.neg_lin_test ~count:1000 ~name:"Lin_api Hashtbl test with Domain";
]
4 changes: 3 additions & 1 deletion src/internal/cleanup_lin.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open QCheck

module Lin = Lin_base.Lin_internal

(** This is a variant of refs to test for double cleanup *)

module RConf =
Expand Down Expand Up @@ -45,7 +47,7 @@ struct
| _, _ -> failwith (Printf.sprintf "unexpected command: %s" (show_cmd (snd c)))
end

module RT = Lin.Make(RConf)
module RT = Lin_domain.Make_internal(RConf)
;;
Util.set_ci_printing ()
;;
Expand Down
4 changes: 2 additions & 2 deletions src/internal/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(executable
(name util_print_test)
(modules util_print_test)
(libraries lin))
(libraries qcheck-multicoretests-util))

(rule
(alias runtest)
Expand All @@ -21,7 +21,7 @@
(executable
(name cleanup_lin)
(modules cleanup_lin)
(libraries lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq)))

(rule
Expand Down
4 changes: 2 additions & 2 deletions src/lazy/dune
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(executable
(name lin_tests)
(modules lin_tests)
(libraries lin)
(libraries qcheck-lin.domain)
(preprocess (pps ppx_deriving.show ppx_deriving.eq)))

; (rule
Expand All @@ -33,7 +33,7 @@
(executable
(name lin_tests_dsl)
(modules lin_tests_dsl)
(libraries lin))
(libraries qcheck-lin.domain))

; (rule
; (alias runtest)
Expand Down
Loading

0 comments on commit 6a78c51

Please sign in to comment.