summaryrefslogtreecommitdiff
path: root/libraries/base/tests
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-04-21 12:11:28 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-21 12:11:36 -0400
commite5732d2a28dfb8a754ee73e124e3558222a543bb (patch)
treed2481cc029034b90de02db594aeacc2170c84d51 /libraries/base/tests
parent3672cf6d0962dd6bf0a05e6e3433c81bbdf04a11 (diff)
downloadhaskell-e5732d2a28dfb8a754ee73e124e3558222a543bb.tar.gz
base: Fix hWaitForInput with timeout on POSIX
This was previously broken (#13252) by f46369b8a1bf90a3bdc30f2b566c3a7e03672518, which ported the fdReady function from `select` to `poll` and in so doing dropping support for timeouts. Unfortunately, while `select` tells us the amount of time not slept (on Linux anyways; it turns out this is implementation dependent), `poll` does not give us this luxury. Consequently, we manually need to track time slept in this case. Unfortunately, portably measuring time is hard. Ideally we would use `clock_gettime` with the monotonic clock here, but sadly this isn't supported on most versions of Darwin. Consequently, we instead use `gettimeofday`, running the risk of system time changes messing us up. Test Plan: Validate Reviewers: simonmar, austin, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13252 Differential Revision: https://phabricator.haskell.org/D3473
Diffstat (limited to 'libraries/base/tests')
-rw-r--r--libraries/base/tests/T13525.hs5
-rw-r--r--libraries/base/tests/all.T2
2 files changed, 5 insertions, 2 deletions
diff --git a/libraries/base/tests/T13525.hs b/libraries/base/tests/T13525.hs
index 1bb01b6a18..b4b589e0b4 100644
--- a/libraries/base/tests/T13525.hs
+++ b/libraries/base/tests/T13525.hs
@@ -1,7 +1,10 @@
+import System.Posix.Files
import System.IO
import System.Timeout
main :: IO ()
main = do
- hWaitForInput stdin (5 * 1000)
+ createNamedPipe "test" accessModes
+ h <- openFile "test" ReadMode
+ hWaitForInput h (5 * 1000)
return ()
diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index 69705bc91e..f3cdeaa512 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -212,4 +212,4 @@ test('T13191',
, only_ways(['normal'])],
compile_and_run,
['-O'])
-test('T13525', expect_broken(13525), compile_and_run, [''])
+test('T13525', normal, compile_and_run, [''])