summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-29 09:49:29 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-31 19:02:32 -0400
commita9743eb7e9a7bc6b406eb5e3beb69c00f0e90b94 (patch)
tree626275d8cd13ca3e81481dfd26f4a092bcfaff33
parent97b6f7a3969ad128f94e872f7389ccc790334d9c (diff)
downloadhaskell-a9743eb7e9a7bc6b406eb5e3beb69c00f0e90b94.tar.gz
testsuite: Add test for #17414
-rw-r--r--libraries/base/tests/IO/T17414.hs18
-rw-r--r--libraries/base/tests/IO/all.T2
2 files changed, 20 insertions, 0 deletions
diff --git a/libraries/base/tests/IO/T17414.hs b/libraries/base/tests/IO/T17414.hs
new file mode 100644
index 0000000000..59d40720ec
--- /dev/null
+++ b/libraries/base/tests/IO/T17414.hs
@@ -0,0 +1,18 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+import Foreign.Ptr (Ptr)
+import Foreign.Marshal.Alloc (mallocBytes, free)
+import System.IO (hPutBuf, withBinaryFile, IOMode (WriteMode))
+
+-- more than 2GiB
+numBytes :: Int
+numBytes = 2264375889
+
+main :: IO ()
+main = do
+ (ptr :: Ptr ()) <- mallocBytes numBytes
+ -- the next line produces the exception on macOS
+ withBinaryFile "test.out" WriteMode (\h -> hPutBuf h ptr numBytes)
+ free ptr
+
+ -- Truncate file in case it doesn't get deleted
+ writeFile "test.out" ""
diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T
index cea513823b..427631c933 100644
--- a/libraries/base/tests/IO/all.T
+++ b/libraries/base/tests/IO/all.T
@@ -132,3 +132,5 @@ test('encodingerror001', normal, compile_and_run, [''])
test('T4808', [fragile_for(16909, ['threaded2']), exit_code(1)], compile_and_run, [''])
test('T4895', normal, compile_and_run, [''])
test('T7853', normal, compile_and_run, [''])
+# Tests ability to perform >32-bit IO operations
+test('T17414', [when(wordsize(32), skip), high_memory_usage], compile_and_run, [''])