diff options
author | Kamil Dworakowski <kamil@dworakowski.name> | 2021-09-20 16:51:46 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-09-29 09:42:04 -0400 |
commit | 361da88a29af9005135d33e00fc61ba92c592970 (patch) | |
tree | 313a397634c2555c4984d7cbaafd47c90491ebc5 | |
parent | 162492ea0903e5b7c96f1f3934a70571f5daad23 (diff) | |
download | haskell-361da88a29af9005135d33e00fc61ba92c592970.tar.gz |
Add a regression test for #17912
-rw-r--r-- | libraries/base/tests/IO/T17912.hs | 34 | ||||
-rw-r--r-- | libraries/base/tests/IO/T17912.stdout | 1 | ||||
-rw-r--r-- | libraries/base/tests/IO/all.T | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/libraries/base/tests/IO/T17912.hs b/libraries/base/tests/IO/T17912.hs new file mode 100644 index 0000000000..102e891968 --- /dev/null +++ b/libraries/base/tests/IO/T17912.hs @@ -0,0 +1,34 @@ +{-# Language ScopedTypeVariables #-} +module Main where + +import Control.Concurrent +import Control.Exception +import System.IO +import System.Exit +import System.Process +import GHC.IO.Handle.FD + +main = do + ecode <- waitForProcess =<< spawnProcess "mkfifo" ["fifo"] + case ecode of + ExitFailure code -> putStrLn "mkfifo failed" + ExitSuccess -> do + passed <- newEmptyMVar + opener <- forkIO $ + (openFileBlocking "fifo" WriteMode >> return ()) + `catch` \(e:: AsyncException) -> do + if e == ThreadKilled then do + putStrLn "openFileBlocking successfully interrupted" + putMVar passed True + else print e + throwIO e + threadDelay 1000 + forkIO $ killThread opener + forkIO $ do + threadDelay (10^6) + putStrLn "timeout!" + putMVar passed False + res <- readMVar passed + case res of + True -> exitSuccess + False -> exitFailure diff --git a/libraries/base/tests/IO/T17912.stdout b/libraries/base/tests/IO/T17912.stdout new file mode 100644 index 0000000000..bdfca81701 --- /dev/null +++ b/libraries/base/tests/IO/T17912.stdout @@ -0,0 +1 @@ +openFileBlocking successfully interrupted diff --git a/libraries/base/tests/IO/all.T b/libraries/base/tests/IO/all.T index a2aac9f37f..40e9dbf35f 100644 --- a/libraries/base/tests/IO/all.T +++ b/libraries/base/tests/IO/all.T @@ -149,3 +149,4 @@ test('T17414', compile_and_run, ['']) test('T17510', expect_broken(17510), compile_and_run, ['']) test('bytestringread001', extra_run_opts('test.data'), compile_and_run, ['']) +test('T17912', [only_ways(['threaded1']), when(opsys('mingw32'),expect_broken(1))], compile_and_run, ['']) |