aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar bjorn@bringert.net <unknown>2007-04-16 22:00:12 +0000
committerGravatar bjorn@bringert.net <unknown>2007-04-16 22:00:12 +0000
commit5f7a21e6d5c8a983e92a576e249db2baab3f9c5a (patch)
tree072e98ebee21695dbf4c173a4a383403b5a1af2c /tests
parent338ea062bb47c22a4f8daac71e749564a7513881 (diff)
Added tests/user001.hs which tests all the get* functions in System.Posix.User.
I added this since I noticed that getUserEntryForID, getUserEntryForName, getGroupEntryForID and getGroupEntryForName failed on OS X 10.4.9 on i386.
Diffstat (limited to 'tests')
-rw-r--r--tests/all.T1
-rw-r--r--tests/user001.hs27
-rw-r--r--tests/user001.stdout13
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/all.T b/tests/all.T
index 17c7acb..096ba2e 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -10,6 +10,7 @@ test('fileexist01', conf, compile_and_run, ['-package unix'])
test('forkprocess01', compose(only_compiler_types(['ghc']),
compose(expect_fail_for('threaded2'), conf)),
compile_and_run, ['-package unix'])
+test('user001', conf, compile_and_run, ['-package unix'])
if config.platform == 'i386-unknown-freebsd':
conf = expect_fail
diff --git a/tests/user001.hs b/tests/user001.hs
new file mode 100644
index 0000000..ae2e875
--- /dev/null
+++ b/tests/user001.hs
@@ -0,0 +1,27 @@
+-- test that none of System.Posix.User.get* fail
+import Control.Exception as Exception
+import System.Posix.User
+
+check :: Show a => a -> Bool
+check a = show a == show a
+
+p :: Show a => String -> IO a -> IO ()
+p s m = (do putStr (s ++ ": ")
+ c <- fmap check m
+ putStrLn $ if c then "OK" else "I am the pope!")
+ `Exception.catch` (putStrLn . ("ERROR: " ++) . show)
+
+main :: IO ()
+main = do p "getRealUserID" $ getRealUserID
+ p "getRealGroupID" $ getRealGroupID
+ p "getEffectiveUserID" $ getEffectiveUserID
+ p "getEffectiveGroupID" $ getEffectiveGroupID
+ p "getGroups" $ getGroups
+ p "getLoginName" $ getLoginName
+ p "getEffectiveUserName" $ getEffectiveUserName
+ p "getGroupEntryForID" $ getRealGroupID >>= getGroupEntryForID
+ p "getGroupEntryForName" $ getRealGroupID >>= getGroupEntryForID >>= getGroupEntryForName . groupName
+ p "getAllGroupEntries" $ getAllGroupEntries
+ p "getUserEntryForID" $ getRealUserID >>= getUserEntryForID
+ p "getUserEntryForName" $ getLoginName >>= getUserEntryForName
+ p "getAllUserEntries" $ getAllUserEntries
diff --git a/tests/user001.stdout b/tests/user001.stdout
new file mode 100644
index 0000000..48c0cfd
--- /dev/null
+++ b/tests/user001.stdout
@@ -0,0 +1,13 @@
+getRealUserID: OK
+getRealGroupID: OK
+getEffectiveUserID: OK
+getEffectiveGroupID: OK
+getGroups: OK
+getLoginName: OK
+getEffectiveUserName: OK
+getGroupEntryForID: OK
+getGroupEntryForName: OK
+getAllGroupEntries: OK
+getUserEntryForID: OK
+getUserEntryForName: OK
+getAllUserEntries: OK