@@ -1,8 +1,8 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
3module Main where
3module Main where
5−import Prelude hiding (catch)
5+import Prelude hiding (catch, log)
6import Test.Framework
6import Test.Framework
8 , defaultMain
8 , defaultMain
@@ -97,6 +97,40 @@ testLocalLiveProcessInfo result = do
97-- infoMessageQueueLength pInfo == Just 4 &&
97-- infoMessageQueueLength pInfo == Just 4 &&
98 infoRegisteredNames pInfo == ["foobar"]
98 infoRegisteredNames pInfo == ["foobar"]
100+testRemoteLiveProcessInfo :: LocalNode -> Assertion
101+testRemoteLiveProcessInfo node1 = do
102+ serverAddr <- liftIO $ newEmptyMVar :: IO (MVar ProcessId)
103+ liftIO $ launchRemote serverAddr
104+ serverPid <- liftIO $ takeMVar serverAddr
105+ withActiveRemote node1 $ \result -> do
108+ -- our send op shouldn't overtake link or monitor requests AFAICT
109+ -- so a little table tennis should get us synchronised properly
110+ send serverPid (self, "ping")
112+ pInfo <- getProcessInfo serverPid
113+ stash result $ pInfo /= Nothing
115+ launchRemote :: MVar ProcessId -> IO ()
116+ launchRemote locMV = do
117+ node2 <- liftIO $ mkNode "8082"
118+ _ <- liftIO $ forkProcess node2 $ do
120+ liftIO $ putMVar locMV self
122+ match (\(pid, "ping") -> send pid "pong")
128+ withActiveRemote :: LocalNode
129+ -> ((TestResult Bool -> Process ()) -> Assertion)
130+ withActiveRemote n = do
131+ a <- delayedAssertion "getProcessInfo remotePid failed" n True
100tests :: LocalNode -> IO [Test]
134tests :: LocalNode -> IO [Test]
101tests node1 = do
135tests node1 = do
@@ -109,6 +143,8 @@ tests node1 = do
109 (delayedAssertion
143 (delayedAssertion
110 "expected process-info to be correctly populated"
144 "expected process-info to be correctly populated"
111 node1 True testLocalLiveProcessInfo)
145 node1 True testLocalLiveProcessInfo)
146+ , testCase "testRemoveLiveProcessInfo"
147+ (testRemoteLiveProcessInfo node1)
114mkNode :: String -> IO LocalNode
150mkNode :: String -> IO LocalNode
@@ -124,4 +160,3 @@ main = do
124 defaultMain testData
160 defaultMain testData
125 closeLocalNode node1
161 closeLocalNode node1
126 return ()
162 return ()