Test cases for the new process group API.
authorFavonia <favonia@gmail.com>
Thu, 12 May 2011 02:35:53 +0000 (22:35 -0400)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 23 May 2011 09:36:46 +0000 (10:36 +0100)
tests/processGroup001.hs [new file with mode: 0644]
tests/processGroup001.stdout [new file with mode: 0644]
tests/processGroup002.hs [new file with mode: 0644]
tests/processGroup002.stdout [new file with mode: 0644]

diff --git a/tests/processGroup001.hs b/tests/processGroup001.hs
new file mode 100644 (file)
index 0000000..cd9f70b
--- /dev/null
@@ -0,0 +1,7 @@
+import System.Posix.Process
+
+main = do
+       pgid <- getProcessGroupID
+       pgid' <- getProcessGroupIDOf =<< getProcessID
+       putStr "Testing getProcessGroupID == getProcessGroupIDOf =<< getProcessID: "
+       print $ pgid == pgid'
diff --git a/tests/processGroup001.stdout b/tests/processGroup001.stdout
new file mode 100644 (file)
index 0000000..b9be50f
--- /dev/null
@@ -0,0 +1 @@
+Testing getProcessGroupID == getProcessGroupIDOf =<< getProcessID: True
diff --git a/tests/processGroup002.hs b/tests/processGroup002.hs
new file mode 100644 (file)
index 0000000..c93a416
--- /dev/null
@@ -0,0 +1,21 @@
+import System.Posix.Process
+
+main = do
+       pid <- getProcessID
+       ppid <- getParentProcessID
+       ppgid <- getProcessGroupIDOf ppid
+       -- join the parent process
+       putStr "Testing joinProcessGroup: "
+       joinProcessGroup ppgid
+       pgid1 <- getProcessGroupID
+       print $ ppgid == pgid1
+       -- be a leader
+       putStr "Testing createProcessGroupFor: "
+       createProcessGroupFor pid
+       pgid2 <- getProcessGroupID
+       print $ pid == fromIntegral pgid2
+       -- and join the parent again
+       putStr "Testing setProcessGroupIDOf: "
+       setProcessGroupIDOf pid ppgid
+       pgid3 <- getProcessGroupID
+       print $ ppgid == pgid3
diff --git a/tests/processGroup002.stdout b/tests/processGroup002.stdout
new file mode 100644 (file)
index 0000000..b9d2409
--- /dev/null
@@ -0,0 +1,3 @@
+Testing joinProcessGroup: True
+Testing createProcessGroupFor: True
+Testing setProcessGroupIDOf: True