should_run/allocLimit4: disable ghci way
[ghc.git] / testsuite / tests / concurrent / should_run / allocLimit4.hs
1 module Main (main) where
2
3 import GHC.Conc
4 import Control.Concurrent
5 import Control.Exception
6 import System.Exit
7 import Control.Monad
8
9 -- check that +RTS -xq is doing the right thing: the test requires
10 -- +RTS -xq300k
11 -- Test does not work in GHCi as it load A Lot Of Things at start
12
13 main = do
14 m <- newEmptyMVar
15 let action = do
16 e <- try $ do
17 setAllocationCounter (10*1024)
18 enableAllocationLimit
19 print (length [1..])
20 case e of
21 Left AllocationLimitExceeded{} -> do
22 c <- getAllocationCounter
23 when (c < 250*1024 || c > 350*1024) $ fail $ "wrong limit grace: " ++ show c
24 print (length [2..])
25 Right _ ->
26 fail "didn't catch AllocationLimitExceeded"
27
28 forkFinally action (putMVar m)
29 r <- takeMVar m
30 case r of
31 Left e | Just AllocationLimitExceeded <- fromException e -> return ()
32 _ -> print r >> exitFailure