[commit: testsuite] master: Test for Trac #8242 (ee2aa63)

git at git.haskell.org git at git.haskell.org
Sun Sep 8 10:57:00 CEST 2013


Repository : ssh://git@git.haskell.org/testsuite

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/ee2aa6301991f32a63d36307e9cf49ce9f03f466/testsuite

>---------------------------------------------------------------

commit ee2aa6301991f32a63d36307e9cf49ce9f03f466
Author: Takano Akio <aljee at hyper.cx>
Date:   Fri Sep 6 20:21:11 2013 +0900

    Test for Trac #8242
    
    Signed-off-by: Austin Seipp <aseipp at pobox.com>


>---------------------------------------------------------------

ee2aa6301991f32a63d36307e9cf49ce9f03f466
 tests/rts/T8242.hs |   41 +++++++++++++++++++++++++++++++++++++++++
 tests/rts/all.T    |    3 +++
 2 files changed, 44 insertions(+)

diff --git a/tests/rts/T8242.hs b/tests/rts/T8242.hs
new file mode 100644
index 0000000..a8dcef5
--- /dev/null
+++ b/tests/rts/T8242.hs
@@ -0,0 +1,41 @@
+{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE UnboxedTuples #-}
+import Control.Monad
+import GHC.Conc
+import Foreign.Marshal.Alloc
+import Foreign.Ptr
+import Foreign.Storable
+import Foreign.C.Types
+import GHC.IO
+import GHC.Exts
+
+foreign import ccall unsafe "&puts" puts :: FunPtr (Ptr CChar -> IO ())
+
+main :: IO ()
+main = alloca $ \ptr@(Ptr p) -> do
+  poke (ptr :: Ptr CChar) 0
+  setNumCapabilities 2
+  let !(FunPtr puts#) = puts
+  replicateM_ 10000 $ IO $ \s -> let
+    !(# s1, w #) = mkWeakNoFinalizer# () () s
+    !(# s2, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s1
+    !(# s3, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s2
+    !(# s4, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s3
+    !(# s5, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s4
+    !(# s6, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s5
+    !(# s7, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s6
+    !(# s8, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s7
+    !(# s9, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s8
+    !(# s10, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s9
+    !(# s11, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s10
+    !(# s12, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s11
+    !(# s13, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s12
+    !(# s14, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s13
+    !(# s15, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s14
+    !(# s16, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s15
+    !(# s17, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s16
+    !(# s18, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s17
+    !(# s19, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s18
+    !(# s20, _ #) = addCFinalizerToWeak# puts# p 0# nullAddr# w s19
+    in (# s20, () #)
diff --git a/tests/rts/all.T b/tests/rts/all.T
index 7e19349..8a09609 100644
--- a/tests/rts/all.T
+++ b/tests/rts/all.T
@@ -188,3 +188,6 @@ test('linker_unload',
 
 test('T8209', [ only_ways(threaded_ways), ignore_output ],
               compile_and_run, [''])
+
+test('T8242', [ only_ways(threaded_ways), ignore_output ],
+              compile_and_run, [''])





More information about the ghc-commits mailing list