-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
testsuite: Add process-fork-wait test
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- | This test verifies that the 'use_process_jobs' feature works as | ||
-- advertised. Specifically: on Windows 'waitForProcess' should not return | ||
-- until all processes created by the child (including those created with | ||
-- @fork@) have exited if 'use_process_jobs' is enabled. | ||
-- | ||
|
||
module Main where | ||
|
||
import Control.Concurrent | ||
import Control.Monad | ||
import System.Environment | ||
import System.IO | ||
import System.Process | ||
|
||
main :: IO () | ||
main = do | ||
args <- getArgs | ||
run args | ||
|
||
run :: [String] -> IO () | ||
run [] = do | ||
putStrLn "starting A" | ||
hFlush stdout | ||
(_,_,_,p) <- createProcess $ (proc "process-fork-wait" ["A"]) { use_process_jobs = True } | ||
void $ waitForProcess p | ||
contents <- readFile "test" | ||
when (contents /= "looks good to me") | ||
$ fail "invalid file contents" | ||
run ["A"] = do | ||
putStrLn "A started" | ||
hFlush stdout | ||
(_,_,_,_) <- createProcess $ (proc "process-fork-wait" ["B"]) | ||
return () | ||
run ["B"] = do | ||
putStrLn "B started" | ||
hFlush stdout | ||
threadDelay (5*1000*1000) | ||
writeFile "test" "looks good to me" | ||
putStrLn "B finished" | ||
run _ = fail "unknown mode" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
starting A | ||
A started | ||
B started | ||
B finished |