Skip to content

Commit 9e35c57

Browse files
hs-viktorBodigrim
authored andcommitted
Fix test bugs
* t8108 cannot run as a thread in the same process as other tests. It could perhaps run last. But I'm not convinced we should bother. * Fix deallocation/write race in FdReadBuf001
1 parent 3aaa9dc commit 9e35c57

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

tests/FdReadBuf001.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Main where
22

33
import System.Posix
44
import Control.Monad
5-
import Foreign
5+
import Foreign hiding (void)
66
import Control.Concurrent
77
import Data.Char
88
import System.Exit
@@ -13,10 +13,10 @@ main = do
1313
block = 512
1414
(rd,wr) <- createPipe
1515
let bytes = take size (map (fromIntegral.ord) (cycle ['a'..'z']))
16-
_ <- allocaBytes size $ \p -> do
17-
pokeArray p bytes
18-
forkIO $ do r <- fdWriteBuf wr p (fromIntegral size)
19-
when (fromIntegral r /= size) $ error "fdWriteBuf failed"
16+
void $ forkIO $ allocaBytes size $ \p -> do
17+
pokeArray p bytes
18+
r <- fdWriteBuf wr p (fromIntegral size)
19+
when (fromIntegral r /= size) $ error "fdWriteBuf failed"
2020
allocaBytes block $ \p -> do
2121
let loop text = do
2222
r <- fdReadBuf rd p (fromIntegral block)

tests/Test.hs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ main = defaultMain $ testGroup "All"
3838
, signals001
3939
, t1185
4040
, t3816
41-
, t8108
4241
, user001
4342
, posix002
4443
, posix005
@@ -163,12 +162,6 @@ t3816 = testCase "T3816" $ do
163162
not . null <$> getAllGroupEntries
164163
@? "should be non-empty"
165164

166-
t8108 :: TestTree
167-
t8108 = testCase "T8108" $ do
168-
void $ forkIO $ forever $ getGroupEntryForID 0
169-
void $ forkIO $ forever $ getGroupEntryForID 0
170-
threadDelay 3000000
171-
172165
user001 :: TestTree
173166
user001 = testCase "user001" $ do
174167
let force act = do

0 commit comments

Comments
 (0)