summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2019-06-02 15:56:57 +0100
committerBen Gamari <ben@smart-cactus.org>2020-07-15 16:41:01 -0400
commit050da6dd42d0cb293c7fce4a5ccdeb5abe1aadb4 (patch)
tree3a6a154976602cfb1558282d791dfbc8b42a6f78
parentd660725edbdaeef9be5da4c032e687276dd09b13 (diff)
downloadhaskell-050da6dd42d0cb293c7fce4a5ccdeb5abe1aadb4.tar.gz
winio: Switch Testsuite to test winio by default
-rw-r--r--libraries/base/tests/IO/T4144.hs23
-rw-r--r--libraries/base/tests/IO/all.T9
-rw-r--r--libraries/base/tests/IO/hClose002.stdout-mingw324
-rw-r--r--libraries/base/tests/IO/openFile002.stderr-mingw321
-rw-r--r--libraries/base/tests/IO/openFile003.stdout-mingw328
-rw-r--r--testsuite/mk/test.mk7
6 files changed, 35 insertions, 17 deletions
diff --git a/libraries/base/tests/IO/T4144.hs b/libraries/base/tests/IO/T4144.hs
index 329601ca38..1fc16c0f07 100644
--- a/libraries/base/tests/IO/T4144.hs
+++ b/libraries/base/tests/IO/T4144.hs
@@ -46,15 +46,21 @@ remaining (BSIODevice bs mPos)
sizeBS :: BSIODevice -> Int
sizeBS (BSIODevice bs _) = B.length bs
-seekBS :: BSIODevice -> SeekMode -> Int -> IO ()
-seekBS dev AbsoluteSeek pos
+seekBS :: BSIODevice -> SeekMode -> Int -> IO Integer
+seekBS dev@(BSIODevice _ mPos) mode pos
+ = do seekBS' dev mode pos
+ maybe 0 fromIntegral <$> tryReadMVar mPos
+
+
+seekBS' :: BSIODevice -> SeekMode -> Int -> IO ()
+seekBS' dev AbsoluteSeek pos
| pos < 0 = error "Cannot seek to a negative position!"
| pos > sizeBS dev = error "Cannot seek past end of handle!"
| otherwise = case dev of
BSIODevice _ mPos
-> modifyMVar_ mPos $ \_ -> return pos
-seekBS dev SeekFromEnd pos = seekBS dev AbsoluteSeek (sizeBS dev - pos)
-seekBS dev RelativeSeek pos
+seekBS' dev SeekFromEnd pos = seekBS' dev AbsoluteSeek (sizeBS dev - pos)
+seekBS' dev RelativeSeek pos
= case dev of
BSIODevice _bs mPos
-> modifyMVar_ mPos $ \curPos ->
@@ -69,12 +75,12 @@ tellBS (BSIODevice _ mPos) = readMVar mPos
dupBS :: BSIODevice -> IO BSIODevice
dupBS (BSIODevice bs mPos) = BSIODevice bs <$> (readMVar mPos >>= newMVar)
-readBS :: BSIODevice -> Ptr Word8 -> Int -> IO Int
-readBS dev@(BSIODevice bs mPos) buff amount
+readBS :: BSIODevice -> Ptr Word8 -> Word64 -> Int -> IO Int
+readBS dev@(BSIODevice bs mPos) buff offset amount
= do
rem <- remaining dev
if amount > rem
- then readBS dev buff rem
+ then readBS dev buff offset rem
else B.unsafeUseAsCString bs $ \ptr ->
do
memcpy buff (castPtr ptr) (fromIntegral amount)
@@ -91,7 +97,7 @@ instance BufferedIO BSIODevice where
instance RawIO BSIODevice where
read = readBS
- readNonBlocking dev buff n = Just `liftM` readBS dev buff n
+ readNonBlocking dev buff offset n = Just `liftM` readBS dev buff offset n
instance IODevice BSIODevice where
ready _ True _ = return False -- read only
@@ -112,3 +118,4 @@ instance IODevice BSIODevice where
main = bsHandle "test" "<fake file>" >>= Data.ByteString.Char8.hGetContents >>= print
+
diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T
index 0ba27f1b42..39b7f17134 100644
--- a/libraries/base/tests/IO/all.T
+++ b/libraries/base/tests/IO/all.T
@@ -16,8 +16,8 @@ test('hFileSize001', normal, compile_and_run, [''])
test('hFileSize002', [omit_ways(['ghci'])], compile_and_run, [''])
test('hFlush001', [], compile_and_run, [''])
-test('hGetBuffering001',
- [omit_ways(['ghci']), set_stdin('hGetBuffering001.hs')],
+test('hGetBuffering001',
+ [omit_ways(['ghci']), set_stdin('hGetBuffering001.hs')],
compile_and_run, [''])
test('hGetContentsS001', normal, compile_and_run, [''])
@@ -47,7 +47,7 @@ test('hSeek004', [], compile_and_run, ['-cpp'])
test('hSetBuffering002', set_stdin('hSetBuffering002.hs'), compile_and_run, [''])
test('hSetBuffering003',
- [omit_ways(['ghci']), set_stdin('hSetBuffering003.hs')],
+ [omit_ways(['ghci']), set_stdin('hSetBuffering003.hs')],
compile_and_run, [''])
test('hSetBuffering004', set_stdin('hSetBuffering004.hs'), compile_and_run, [''])
@@ -86,7 +86,8 @@ test('hGetBuf001',
compile_and_run, ['-package unix'])
# As discussed in #16819, this test is racy in a threaded environment.
-test('hDuplicateTo001', [omit_ways(concurrent_ways)], compile_and_run, [''])
+test('hDuplicateTo001', [omit_ways(concurrent_ways),
+ when(opsys('mingw32'), skip)], compile_and_run, [''])
test('countReaders001', [], compile_and_run, [''])
diff --git a/libraries/base/tests/IO/hClose002.stdout-mingw32 b/libraries/base/tests/IO/hClose002.stdout-mingw32
new file mode 100644
index 0000000000..e05b87a7eb
--- /dev/null
+++ b/libraries/base/tests/IO/hClose002.stdout-mingw32
@@ -0,0 +1,4 @@
+Left hClose002.tmp: hClose: invalid argument (The handle is invalid.)
+Right ()
+Right ()
+Right ()
diff --git a/libraries/base/tests/IO/openFile002.stderr-mingw32 b/libraries/base/tests/IO/openFile002.stderr-mingw32
new file mode 100644
index 0000000000..a75cc496f4
--- /dev/null
+++ b/libraries/base/tests/IO/openFile002.stderr-mingw32
@@ -0,0 +1 @@
+openFile002.exe: nonexistent: openFile: does not exist (The system cannot find the file specified.)
diff --git a/libraries/base/tests/IO/openFile003.stdout-mingw32 b/libraries/base/tests/IO/openFile003.stdout-mingw32
index 77ad0a860a..b808fccc3f 100644
--- a/libraries/base/tests/IO/openFile003.stdout-mingw32
+++ b/libraries/base/tests/IO/openFile003.stdout-mingw32
@@ -1,4 +1,4 @@
-Left openFile003Dir: openFile: permission denied (Permission denied)
-Left openFile003Dir: openFile: permission denied (Permission denied)
-Left openFile003Dir: openFile: permission denied (Permission denied)
-Left openFile003Dir: openFile: permission denied (Permission denied)
+Left openFile003Dir: openFile: permission denied (Access is denied.)
+Left openFile003Dir: openFile: permission denied (Access is denied.)
+Left openFile003Dir: openFile: permission denied (Access is denied.)
+Left openFile003Dir: openFile: permission denied (Access is denied.)
diff --git a/testsuite/mk/test.mk b/testsuite/mk/test.mk
index cb4b3747f5..db6d6f41e3 100644
--- a/testsuite/mk/test.mk
+++ b/testsuite/mk/test.mk
@@ -34,6 +34,11 @@ ifeq "$(GhcUnregisterised)" "YES"
EXTRA_HC_OPTS += -optc-fno-builtin
endif
+# These flags are for testing the native I/O of Windows's new base. We can't
+# realistically run both as this would require two the amount of time to go
+# through the testsuite. So for now just rely on one.
+EXTRA_HC_OPTS += -with-rtsopts="--io-manager=native" # +RTS --io-manager=native -RTS
+
# TEST_HC_OPTS is passed to every invocation of TEST_HC
# in nested Makefiles
TEST_HC_OPTS = -dcore-lint -dstg-lint -dcmm-lint \
@@ -60,7 +65,7 @@ TEST_HC_OPTS += -Werror=compat
# removing this line.
TEST_HC_OPTS += -dno-debug-output
-TEST_HC_OPTS_INTERACTIVE = $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci -fno-ghci-history
+TEST_HC_OPTS_INTERACTIVE = $(TEST_HC_OPTS) --interactive -v0 -ignore-dot-ghci -fno-ghci-history +RTS --io-manager=native -RTS
RUNTEST_OPTS =