Skip to content

Commit 458e618

Browse files
committed
Qcheck-lin test for MPMC queue
1 parent 9d77b47 commit 458e618

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

lockfree.opam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ depends: [
1414
"qcheck" {with-test & >= "0.18.1"}
1515
"qcheck-alcotest" {with-test & >= "0.18.1"}
1616
"yojson" {>= "2.0.2"}
17+
"qcheck-lin" {with-test}
1718
]
1819
depopts: []
1920
build: ["dune" "build" "-p" name "-j" jobs]

test/dune

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@
2121
(test
2222
(name qcheck_mpsc_queue)
2323
(libraries lockfree qcheck qcheck-alcotest)
24-
(modules qcheck_mpsc_queue))
24+
(modules qcheck_mpsc_queue))
25+
26+
(test
27+
(name lin_mpmc_queue)
28+
(libraries lockfree qcheck-lin.domain)
29+
(modules lin_mpmc_queue))

test/lin_mpmc_queue.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module Q = Lockfree.Mpmc_queue
2+
3+
module Test = struct
4+
type t = int Q.t
5+
6+
let init () = Q.make ~capacity:1 ()
7+
8+
let cleanup _ = ()
9+
10+
open Lin_base
11+
12+
let api =
13+
[ val_ "push" Q.push (t @-> int @-> returning unit)
14+
; val_ "pop" Q.pop (t @-> returning (option int))
15+
]
16+
end
17+
18+
module T = Lin_domain.Make (Test)
19+
20+
let () =
21+
QCheck_base_runner.run_tests_main
22+
[ T.lin_test ~count:10_000 ~name:"MPMC Queue" ]

0 commit comments

Comments
 (0)