add tests from GHC testsuite
authorSimon Marlow <simonmar@microsoft.com>
Mon, 5 Mar 2007 14:52:58 +0000 (14:52 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 5 Mar 2007 14:52:58 +0000 (14:52 +0000)
18 files changed:
tests/Makefile [new file with mode: 0644]
tests/all.T [new file with mode: 0644]
tests/fileexist01.hs [new file with mode: 0644]
tests/fileexist01.stdout [new file with mode: 0644]
tests/forkprocess01.hs [new file with mode: 0644]
tests/forkprocess01.stdout [new file with mode: 0644]
tests/getEnvironment01.hs [new file with mode: 0644]
tests/getEnvironment01.stdout [new file with mode: 0644]
tests/queryfdoption01.hs [new file with mode: 0644]
tests/queryfdoption01.stdout [new file with mode: 0644]
tests/signals001.hs [new file with mode: 0644]
tests/signals001.stdout [new file with mode: 0644]
tests/signals001.stdout-i386-unknown-freebsd [new file with mode: 0644]
tests/signals001.stdout-i386-unknown-openbsd [new file with mode: 0644]
tests/signals001.stdout-sparc-unknown-openbsd [new file with mode: 0644]
tests/signals001.stdout-x86_64-unknown-openbsd [new file with mode: 0644]
tests/signals002.hs [new file with mode: 0644]
tests/signals002.stdout [new file with mode: 0644]

diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644 (file)
index 0000000..6a0abcf
--- /dev/null
@@ -0,0 +1,7 @@
+# This Makefile runs the tests using GHC's testsuite framework.  It
+# assumes the package is part of a GHC build tree with the testsuite
+# installed in ../../../testsuite.
+
+TOP=../../../testsuite
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/tests/all.T b/tests/all.T
new file mode 100644 (file)
index 0000000..17c7acb
--- /dev/null
@@ -0,0 +1,20 @@
+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'])
+
diff --git a/tests/fileexist01.hs b/tests/fileexist01.hs
new file mode 100644 (file)
index 0000000..7bddda9
--- /dev/null
@@ -0,0 +1,5 @@
+-- test System.Posix.fileExist
+import System.Posix
+main = do
+  fileExist "fileexist01.hs" >>= print
+  fileExist "does not exist" >>= print
diff --git a/tests/fileexist01.stdout b/tests/fileexist01.stdout
new file mode 100644 (file)
index 0000000..1cc8b5e
--- /dev/null
@@ -0,0 +1,2 @@
+True
+False
diff --git a/tests/forkprocess01.hs b/tests/forkprocess01.hs
new file mode 100644 (file)
index 0000000..b4bc78b
--- /dev/null
@@ -0,0 +1,9 @@
+-- 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
+
diff --git a/tests/forkprocess01.stdout b/tests/forkprocess01.stdout
new file mode 100644 (file)
index 0000000..423e57d
--- /dev/null
@@ -0,0 +1 @@
+Just (Exited (ExitFailure 1))
diff --git a/tests/getEnvironment01.hs b/tests/getEnvironment01.hs
new file mode 100644 (file)
index 0000000..fb50fab
--- /dev/null
@@ -0,0 +1,8 @@
+
+-- 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)
+
diff --git a/tests/getEnvironment01.stdout b/tests/getEnvironment01.stdout
new file mode 100644 (file)
index 0000000..0ca9514
--- /dev/null
@@ -0,0 +1 @@
+True
diff --git a/tests/queryfdoption01.hs b/tests/queryfdoption01.hs
new file mode 100644 (file)
index 0000000..46833c1
--- /dev/null
@@ -0,0 +1,11 @@
+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
diff --git a/tests/queryfdoption01.stdout b/tests/queryfdoption01.stdout
new file mode 100644 (file)
index 0000000..1ed43b5
--- /dev/null
@@ -0,0 +1,2 @@
+NonBlockingRead = False
+NonBlockingRead = True
diff --git a/tests/signals001.hs b/tests/signals001.hs
new file mode 100644 (file)
index 0000000..e278550
--- /dev/null
@@ -0,0 +1,110 @@
+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
+    ]
diff --git a/tests/signals001.stdout b/tests/signals001.stdout
new file mode 100644 (file)
index 0000000..b90d1f3
--- /dev/null
@@ -0,0 +1,4 @@
+[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]
diff --git a/tests/signals001.stdout-i386-unknown-freebsd b/tests/signals001.stdout-i386-unknown-freebsd
new file mode 100644 (file)
index 0000000..b90d1f3
--- /dev/null
@@ -0,0 +1,4 @@
+[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]
diff --git a/tests/signals001.stdout-i386-unknown-openbsd b/tests/signals001.stdout-i386-unknown-openbsd
new file mode 100644 (file)
index 0000000..b90d1f3
--- /dev/null
@@ -0,0 +1,4 @@
+[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]
diff --git a/tests/signals001.stdout-sparc-unknown-openbsd b/tests/signals001.stdout-sparc-unknown-openbsd
new file mode 100644 (file)
index 0000000..b90d1f3
--- /dev/null
@@ -0,0 +1,4 @@
+[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]
diff --git a/tests/signals001.stdout-x86_64-unknown-openbsd b/tests/signals001.stdout-x86_64-unknown-openbsd
new file mode 100644 (file)
index 0000000..b90d1f3
--- /dev/null
@@ -0,0 +1,4 @@
+[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]
diff --git a/tests/signals002.hs b/tests/signals002.hs
new file mode 100644 (file)
index 0000000..b2e6e5e
--- /dev/null
@@ -0,0 +1,15 @@
+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
diff --git a/tests/signals002.stdout b/tests/signals002.stdout
new file mode 100644 (file)
index 0000000..8e3dc9e
--- /dev/null
@@ -0,0 +1,2 @@
+True
+hello