@@ -4,10 +4,11 @@ module Main where
4import Prelude hiding (catch)
4import Prelude hiding (catch)
7import Data.Binary (Binary(..))
8import Data.Binary (Binary(..))
8import Data.Typeable (Typeable)
9import Data.Typeable (Typeable)
9import Data.Foldable (forM_)
10import Data.Foldable (forM_)
10−import Control.Concurrent (forkIO, threadDelay)
11+import Control.Concurrent (forkIO, threadDelay, myThreadId, throwTo, ThreadId)
11import Control.Concurrent.MVar
12import Control.Concurrent.MVar
13 , newEmptyMVar
14 , newEmptyMVar
@@ -16,8 +17,9 @@ import Control.Concurrent.MVar
16 , readMVar
17 , readMVar
18import Control.Monad (replicateM_, replicateM, forever)
19import Control.Monad (replicateM_, replicateM, forever)
19−import Control.Exception (throwIO)
20+import Control.Exception (SomeException, throwIO)
21+import qualified Control.Exception as Ex (catch)
20−import Control.Applicative ((<$>), (<*>))
22+import Control.Applicative ((<$>), (<*>), pure, (<|>))
21import qualified Network.Transport as NT (Transport, closeEndPoint)
23import qualified Network.Transport as NT (Transport, closeEndPoint)
22import Network.Socket (sClose)
24import Network.Socket (sClose)
23import Network.Transport.TCP
25import Network.Transport.TCP
@@ -32,7 +34,10 @@ import Control.Distributed.Process.Internal.Types
33import Control.Distributed.Process.Node
35import Control.Distributed.Process.Node
34import Control.Distributed.Process.Serializable (Serializable)
36import Control.Distributed.Process.Serializable (Serializable)
35−import TestAuxiliary
37+
38+import Test.HUnit (Assertion)
39+import Test.Framework (Test, defaultMain, testGroup)
40+import Test.Framework.Providers.HUnit (testCase)
37newtype Ping = Ping ProcessId
42newtype Ping = Ping ProcessId
38 deriving (Typeable, Binary, Show)
43 deriving (Typeable, Binary, Show)
@@ -40,6 +45,16 @@ newtype Ping = Ping ProcessId
40newtype Pong = Pong ProcessId
45newtype Pong = Pong ProcessId
41 deriving (Typeable, Binary, Show)
46 deriving (Typeable, Binary, Show)
48+--------------------------------------------------------------------------------
49+-- Supporting definitions --
50+--------------------------------------------------------------------------------
52+-- | Like fork, but throw exceptions in the child thread to the parent
53+forkTry :: IO () -> IO ThreadId
56+ forkIO $ Ex.catch p (\e -> throwTo tid (e :: SomeException))
43-- | The ping server from the paper
58-- | The ping server from the paper
44ping :: Process ()
59ping :: Process ()
@@ -55,35 +70,32 @@ whereisRemote nid string = do
55 WhereIsReply _ mPid <- expect
70 WhereIsReply _ mPid <- expect
56 return mPid
71 return mPid
58−-- | Basic ping test
73+data Add = Add ProcessId Double Double deriving (Typeable)
59−testPing :: NT.Transport -> IO ()
74+data Divide = Divide ProcessId Double Double deriving (Typeable)
60−testPing transport = do
75+data DivByZero = DivByZero deriving (Typeable)
61− serverAddr <- newEmptyMVar
62− clientDone <- newEmptyMVar
66− localNode <- newLocalNode transport initRemoteTable
67− addr <- forkProcess localNode ping
68− putMVar serverAddr addr
72− localNode <- newLocalNode transport initRemoteTable
73− pingServer <- readMVar serverAddr
75− let numPings = 10000
77+instance Binary Add where
78+ put (Add pid x y) = put pid >> put x >> put y
79+ get = Add <$> get <*> get <*> get
77− runProcess localNode $ do
81+instance Binary Divide where
78− pid <- getSelfPid
82+ put (Divide pid x y) = put pid >> put x >> put y
79− replicateM_ numPings $ do
83+ get = Divide <$> get <*> get <*> get
80− send pingServer (Pong pid)
84− putMVar clientDone ()
85+instance Binary DivByZero where
86+ put DivByZero = return ()
87+ get = return DivByZero
86− takeMVar clientDone
89+-- The math server from the paper
93+ [ match (\(Add pid x y) -> send pid (x + y))
94+ , matchIf (\(Divide _ _ y) -> y /= 0)
95+ (\(Divide pid x y) -> send pid (x / y))
96+ , match (\(Divide pid _ _) -> send pid DivByZero)
88-- | Monitor or link to a remote node
100-- | Monitor or link to a remote node
89monitorOrLink :: Bool -- ^ 'True' for monitor, 'False' for link
101monitorOrLink :: Bool -- ^ 'True' for monitor, 'False' for link
@@ -125,9 +137,42 @@ monitorTestProcess theirAddr mOrL un reason monitorSetup done =
125 liftIO $ putMVar done ()
137 liftIO $ putMVar done ()
140+--------------------------------------------------------------------------------
141+-- The tests proper --
142+--------------------------------------------------------------------------------
145+testPing :: NT.Transport -> Assertion
146+testPing transport = do
147+ serverAddr <- newEmptyMVar
148+ clientDone <- newEmptyMVar
152+ localNode <- newLocalNode transport initRemoteTable
153+ addr <- forkProcess localNode ping
154+ putMVar serverAddr addr
158+ localNode <- newLocalNode transport initRemoteTable
159+ pingServer <- readMVar serverAddr
161+ let numPings = 10000
163+ runProcess localNode $ do
165+ replicateM_ numPings $ do
166+ send pingServer (Pong pid)
170+ putMVar clientDone ()
129-- | Monitor a process on an unreachable node
174-- | Monitor a process on an unreachable node
130−testMonitorUnreachable :: NT.Transport -> Bool -> Bool -> IO ()
175+testMonitorUnreachable :: NT.Transport -> Bool -> Bool -> Assertion
131testMonitorUnreachable transport mOrL un = do
176testMonitorUnreachable transport mOrL un = do
132 deadProcess <- newEmptyMVar
177 deadProcess <- newEmptyMVar
133 done <- newEmptyMVar
178 done <- newEmptyMVar
@@ -147,7 +192,7 @@ testMonitorUnreachable transport mOrL un = do
147 takeMVar done
192 takeMVar done
149-- | Monitor a process which terminates normally
194-- | Monitor a process which terminates normally
150−testMonitorNormalTermination :: NT.Transport -> Bool -> Bool -> IO ()
195+testMonitorNormalTermination :: NT.Transport -> Bool -> Bool -> Assertion
151testMonitorNormalTermination transport mOrL un = do
196testMonitorNormalTermination transport mOrL un = do
152 monitorSetup <- newEmptyMVar
197 monitorSetup <- newEmptyMVar
153 monitoredProcess <- newEmptyMVar
198 monitoredProcess <- newEmptyMVar
@@ -168,7 +213,7 @@ testMonitorNormalTermination transport mOrL un = do
168 takeMVar done
213 takeMVar done
170-- | Monitor a process which terminates abnormally
215-- | Monitor a process which terminates abnormally
171−testMonitorAbnormalTermination :: NT.Transport -> Bool -> Bool -> IO ()
216+testMonitorAbnormalTermination :: NT.Transport -> Bool -> Bool -> Assertion
172testMonitorAbnormalTermination transport mOrL un = do
217testMonitorAbnormalTermination transport mOrL un = do
173 monitorSetup <- newEmptyMVar
218 monitorSetup <- newEmptyMVar
174 monitoredProcess <- newEmptyMVar
219 monitoredProcess <- newEmptyMVar
@@ -192,7 +237,7 @@ testMonitorAbnormalTermination transport mOrL un = do
192 takeMVar done
237 takeMVar done
194-- | Monitor a local process that is already dead
239-- | Monitor a local process that is already dead
195−testMonitorLocalDeadProcess :: NT.Transport -> Bool -> Bool -> IO ()
240+testMonitorLocalDeadProcess :: NT.Transport -> Bool -> Bool -> Assertion
196testMonitorLocalDeadProcess transport mOrL un = do
241testMonitorLocalDeadProcess transport mOrL un = do
197 processDead <- newEmptyMVar
242 processDead <- newEmptyMVar
198 processAddr <- newEmptyMVar
243 processAddr <- newEmptyMVar
@@ -212,7 +257,7 @@ testMonitorLocalDeadProcess transport mOrL un = do
212 takeMVar done
257 takeMVar done
214-- | Monitor a remote process that is already dead
259-- | Monitor a remote process that is already dead
215−testMonitorRemoteDeadProcess :: NT.Transport -> Bool -> Bool -> IO ()
260+testMonitorRemoteDeadProcess :: NT.Transport -> Bool -> Bool -> Assertion
216testMonitorRemoteDeadProcess transport mOrL un = do
261testMonitorRemoteDeadProcess transport mOrL un = do
217 processDead <- newEmptyMVar
262 processDead <- newEmptyMVar
218 processAddr <- newEmptyMVar
263 processAddr <- newEmptyMVar
@@ -233,7 +278,7 @@ testMonitorRemoteDeadProcess transport mOrL un = do
233 takeMVar done
278 takeMVar done
235-- | Monitor a process that becomes disconnected
280-- | Monitor a process that becomes disconnected
236−testMonitorDisconnect :: NT.Transport -> Bool -> Bool -> IO ()
281+testMonitorDisconnect :: NT.Transport -> Bool -> Bool -> Assertion
237testMonitorDisconnect transport mOrL un = do
282testMonitorDisconnect transport mOrL un = do
238 processAddr <- newEmptyMVar
283 processAddr <- newEmptyMVar
239 monitorSetup <- newEmptyMVar
284 monitorSetup <- newEmptyMVar
@@ -254,34 +299,8 @@ testMonitorDisconnect transport mOrL un = do
255 takeMVar done
300 takeMVar done
257−data Add = Add ProcessId Double Double deriving (Typeable)
258−data Divide = Divide ProcessId Double Double deriving (Typeable)
259−data DivByZero = DivByZero deriving (Typeable)
261−instance Binary Add where
262− put (Add pid x y) = put pid >> put x >> put y
263− get = Add <$> get <*> get <*> get
265−instance Binary Divide where
266− put (Divide pid x y) = put pid >> put x >> put y
267− get = Divide <$> get <*> get <*> get
269−instance Binary DivByZero where
270− put DivByZero = return ()
271− get = return DivByZero
276− [ match (\(Add pid x y) -> send pid (x + y))
277− , matchIf (\(Divide _ _ y) -> y /= 0)
278− (\(Divide pid x y) -> send pid (x / y))
279− , match (\(Divide pid _ _) -> send pid DivByZero)
283-- | Test the math server (i.e., receiveWait)
302-- | Test the math server (i.e., receiveWait)
284−testMath :: NT.Transport -> IO ()
303+testMath :: NT.Transport -> Assertion
285testMath transport = do
304testMath transport = do
286 serverAddr <- newEmptyMVar
305 serverAddr <- newEmptyMVar
287 clientDone <- newEmptyMVar
306 clientDone <- newEmptyMVar
@@ -312,7 +331,7 @@ testMath transport = do
312-- | Send first message (i.e. connect) to an already terminated process
331-- | Send first message (i.e. connect) to an already terminated process
313-- (without monitoring); then send another message to a second process on
332-- (without monitoring); then send another message to a second process on
314-- the same remote node (we're checking that the remote node did not die)
333-- the same remote node (we're checking that the remote node did not die)
315−testSendToTerminated :: NT.Transport -> IO ()
334+testSendToTerminated :: NT.Transport -> Assertion
316testSendToTerminated transport = do
335testSendToTerminated transport = do
317 serverAddr1 <- newEmptyMVar
336 serverAddr1 <- newEmptyMVar
318 serverAddr2 <- newEmptyMVar
337 serverAddr2 <- newEmptyMVar
@@ -342,7 +361,7 @@ testSendToTerminated transport = do
342 takeMVar clientDone
361 takeMVar clientDone
344-- | Test (non-zero) timeout
363-- | Test (non-zero) timeout
345−testTimeout :: NT.Transport -> IO ()
364+testTimeout :: NT.Transport -> Assertion
346testTimeout transport = do
365testTimeout transport = do
347 localNode <- newLocalNode transport initRemoteTable
366 localNode <- newLocalNode transport initRemoteTable
348 runProcess localNode $ do
367 runProcess localNode $ do
@@ -350,7 +369,7 @@ testTimeout transport = do
350 return ()
369 return ()
352-- | Test zero timeout
371-- | Test zero timeout
353−testTimeout0 :: NT.Transport -> IO ()
372+testTimeout0 :: NT.Transport -> Assertion
354testTimeout0 transport = do
373testTimeout0 transport = do
355 serverAddr <- newEmptyMVar
374 serverAddr <- newEmptyMVar
356 clientDone <- newEmptyMVar
375 clientDone <- newEmptyMVar
@@ -384,7 +403,7 @@ testTimeout0 transport = do
384 takeMVar clientDone
403 takeMVar clientDone
386-- | Test typed channels
405-- | Test typed channels
387−testTypedChannels :: NT.Transport -> IO ()
406+testTypedChannels :: NT.Transport -> Assertion
388testTypedChannels transport = do
407testTypedChannels transport = do
389 serverChannel <- newEmptyMVar :: IO (MVar (SendPort (SendPort Bool, Int)))
408 serverChannel <- newEmptyMVar :: IO (MVar (SendPort (SendPort Bool, Int)))
390 clientDone <- newEmptyMVar
409 clientDone <- newEmptyMVar
@@ -410,7 +429,7 @@ testTypedChannels transport = do
410 takeMVar clientDone
429 takeMVar clientDone
412-- | Test merging receive ports
431-- | Test merging receive ports
413−testMergeChannels :: NT.Transport -> IO ()
432+testMergeChannels :: NT.Transport -> Assertion
414testMergeChannels transport = do
433testMergeChannels transport = do
415 localNode <- newLocalNode transport initRemoteTable
434 localNode <- newLocalNode transport initRemoteTable
416 testFlat localNode True "aaabbbccc"
435 testFlat localNode True "aaabbbccc"
@@ -424,29 +443,34 @@ testMergeChannels transport = do
425 -- Single layer of merging
444 -- Single layer of merging
426 testFlat :: LocalNode -> Bool -> String -> IO ()
445 testFlat :: LocalNode -> Bool -> String -> IO ()
427− testFlat localNode biased expected =
446+ testFlat localNode biased expected = do
447+ done <- newEmptyMVar
428− runProcess localNode $ do
448+ forkProcess localNode $ do
429 rs <- mapM charChannel "abc"
449 rs <- mapM charChannel "abc"
430 m <- mergePorts biased rs
450 m <- mergePorts biased rs
431 xs <- replicateM 9 $ receiveChan m
451 xs <- replicateM 9 $ receiveChan m
432 True <- return $ xs == expected
452 True <- return $ xs == expected
433− return ()
453+ liftIO $ putMVar done ()
435 -- Two layers of merging
456 -- Two layers of merging
436 testNested :: LocalNode -> Bool -> Bool -> String -> IO ()
457 testNested :: LocalNode -> Bool -> Bool -> String -> IO ()
437− testNested localNode biasedInner biasedOuter expected =
458+ testNested localNode biasedInner biasedOuter expected = do
459+ done <- newEmptyMVar
438− runProcess localNode $ do
460+ forkProcess localNode $ do
439 rss <- mapM (mapM charChannel) ["abc", "def", "ghi"]
461 rss <- mapM (mapM charChannel) ["abc", "def", "ghi"]
440 ms <- mapM (mergePorts biasedInner) rss
462 ms <- mapM (mergePorts biasedInner) rss
441 m <- mergePorts biasedOuter ms
463 m <- mergePorts biasedOuter ms
442 xs <- replicateM (9 * 3) $ receiveChan m
464 xs <- replicateM (9 * 3) $ receiveChan m
443 True <- return $ xs == expected
465 True <- return $ xs == expected
444− return ()
466+ liftIO $ putMVar done ()
446 -- Test that if no messages are (immediately) available, the scheduler makes no difference
469 -- Test that if no messages are (immediately) available, the scheduler makes no difference
447 testBlocked :: LocalNode -> Bool -> IO ()
470 testBlocked :: LocalNode -> Bool -> IO ()
448 testBlocked localNode biased = do
471 testBlocked localNode biased = do
449 vs <- replicateM 3 newEmptyMVar
472 vs <- replicateM 3 newEmptyMVar
473+ done <- newEmptyMVar
451 forkProcess localNode $ do
475 forkProcess localNode $ do
452 [sa, sb, sc] <- liftIO $ mapM readMVar vs
476 [sa, sb, sc] <- liftIO $ mapM readMVar vs
@@ -477,13 +501,15 @@ testMergeChannels transport = do
477 , (sa, 'a')
501 , (sa, 'a')
480− runProcess localNode $ do
504+ forkProcess localNode $ do
481 (ss, rs) <- unzip <$> replicateM 3 newChan
505 (ss, rs) <- unzip <$> replicateM 3 newChan
482 liftIO $ mapM_ (uncurry putMVar) $ zip vs ss
506 liftIO $ mapM_ (uncurry putMVar) $ zip vs ss
483 m <- mergePorts biased rs
507 m <- mergePorts biased rs
484 xs <- replicateM (6 * 3) $ receiveChan m
508 xs <- replicateM (6 * 3) $ receiveChan m
485 True <- return $ xs == "abcacbbacbcacabcba"
509 True <- return $ xs == "abcacbbacbcacabcba"
486− return ()
510+ liftIO $ putMVar done ()
488 mergePorts :: Serializable a => Bool -> [ReceivePort a] -> Process (ReceivePort a)
514 mergePorts :: Serializable a => Bool -> [ReceivePort a] -> Process (ReceivePort a)
489 mergePorts True = mergePortsBiased
515 mergePorts True = mergePortsBiased
@@ -496,7 +522,7 @@ testMergeChannels transport = do
496 liftIO $ threadDelay 10000 -- Make sure messages have been sent
522 liftIO $ threadDelay 10000 -- Make sure messages have been sent
497 return rport
523 return rport
499−testTerminate :: NT.Transport -> IO ()
525+testTerminate :: NT.Transport -> Assertion
500testTerminate transport = do
526testTerminate transport = do
501 localNode <- newLocalNode transport initRemoteTable
527 localNode <- newLocalNode transport initRemoteTable
@@ -510,7 +536,7 @@ testTerminate transport = do
510 True <- return $ ref == ref' && pid == pid' && ex == show ProcessTerminationException
536 True <- return $ ref == ref' && pid == pid' && ex == show ProcessTerminationException
511 return ()
537 return ()
513−testMonitorNode :: NT.Transport -> IO ()
539+testMonitorNode :: NT.Transport -> Assertion
514testMonitorNode transport = do
540testMonitorNode transport = do
515 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
541 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
@@ -522,7 +548,7 @@ testMonitorNode transport = do
522 True <- return $ ref == ref' && nid == localNodeId node1
548 True <- return $ ref == ref' && nid == localNodeId node1
523 return ()
549 return ()
525−testMonitorChannel :: NT.Transport -> IO ()
551+testMonitorChannel :: NT.Transport -> Assertion
526testMonitorChannel transport = do
552testMonitorChannel transport = do
527 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
553 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
528 gotNotification <- newEmptyMVar
554 gotNotification <- newEmptyMVar
@@ -543,7 +569,7 @@ testMonitorChannel transport = do
544 takeMVar gotNotification
570 takeMVar gotNotification
546−testRegistry :: NT.Transport -> IO ()
572+testRegistry :: NT.Transport -> Assertion
547testRegistry transport = do
573testRegistry transport = do
548 node <- newLocalNode transport initRemoteTable
574 node <- newLocalNode transport initRemoteTable
@@ -559,7 +585,7 @@ testRegistry transport = do
559 True <- return $ pingServer == pid'
585 True <- return $ pingServer == pid'
560 return ()
586 return ()
562−testRemoteRegistry :: NT.Transport -> IO ()
588+testRemoteRegistry :: NT.Transport -> Assertion
563testRemoteRegistry transport = do
589testRemoteRegistry transport = do
564 node1 <- newLocalNode transport initRemoteTable
590 node1 <- newLocalNode transport initRemoteTable
565 node2 <- newLocalNode transport initRemoteTable
591 node2 <- newLocalNode transport initRemoteTable
@@ -577,7 +603,7 @@ testRemoteRegistry transport = do
577 True <- return $ pingServer == pid'
603 True <- return $ pingServer == pid'
578 return ()
604 return ()
580−testSpawnLocal :: NT.Transport -> IO ()
606+testSpawnLocal :: NT.Transport -> Assertion
581testSpawnLocal transport = do
607testSpawnLocal transport = do
582 node <- newLocalNode transport initRemoteTable
608 node <- newLocalNode transport initRemoteTable
@@ -595,7 +621,7 @@ testSpawnLocal transport = do
595 send pid sport
621 send pid sport
598−testReconnect :: NT.Transport -> TransportInternals -> IO ()
624+testReconnect :: NT.Transport -> TransportInternals -> Assertion
599testReconnect transport transportInternals = do
625testReconnect transport transportInternals = do
600 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
626 [node1, node2] <- replicateM 2 $ newLocalNode transport initRemoteTable
601 let nid1 = localNodeId node1
627 let nid1 = localNodeId node1
@@ -664,7 +690,7 @@ testReconnect transport transportInternals = do
665-- | Test 'matchAny'. This repeats the 'testMath' but with a proxy server
691-- | Test 'matchAny'. This repeats the 'testMath' but with a proxy server
666-- in between
692-- in between
667−testMatchAny :: NT.Transport -> IO ()
693+testMatchAny :: NT.Transport -> Assertion
668testMatchAny transport = do
694testMatchAny transport = do
669 proxyAddr <- newEmptyMVar
695 proxyAddr <- newEmptyMVar
670 clientDone <- newEmptyMVar
696 clientDone <- newEmptyMVar
@@ -695,48 +721,157 @@ testMatchAny transport = do
696 takeMVar clientDone
722 takeMVar clientDone
698−main :: IO ()
724+-- Test 'receiveChanTimeout'
699−main = do
725+testReceiveChanTimeout :: NT.Transport -> Assertion
726+testReceiveChanTimeout transport = do
727+ done <- newEmptyMVar
728+ sendPort <- newEmptyMVar
731+ localNode <- newLocalNode transport initRemoteTable
732+ runProcess localNode $ do
733+ -- Create a typed channel
734+ (sp, rp) <- newChan :: Process (SendPort Bool, ReceivePort Bool)
735+ liftIO $ putMVar sendPort sp
737+ -- Wait for a message with a delay. No message arrives, we should get Nothing after 1 second
738+ Nothing <- receiveChanTimeout 1000000 rp
740+ -- Wait for a message with a delay again. Now a message arrives after 0.5 seconds
741+ Just True <- receiveChanTimeout 1000000 rp
743+ -- Wait for a message with zero timeout: non-blocking check. No message is available, we get Nothing
744+ Nothing <- receiveChanTimeout 0 rp
746+ -- Again, but now there is a message available
747+ liftIO $ threadDelay 1000000
748+ Just False <- receiveChanTimeout 0 rp
750+ liftIO $ putMVar done ()
753+ localNode <- newLocalNode transport initRemoteTable
754+ runProcess localNode $ do
755+ sp <- liftIO $ readMVar sendPort
757+ liftIO $ threadDelay 1500000
760+ liftIO $ threadDelay 500000
765+-- | Test Functor, Applicative, Alternative and Monad instances for ReceiveChan
766+testReceiveChanFeatures :: NT.Transport -> Assertion
767+testReceiveChanFeatures transport = do
768+ done <- newEmptyMVar
771+ localNode <- newLocalNode transport initRemoteTable
772+ runProcess localNode $ do
773+ (spInt, rpInt) <- newChan :: Process (SendPort Int, ReceivePort Int)
774+ (spBool, rpBool) <- newChan :: Process (SendPort Bool, ReceivePort Bool)
776+ -- Test Functor instance
779+ sendChan spBool False
781+ rp1 <- mergePortsBiased [even <$> rpInt, rpBool]
783+ True <- receiveChan rp1
784+ False <- receiveChan rp1
786+ -- Test Applicative instance
791+ let rp2 = pure (+) <*> rpInt <*> rpInt
793+ 7 <- receiveChan rp2
795+ -- Test Alternative instance
798+ sendChan spBool True
800+ let rp3 = (even <$> rpInt) <|> rpBool
802+ False <- receiveChan rp3
803+ True <- receiveChan rp3
805+ -- Test Monad instance
807+ sendChan spBool True
808+ sendChan spBool False
811+ let rp4 :: ReceivePort Int
812+ rp4 = do b <- rpBool
817+ 5 <- receiveChan rp4
818+ 7 <- receiveChan rp4
820+ liftIO $ putMVar done ()
824+tests :: (NT.Transport, TransportInternals) -> [Test]
700− Right (transport, transportInternals) <- createTransportExposeInternals "127.0.0.1" "8080" defaultTCPParameters
825+tests (transport, transportInternals) = [
701− runTests
826+ testGroup "Basic features" [
702− [ ("Ping", testPing transport)
827+ testCase "Ping" (testPing transport)
703− , ("Math", testMath transport)
828+ , testCase "Math" (testMath transport)
704− , ("Timeout", testTimeout transport)
829+ , testCase "Timeout" (testTimeout transport)
705− , ("Timeout0", testTimeout0 transport)
830+ , testCase "Timeout0" (testTimeout0 transport)
706− , ("SendToTerminated", testSendToTerminated transport)
831+ , testCase "SendToTerminated" (testSendToTerminated transport)
707− , ("TypedChannnels", testTypedChannels transport)
832+ , testCase "TypedChannnels" (testTypedChannels transport)
708− , ("MergeChannels", testMergeChannels transport)
833+ , testCase "MergeChannels" (testMergeChannels transport)
709− , ("Terminate", testTerminate transport)
834+ , testCase "Terminate" (testTerminate transport)
710− , ("Registry", testRegistry transport)
835+ , testCase "Registry" (testRegistry transport)
711− , ("RemoteRegistry", testRemoteRegistry transport)
836+ , testCase "RemoteRegistry" (testRemoteRegistry transport)
712− , ("SpawnLocal", testSpawnLocal transport)
837+ , testCase "SpawnLocal" (testSpawnLocal transport)
713− , ("MatchAny", testMatchAny transport)
838+ , testCase "MatchAny" (testMatchAny transport)
839+ , testCase "ReceiveChanTimeout" (testReceiveChanTimeout transport)
840+ , testCase "ReceiveChanFeatures" (testReceiveChanFeatures transport)
842+ , testGroup "Monitoring and Linking" [
714 -- Monitoring processes
843 -- Monitoring processes
716 -- The "missing" combinations in the list below don't make much sense, as
845 -- The "missing" combinations in the list below don't make much sense, as
717 -- we cannot guarantee that the monitor reply or link exception will not
846 -- we cannot guarantee that the monitor reply or link exception will not
718 -- happen before the unmonitor or unlink
847 -- happen before the unmonitor or unlink
719− , ("MonitorUnreachable", testMonitorUnreachable transport True False)
848+ testCase "MonitorUnreachable" (testMonitorUnreachable transport True False)
720− , ("MonitorNormalTermination", testMonitorNormalTermination transport True False)
849+ , testCase "MonitorNormalTermination" (testMonitorNormalTermination transport True False)
721− , ("MonitorAbnormalTermination", testMonitorAbnormalTermination transport True False)
850+ , testCase "MonitorAbnormalTermination" (testMonitorAbnormalTermination transport True False)
722− , ("MonitorLocalDeadProcess", testMonitorLocalDeadProcess transport True False)
851+ , testCase "MonitorLocalDeadProcess" (testMonitorLocalDeadProcess transport True False)
723− , ("MonitorRemoteDeadProcess", testMonitorRemoteDeadProcess transport True False)
852+ , testCase "MonitorRemoteDeadProcess" (testMonitorRemoteDeadProcess transport True False)
724− , ("MonitorDisconnect", testMonitorDisconnect transport True False)
853+ , testCase "MonitorDisconnect" (testMonitorDisconnect transport True False)
725− , ("LinkUnreachable", testMonitorUnreachable transport False False)
854+ , testCase "LinkUnreachable" (testMonitorUnreachable transport False False)
726− , ("LinkNormalTermination", testMonitorNormalTermination transport False False)
855+ , testCase "LinkNormalTermination" (testMonitorNormalTermination transport False False)
727− , ("LinkAbnormalTermination", testMonitorAbnormalTermination transport False False)
856+ , testCase "LinkAbnormalTermination" (testMonitorAbnormalTermination transport False False)
728− , ("LinkLocalDeadProcess", testMonitorLocalDeadProcess transport False False)
857+ , testCase "LinkLocalDeadProcess" (testMonitorLocalDeadProcess transport False False)
729− , ("LinkRemoteDeadProcess", testMonitorRemoteDeadProcess transport False False)
858+ , testCase "LinkRemoteDeadProcess" (testMonitorRemoteDeadProcess transport False False)
730− , ("LinkDisconnect", testMonitorDisconnect transport False False)
859+ , testCase "LinkDisconnect" (testMonitorDisconnect transport False False)
731− , ("UnmonitorNormalTermination", testMonitorNormalTermination transport True True)
860+ , testCase "UnmonitorNormalTermination" (testMonitorNormalTermination transport True True)
732− , ("UnmonitorAbnormalTermination", testMonitorAbnormalTermination transport True True)
861+ , testCase "UnmonitorAbnormalTermination" (testMonitorAbnormalTermination transport True True)
733− , ("UnmonitorDisconnect", testMonitorDisconnect transport True True)
862+ , testCase "UnmonitorDisconnect" (testMonitorDisconnect transport True True)
734− , ("UnlinkNormalTermination", testMonitorNormalTermination transport False True)
863+ , testCase "UnlinkNormalTermination" (testMonitorNormalTermination transport False True)
735− , ("UnlinkAbnormalTermination", testMonitorAbnormalTermination transport False True)
864+ , testCase "UnlinkAbnormalTermination" (testMonitorAbnormalTermination transport False True)
736− , ("UnlinkDisconnect", testMonitorDisconnect transport False True)
865+ , testCase "UnlinkDisconnect" (testMonitorDisconnect transport False True)
737 -- Monitoring nodes and channels
866 -- Monitoring nodes and channels
738− , ("MonitorNode", testMonitorNode transport)
867+ , testCase "MonitorNode" (testMonitorNode transport)
739− , ("MonitorChannel", testMonitorChannel transport)
868+ , testCase "MonitorChannel" (testMonitorChannel transport)
740 -- Reconnect
869 -- Reconnect
741− , ("Reconnect", testReconnect transport transportInternals)
870+ , testCase "Reconnect" (testReconnect transport transportInternals)
876+ Right transport <- createTransportExposeInternals "127.0.0.1" "8080" defaultTCPParameters
877+ defaultMain (tests transport)