Skip to content

Commit da96fc4

Browse files
committed
rebase on new packaging
1 parent 9639068 commit da96fc4

File tree

19 files changed

+79
-97
lines changed

19 files changed

+79
-97
lines changed

lib/stm/STM.ml renamed to lib/STM.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open QCheck
2-
include Common
2+
include Util
33

44
(** A revised state machine framework with parallel testing.
55
This version does not come with built-in GC commands. *)

lib/dune

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
(library
2-
(name common)
3-
(modules common))
4-
5-
(library
6-
(name util)
7-
(modules util)
8-
(libraries qcheck unix)
9-
(preprocess (pps ppx_deriving.show)))
10-
111
(library
122
(name STM)
13-
(public_name stm)
3+
(public_name multicorecheck.stm)
144
(modules STM)
15-
(libraries qcheck domainslib common))
5+
(libraries qcheck domainslib util))
166

177
(library
188
(name lin)
19-
(public_name lin)
9+
(public_name multicorecheck.lin)
2010
(modules lin)
21-
(libraries threads qcheck common))
11+
(libraries threads qcheck util))
12+
13+
(library
14+
(name util)
15+
(package multicorecheck)
16+
(modules util)
17+
(libraries qcheck unix))

lib/lin/lin.ml renamed to lib/lin.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
open QCheck
2-
include Common
2+
include Util
33

44
module type CmdSpec = sig
55
type t

lib/lin/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/stm/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/common.ml renamed to lib/util.ml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1+
(* Repeat a non-determistic property *)
2+
(* This is handy if the outcome depends on, e.g., scheduling. *)
13
let rec repeat n prop = fun input ->
24
if n<0 then failwith "repeat: negative repetition count";
35
if n=0
46
then true
57
else prop input && repeat (n-1) prop input
68

9+
let set_ci_printing () =
10+
if (Array.mem "--no-colors" Sys.argv)
11+
&& (Array.mem "--verbose" Sys.argv || Array.mem "-v" Sys.argv)
12+
then
13+
QCheck_base_runner.set_time_between_msg 2.5
14+
15+
exception Timeout
16+
17+
(* Test a property with a timeout. *)
18+
(* This is handy if the tested code can loop infinitely. *)
19+
let prop_timeout sec p x =
20+
Sys.(signal sigalrm (Signal_handle (fun _ -> raise Timeout))) |> ignore;
21+
ignore (Unix.alarm sec);
22+
let res = p x in
23+
ignore (Unix.alarm 0); (*cancel alarm*)
24+
res
25+
26+
27+
(* Test a property in a separate process - with a timeout. *)
28+
(* This is handy if the tested code can segfault or loop infinitely. *)
29+
let fork_prop_with_timeout sec p x =
30+
let a = Unix.fork () in
31+
match a with
32+
| 0 ->
33+
let _ = Unix.alarm sec in
34+
if p x
35+
then (ignore (Unix.alarm 0); exit 0) (*cancel alarm*)
36+
else (ignore (Unix.alarm 0); exit 2) (*cancel alarm*)
37+
| _ ->
38+
let _childid, retcode = Unix.wait () in
39+
(match retcode with
40+
| WEXITED code -> (0=code)
41+
| WSIGNALED _
42+
| WSTOPPED _ -> false)
43+
744
let print_triple_vertical ?(fig_indent=10) ?(res_width=20) show (seq,cmds1,cmds2) =
845
let seq,cmds1,cmds2 = List.(map show seq, map show cmds1, map show cmds2) in
946
let max_width ss = List.fold_left max 0 (List.map String.length ss) in
@@ -34,3 +71,9 @@ let print_triple_vertical ?(fig_indent=10) ?(res_width=20) show (seq,cmds1,cmds2
3471
print_par_cols (bar_cmd::cmds1) (bar_cmd::cmds2);
3572
Buffer.contents buf
3673

74+
let protect (f : 'a -> 'b) (a : 'a) : ('b, exn) result =
75+
try Result.Ok (f a)
76+
with e -> Result.Error e
77+
78+
let pp_exn fmt e = Format.fprintf fmt "%s" (Printexc.to_string e)
79+
let show_exn e = Format.asprintf "%a" e pp_exn

lib/util/dune

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/util/util.ml

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/domainslib/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(executable
1010
(name ws_deque_test)
1111
(modules ws_deque_test)
12-
(libraries util qcheck STM domainslib)
12+
(libraries qcheck STM domainslib)
1313
(preprocess (pps ppx_deriving.show)))
1414

1515
(env

src/domainslib/ws_deque_test.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(** Sequential tests of ws_deque *)
22

33
open QCheck
4+
open STM
45

56
module Ws_deque = Domainslib__Ws_deque
67

@@ -65,8 +66,8 @@ struct
6566
| RIs_empty of bool
6667
| RSize of int
6768
| RPush
68-
| RPop of int Util.protected
69-
| RSteal of int Util.protected [@@deriving show { with_path = false }]
69+
| RPop of (int, exn) result
70+
| RSteal of (int, exn) result [@@deriving show { with_path = false }]
7071

7172
let run c d = match c with
7273
| Is_empty -> RIs_empty (Ws_deque.M.is_empty d)

0 commit comments

Comments
 (0)