Commit 8f14bd6b authored by Simon Marlow's avatar Simon Marlow

Posix tests moved to the unix package

parent 12c0d7be
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
if config.platform == 'i386-unknown-mingw32':
conf = skip
else:
conf = normal
test('signals001', conf, compile_and_run, ['-package unix -cpp'])
test('signals002', compose(only_compiler_types(['ghc']), conf),
compile_and_run, ['-package unix'])
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'])
if config.platform == 'i386-unknown-freebsd':
conf = expect_fail
test('queryfdoption01', compose(omit_ways(['ghci']), compose(only_compiler_types(['ghc']), conf)),
compile_and_run, ['-package unix'])
test('getEnvironment01', conf, compile_and_run, ['-package unix'])
-- test System.Posix.fileExist
import System.Posix
main = do
fileExist "fileexist01.hs" >>= print
fileExist "does not exist" >>= print
-- Test that we can call exitFailure in a forked process, and have it
-- communicated properly to the parent.
import System.Exit
import System.Posix.Process
main = do
p <- forkProcess exitFailure
r <- getProcessStatus True False p
print r
-- test for trac #781 (GHCi on x86_64, cannot link to static data in
-- shared libs)
import System.Posix.Env
main = getEnvironment >>= (print . (0 <=) . length)
import System.Posix.IO
import System.IO
showNBR = do
v <- System.Posix.IO.queryFdOption 0 System.Posix.IO.NonBlockingRead
putStr $ "NonBlockingRead = " ++ (show v) ++ "\n"
main = do
showNBR
System.Posix.IO.setFdOption 0 System.Posix.IO.NonBlockingRead True
showNBR
import System.Posix.Signals
#if __GLASGOW_HASKELL__ >= 603
#include "ghcconfig.h"
#else
#include "config.h"
#endif
main = do
print (testMembers emptySignalSet)
print (testMembers emptyset)
print (testMembers fullSignalSet)
print (testMembers fullset)
fullset = internalAbort `addSignal`
realTimeAlarm `addSignal`
busError `addSignal`
processStatusChanged `addSignal`
continueProcess `addSignal`
floatingPointException `addSignal`
lostConnection `addSignal`
illegalInstruction `addSignal`
keyboardSignal `addSignal`
killProcess `addSignal`
openEndedPipe `addSignal`
keyboardTermination `addSignal`
segmentationViolation `addSignal`
softwareStop `addSignal`
softwareTermination `addSignal`
keyboardStop `addSignal`
backgroundRead `addSignal`
backgroundWrite `addSignal`
userDefinedSignal1 `addSignal`
userDefinedSignal2 `addSignal`
#if HAVE_SIGPOLL
pollableEvent `addSignal`
#endif
profilingTimerExpired `addSignal`
badSystemCall `addSignal`
breakpointTrap `addSignal`
urgentDataAvailable `addSignal`
virtualTimerExpired `addSignal`
cpuTimeLimitExceeded `addSignal`
fileSizeLimitExceeded `addSignal`
emptySignalSet
emptyset = internalAbort `deleteSignal`
realTimeAlarm `deleteSignal`
busError `deleteSignal`
processStatusChanged `deleteSignal`
continueProcess `deleteSignal`
floatingPointException `deleteSignal`
lostConnection `deleteSignal`
illegalInstruction `deleteSignal`
keyboardSignal `deleteSignal`
killProcess `deleteSignal`
openEndedPipe `deleteSignal`
keyboardTermination `deleteSignal`
segmentationViolation `deleteSignal`
softwareStop `deleteSignal`
softwareTermination `deleteSignal`
keyboardStop `deleteSignal`
backgroundRead `deleteSignal`
backgroundWrite `deleteSignal`
userDefinedSignal1 `deleteSignal`
userDefinedSignal2 `deleteSignal`
#if HAVE_SIGPOLL
pollableEvent `deleteSignal`
#endif
profilingTimerExpired `deleteSignal`
badSystemCall `deleteSignal`
breakpointTrap `deleteSignal`
urgentDataAvailable `deleteSignal`
virtualTimerExpired `deleteSignal`
cpuTimeLimitExceeded `deleteSignal`
fileSizeLimitExceeded `deleteSignal`
fullSignalSet
testMembers set = [
internalAbort `inSignalSet` set,
realTimeAlarm `inSignalSet` set,
busError `inSignalSet` set,
processStatusChanged `inSignalSet` set,
continueProcess `inSignalSet` set,
floatingPointException `inSignalSet` set,
lostConnection `inSignalSet` set,
illegalInstruction `inSignalSet` set,
keyboardSignal `inSignalSet` set,
killProcess `inSignalSet` set,
openEndedPipe `inSignalSet` set,
keyboardTermination `inSignalSet` set,
segmentationViolation `inSignalSet` set,
softwareStop `inSignalSet` set,
softwareTermination `inSignalSet` set,
keyboardStop `inSignalSet` set,
backgroundRead `inSignalSet` set,
backgroundWrite `inSignalSet` set,
userDefinedSignal1 `inSignalSet` set,
userDefinedSignal2 `inSignalSet` set,
#if HAVE_SIGPOLL
pollableEvent `inSignalSet` set,
#endif
profilingTimerExpired `inSignalSet` set,
badSystemCall `inSignalSet` set,
breakpointTrap `inSignalSet` set,
urgentDataAvailable `inSignalSet` set,
virtualTimerExpired `inSignalSet` set,
cpuTimeLimitExceeded `inSignalSet` set,
fileSizeLimitExceeded `inSignalSet` set
]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
[True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True,True]
import System.Posix
import Control.Concurrent
-- !!! test blockSignals, raiseSignal, unblockSignals, getPendingSignals
main = do
blockSignals ( userDefinedSignal1 `addSignal` emptySignalSet )
raiseSignal userDefinedSignal1
set <- getPendingSignals
print (userDefinedSignal1 `inSignalSet` set)
m <- newEmptyMVar
installHandler userDefinedSignal1
(Catch (putStrLn "hello" >> putMVar m ())) Nothing
awaitSignal (Just emptySignalSet)
takeMVar m
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment