summaryrefslogtreecommitdiff
path: root/libraries/base/tests/listThreads.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/tests/listThreads.hs')
-rw-r--r--libraries/base/tests/listThreads.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/libraries/base/tests/listThreads.hs b/libraries/base/tests/listThreads.hs
index 398afd0cc7..5037ea2e32 100644
--- a/libraries/base/tests/listThreads.hs
+++ b/libraries/base/tests/listThreads.hs
@@ -1,3 +1,6 @@
+import Data.Maybe
+import Control.Monad
+import qualified Data.Set as S
import Control.Concurrent
import Data.List (sort)
import GHC.Conc.Sync
@@ -13,11 +16,14 @@ main = do
mvar <- newEmptyMVar
let mkThread n = do
tid <- forkIO $ readMVar mvar
- labelThread tid ("thread-"++show n)
+ let lbl = "thread-"++show n
+ labelThread tid lbl
+ return lbl
- mapM_ mkThread [0..100]
+ expectedLabels <- S.fromList <$> mapM mkThread [0..100]
threads <- listThreads
- print $ length threads
- print . sort =<< mapM threadLabel threads
+ labels <- S.fromList . catMaybes <$> mapM threadLabel threads
+ unless (S.null $ expectedLabels `S.difference` labels) $
+ putStrLn $ unlines [ "thread labels don't match", show expectedLabels, show labels ]
putMVar mvar ()