blob: 4b4dd8bde09c8dd657653d13fbd13e7c7fdb6e8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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` (\e -> putStrLn ("ERROR: " ++ show (e::SomeException)))
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
|