[commit: base] master: add tests for deadlocks in readChan & writeChan (6b2f322)
Simon Marlow
marlowsd at gmail.com
Mon Jun 11 18:02:08 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/6b2f322485060d9e8e269363a6a67ed371e8acc1
>---------------------------------------------------------------
commit 6b2f322485060d9e8e269363a6a67ed371e8acc1
Author: Simon Marlow <marlowsd at gmail.com>
Date: Mon Jun 11 09:51:36 2012 +0100
add tests for deadlocks in readChan & writeChan
>---------------------------------------------------------------
tests/Concurrent/Chan002.hs | 19 +++++++++++++++++++
tests/Concurrent/Chan002.stdout | 1 +
tests/Concurrent/Chan003.hs | 17 +++++++++++++++++
tests/Concurrent/Chan003.stdout | 1 +
tests/Concurrent/all.T | 4 ++++
5 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/tests/Concurrent/Chan002.hs b/tests/Concurrent/Chan002.hs
new file mode 100644
index 0000000..812298e
--- /dev/null
+++ b/tests/Concurrent/Chan002.hs
@@ -0,0 +1,19 @@
+import Control.Concurrent
+import Control.Exception
+import Control.Monad
+import System.IO
+import System.Environment
+
+-- test for deadlocks
+main = do
+ hSetBuffering stdout NoBuffering
+ [n] <- getArgs
+ replicateM_ (read n) $ do
+ chan <- newChan
+ wid <- forkIO $ forever $ writeChan chan (5::Int)
+ rid <- forkIO $ forever $ void $ readChan chan
+ threadDelay 1000
+ throwTo rid ThreadKilled
+ putStr "."
+ readChan chan
+ throwTo wid ThreadKilled
diff --git a/tests/Concurrent/Chan002.stdout b/tests/Concurrent/Chan002.stdout
new file mode 100644
index 0000000..ab79b98
--- /dev/null
+++ b/tests/Concurrent/Chan002.stdout
@@ -0,0 +1 @@
+....................................................................................................
\ No newline at end of file
diff --git a/tests/Concurrent/Chan003.hs b/tests/Concurrent/Chan003.hs
new file mode 100644
index 0000000..bfadaa8
--- /dev/null
+++ b/tests/Concurrent/Chan003.hs
@@ -0,0 +1,17 @@
+import Control.Concurrent
+import Control.Exception
+import Control.Monad
+import System.IO
+import System.Environment
+
+-- test for deadlocks
+main = do
+ hSetBuffering stdout NoBuffering
+ [n] <- getArgs
+ replicateM_ (read n) $ do
+ chan <- newChan
+ wid <- forkIO $ forever $ writeChan chan (5::Int)
+ threadDelay 3000
+ throwTo wid ThreadKilled
+ putStr "."
+ writeChan chan (3::Int)
diff --git a/tests/Concurrent/Chan003.stdout b/tests/Concurrent/Chan003.stdout
new file mode 100644
index 0000000..e003cf1
--- /dev/null
+++ b/tests/Concurrent/Chan003.stdout
@@ -0,0 +1 @@
+........................................................................................................................................................................................................
\ No newline at end of file
diff --git a/tests/Concurrent/all.T b/tests/Concurrent/all.T
index 004c6a1..35a7547 100644
--- a/tests/Concurrent/all.T
+++ b/tests/Concurrent/all.T
@@ -4,6 +4,10 @@ test('SampleVar001', reqlib('QuickCheck'), compile_and_run, ['-package QuickChec
test('4876', reqlib('random'), compile_and_run, ['']) # another SampleVar test
test('Chan001', reqlib('QuickCheck'), compile_and_run, ['-package QuickCheck'])
+
+test('Chan002', extra_run_opts('100'), compile_and_run, [''])
+test('Chan003', extra_run_opts('200'), compile_and_run, [''])
+
test('MVar001', reqlib('QuickCheck'), compile_and_run, ['-package QuickCheck'])
test('QSemN001', reqlib('QuickCheck'), compile_and_run, ['-package QuickCheck'])
test('QSem001', reqlib('QuickCheck'), compile_and_run, ['-package QuickCheck'])
More information about the Cvs-libraries
mailing list