Commit bde4a841 authored by Simon Marlow's avatar Simon Marlow
Browse files

add tests for deadlocks in readChan & writeChan

parent e9f1000f
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
....................................................................................................
\ No newline at end of file
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)
........................................................................................................................................................................................................
\ No newline at end of file
......@@ -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'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment