diff options
author | Paolo Capriotti <p.capriotti@gmail.com> | 2012-03-09 11:44:41 +0000 |
---|---|---|
committer | Paolo Capriotti <p.capriotti@gmail.com> | 2012-03-09 11:44:41 +0000 |
commit | 891c0bf89b89e3995d2dbc1f6f72b43312b14a44 (patch) | |
tree | 2f49d3817b718b226ca37489302bae735bf9ade0 /tests/libposix/posix004.hs | |
parent | 0e8de7869a0f3b32d2ac8cbe2aad74eb7dcf054a (diff) |
Copy tests from GHC testsuite (#1161)
Diffstat (limited to 'tests/libposix/posix004.hs')
-rw-r--r-- | tests/libposix/posix004.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/libposix/posix004.hs b/tests/libposix/posix004.hs new file mode 100644 index 0000000..20e2af2 --- /dev/null +++ b/tests/libposix/posix004.hs @@ -0,0 +1,44 @@ + +import System.Exit (ExitCode(..), exitWith) +import System.Posix.Process +import System.Posix.Signals + +main = do test1 + test2 + test3 + test4 + putStrLn "I'm happy." + +test1 = do + forkProcess $ raiseSignal floatingPointException + Just (pid, tc) <- getAnyProcessStatus True False + case tc of + Terminated sig | sig == floatingPointException -> return () + _ -> error "unexpected termination cause" + +test2 = do + forkProcess $ exitImmediately (ExitFailure 42) + Just (pid, tc) <- getAnyProcessStatus True False + case tc of + Exited (ExitFailure 42) -> return () + _ -> error "unexpected termination cause (2)" + +test3 = do + forkProcess $ exitImmediately ExitSuccess + Just (pid, tc) <- getAnyProcessStatus True False + case tc of + Exited ExitSuccess -> return () + _ -> error "unexpected termination cause (3)" + +test4 = do + forkProcess $ raiseSignal softwareStop + Just (pid, tc) <- getAnyProcessStatus True True + case tc of + Stopped sig | sig == softwareStop -> do + signalProcess killProcess pid + Just (pid, tc) <- getAnyProcessStatus True True + case tc of + Terminated sig | sig == killProcess -> return () + _ -> error "unexpected termination cause (5)" + _ -> error "unexpected termination cause (4)" + |