Added tests/user001.hs which tests all the get* functions in System.Posix.User.
authorbjorn@bringert.net <unknown>
Mon, 16 Apr 2007 22:00:12 +0000 (22:00 +0000)
committerbjorn@bringert.net <unknown>
Mon, 16 Apr 2007 22:00:12 +0000 (22:00 +0000)
I added this since I noticed that getUserEntryForID, getUserEntryForName,
getGroupEntryForID and getGroupEntryForName failed on OS X 10.4.9 on i386.

tests/all.T
tests/user001.hs [new file with mode: 0644]
tests/user001.stdout [new file with mode: 0644]

index 17c7acb..096ba2e 100644 (file)
@@ -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 (file)
index 0000000..ae2e875
--- /dev/null
@@ -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 (file)
index 0000000..48c0cfd
--- /dev/null
@@ -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