Skip to content

Commit a4a635c

Browse files
committed
REMOVE ME: add Lin.thread stats for {int,int64} x {ref,CList}
1 parent ad1d5e4 commit a4a635c

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

lib/lin_thread.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ module Make_internal (Spec : Internal.CmdSpec [@alert "-internal"]) = struct
5454

5555
let neg_lin_test ~count ~name =
5656
neg_lin_test ~rep_count:100 ~count ~retries:5 ~name ~lin_prop:lin_prop
57+
58+
let lin_stats ~count =
59+
let rep_count = 25 in
60+
let seq_len,par_len = 20,12 in
61+
let exceptions = ref 0 in
62+
let t =
63+
QCheck.Test.make ~count
64+
(arb_cmds_triple seq_len par_len)
65+
(fun triple ->
66+
try (* On purpose we include repetition, because triggering issue is very rare *)
67+
Util.repeat rep_count lin_prop triple
68+
with _ ->
69+
incr exceptions;
70+
true) in
71+
QCheck.Test.check_exn t;
72+
!exceptions
5773
end
5874

5975
module Make (Spec : Spec) = Make_internal(MakeCmd(Spec))

lib/lin_thread.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,10 @@ module Make (Spec : Spec) : sig
4343
is found, and succeeds if a counter example is indeed found, and prints it
4444
afterwards.
4545
*)
46+
47+
val lin_stats : count:int -> int
48+
(** Repeatedly run a concurrent test based on {!Stdlib.Thread} and
49+
return how many times sequential consistency failed.
50+
Accepts a labeled parameter:
51+
[count] is the number of test iterations. *)
4652
end

src/neg_tests/dune

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@
118118
(action (progn))
119119
)
120120

121+
(executable
122+
(name lin_tests_thread_stats)
123+
(modules lin_tests_thread_stats)
124+
(flags (:standard -w -27))
125+
(libraries lin_tests_common qcheck-lin.thread)
126+
(modes native byte)
127+
)
128+
121129
(test
122130
(name lin_tests_effect)
123131
(modules lin_tests_effect)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
open Lin_tests_common
2+
3+
(** This is a driver of the negative tests over the Thread module *)
4+
5+
module CList_bis = struct include CList let add_node = add_node_thread end
6+
module RT_int_thread = Lin_thread.Make(Ref_int_spec)
7+
module RT_int64_thread = Lin_thread.Make(Ref_int64_spec)
8+
module CLT_int_thread = Lin_thread.Make(CList_spec_int(CList_bis))
9+
module CLT_int64_thread = Lin_thread.Make(CList_spec_int64(CList_bis))
10+
11+
let count = 10000
12+
13+
let failures = RT_int_thread.lin_stats ~count
14+
let () = Printf.printf "Lin int ref Thread %i / %i\n%!" failures count
15+
16+
let failures = RT_int64_thread.lin_stats ~count
17+
let () = Printf.printf "Lin int64 ref Thread %i / %i\n%!" failures count
18+
19+
let failures = CLT_int_thread.lin_stats ~count
20+
let () = Printf.printf "Lin int CList Thread %i / %i\n%!" failures count
21+
22+
let failures = CLT_int64_thread.lin_stats ~count
23+
let () = Printf.printf "Lin int64 CList Thread %i / %i\n%!" failures count

0 commit comments

Comments
 (0)