@@ -838,6 +838,70 @@ testReceiveChanFeatures transport = do
838838
839839 takeMVar done
840840
841+testKillLocal :: NT.Transport -> Assertion
842+testKillLocal transport = do
843+ localNode <- newLocalNode transport initRemoteTable
844+
845+ pid <- forkProcess localNode $ do
846+ liftIO $ threadDelay 100000
847+
848+ runProcess localNode $ do
849+ ref <- monitor pid
850+ kill pid "TestKill"
851+ ProcessMonitorNotification ref' pid' (DiedException ex) <- expect
852+ True <- return $ ref == ref' && pid == pid' && ex == "TestKill"
853+ return ()
854+
855+testKillRemote :: NT.Transport -> Assertion
856+testKillRemote transport = do
857+ node1 <- newLocalNode transport initRemoteTable
858+ node2 <- newLocalNode transport initRemoteTable
859+
860+ pid <- forkProcess node1 $ do
861+ liftIO $ threadDelay 100000
862+
863+ runProcess node2 $ do
864+ ref <- monitor pid
865+ kill pid "TestKill"
866+ ProcessMonitorNotification ref' pid' (DiedException ex) <- expect
867+ True <- return $ ref == ref' && pid == pid' && ex == "TestKill"
868+ return ()
869+
870+testExitLocal :: NT.Transport -> Assertion
871+testExitLocal transport = do
872+ localNode <- newLocalNode transport initRemoteTable
873+
874+ pid <- forkProcess localNode $ do
875+ (liftIO $ threadDelay 100000)
876+ `catchExit` \from reason -> do
877+ say $ "Got " ++ reason ++ " from " ++ show from
878+ return ()
879+
880+ runProcess localNode $ do
881+ ref <- monitor pid
882+ exit pid "TestExit"
883+ ProcessMonitorNotification ref' pid' (DiedException ex) <- expect
884+ True <- return $ ref == ref' && pid == pid' && ex == "TestExit"
885+ return ()
886+
887+testExitRemote :: NT.Transport -> Assertion
888+testExitRemote transport = do
889+ node1 <- newLocalNode transport initRemoteTable
890+ node2 <- newLocalNode transport initRemoteTable
891+
892+ pid <- forkProcess node1 $ do
893+ (liftIO $ threadDelay 100000)
894+ `catchExit` \from reason -> do
895+ say $ "Got " ++ reason ++ " from " ++ show from
896+ return ()
897+
898+ runProcess node2 $ do
899+ ref <- monitor pid
900+ exit pid "TestExit"
901+ ProcessMonitorNotification ref' pid' (DiedException ex) <- expect
902+ True <- return $ ref == ref' && pid == pid' && ex == "TestExit"
903+ return ()
904+
841905tests :: (NT.Transport, TransportInternals) -> [Test]
842906tests (transport, transportInternals) = [
843907 testGroup "Basic features" [
@@ -855,6 +919,10 @@ tests (transport, transportInternals) = [
855919 , testCase "MatchAny" (testMatchAny transport)
856920 , testCase "ReceiveChanTimeout" (testReceiveChanTimeout transport)
857921 , testCase "ReceiveChanFeatures" (testReceiveChanFeatures transport)
922+ , testCase "KillLocal" (testKillLocal transport)
923+ , testCase "KillRemote" (testKillRemote transport)
924+ , testCase "ExitLocal" (testExitLocal transport)
925+ , testCase "ExitRemote" (testExitRemote transport)
858926 ]
859927 , testGroup "Monitoring and Linking" [
860928 -- Monitoring processes