@@ -1,8 +1,8 @@
11{-# LANGUAGE DeriveDataTypeable #-}
2−{-# OPTIONS_GHC -fno-warn-orphans #-}
2+{-# OPTIONS_GHC -fno-warn-orphans #-}
33module Main where
44
5−import Prelude hiding (catch)
5+import Prelude hiding (catch, log)
66import Test.Framework
77 ( Test
88 , defaultMain
@@ -97,6 +97,40 @@ testLocalLiveProcessInfo result = do
9797-- infoMessageQueueLength pInfo == Just 4 &&
9898 infoRegisteredNames pInfo == ["foobar"]
9999
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
106+ self <- getSelfPid
107+ link serverPid
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")
111+ "pong" <- expect
112+ pInfo <- getProcessInfo serverPid
113+ stash result $ pInfo /= Nothing
114+ where
115+ launchRemote :: MVar ProcessId -> IO ()
116+ launchRemote locMV = do
117+ node2 <- liftIO $ mkNode "8082"
118+ _ <- liftIO $ forkProcess node2 $ do
119+ self <- getSelfPid
120+ liftIO $ putMVar locMV self
121+ _ <- receiveWait [
122+ match (\(pid, "ping") -> send pid "pong")
123+ ]
124+ "stop" <- expect
125+ return ()
126+ return ()
127+
128+ withActiveRemote :: LocalNode
129+ -> ((TestResult Bool -> Process ()) -> Assertion)
130+ withActiveRemote n = do
131+ a <- delayedAssertion "getProcessInfo remotePid failed" n True
132+ return a
133+
100134tests :: LocalNode -> IO [Test]
101135tests node1 = do
102136 return [
@@ -109,6 +143,8 @@ tests node1 = do
109143 (delayedAssertion
110144 "expected process-info to be correctly populated"
111145 node1 True testLocalLiveProcessInfo)
146+ , testCase "testRemoveLiveProcessInfo"
147+ (testRemoteLiveProcessInfo node1)
112148 ] ]
113149
114150mkNode :: String -> IO LocalNode
@@ -124,4 +160,3 @@ main = do
124160 defaultMain testData
125161 closeLocalNode node1
126162 return ()
127−