Skip to content

Commit 6ac7efe

Browse files
committed
add spinlock test
1 parent d21fe3a commit 6ac7efe

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/dune

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@
77
(name test_simple)
88
(modules test_simple)
99
(libraries dscheck))
10+
11+
(executable
12+
(name test_spinlock)
13+
(modules test_spinlock)
14+
(libraries dscheck))

tests/test_spinlock.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Atomic = Dscheck.TracedAtomic
2+
3+
let test () =
4+
let lock = Atomic.make true in
5+
let result = Atomic.make 0 in
6+
Atomic.spawn (fun () -> while Atomic.get lock do Atomic.incr result done) ;
7+
Atomic.spawn (fun () -> Atomic.set lock false) ;
8+
Atomic.final (fun () -> Atomic.check (fun () -> Atomic.get result < 10))
9+
10+
let () = Atomic.trace test

0 commit comments

Comments
 (0)