about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-11-23 07:19:14 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-11-23 07:19:14 -0800
commitb437f7aee100475533add418632833e9eaebc7bc (patch)
treeaa696ac10c84f26b1f2095faf2b46c584e4c09e2 /mu.arc.t
parent88e1f0eba0be324a74f10b9632ffbfc391b4a6fa (diff)
downloadmu-b437f7aee100475533add418632833e9eaebc7bc.tar.gz
304 - a unit test for a race condition
Still failing, but worth memorializing for posterity.

Race condition tests are still experimental, even more tied to a very
specific implementation. If I make changes to 'write' the very
'wipe-read' label will go away.

But then you just delete all tests relying on stale labels and try to
think up new race conditions.
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t26
1 files changed, 26 insertions, 0 deletions
diff --git a/mu.arc.t b/mu.arc.t
index d010e415..66d2f3ee 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -2434,6 +2434,32 @@
   (prn "F - channels are meant to be shared between routines"))
 ;? (quit)
 
+(reset)
+(new-trace "channel-race")
+(add-fns
+  '((main
+      ; create a channel with capacity 1
+      ((1 channel-address) <- new-channel (1 literal))
+      ((2 integer-address) <- new (integer literal))
+      ((2 integer-address deref) <- copy (34 literal))
+      ((3 tagged-value-address) <- new-tagged-value (integer-address literal) (2 integer-address))
+      ; write a value
+      ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref))
+      ; write a second value
+      ((1 channel-address deref) <- write (1 channel-address) (3 tagged-value-address deref)))
+    (reader
+      (_ (1 channel-address deref) <- read (1 channel-address)))))
+; switch context at just the wrong time
+(= scheduler-switch-table*
+   '((wipe-read  reader)))
+;? (= dump-trace* (obj whitelist '("schedule" "run")))
+(run 'main 'reader)
+; second write should not cause deadlock
+(each routine completed-routines*
+  (when (posmatch "deadlock" rep.routine!error)
+    (prn "F - 'write' race condition 1")))
+;? (quit)
+
 ;; Separating concerns
 ;
 ; Lightweight tools can also operate on quoted lists of statements surrounded