[project @ 1998-08-04 15:21:15 by simonm]
authorsimonm <unknown>
Tue, 4 Aug 1998 15:21:17 +0000 (15:21 +0000)
committersimonm <unknown>
Tue, 4 Aug 1998 15:21:17 +0000 (15:21 +0000)
add a quick stable ptr stress test.

ghc/tests/lib/should_run/Makefile
ghc/tests/lib/should_run/stableptr001.hs [new file with mode: 0644]
ghc/tests/lib/should_run/stableptr001.stdout [new file with mode: 0644]

index 0f59dc7..dfd259d 100644 (file)
@@ -1,5 +1,5 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.2 1998/07/08 10:36:54 simonm Exp $
+# $Id: Makefile,v 1.3 1998/08/04 15:21:15 simonm Exp $
 
 TOP = ../..
 include $(TOP)/mk/boilerplate.mk
@@ -8,6 +8,7 @@ include $(TOP)/mk/should_run.mk
 SRC_HC_OPTS += -dcore-lint
 
 packedstring001_HC_OPTS = -syslib misc
+stableptr001_RUNTEST_OPTS = +RTS -K4m
 
 SRC_MKDEPENDHS_OPTS += -syslib misc
 
diff --git a/ghc/tests/lib/should_run/stableptr001.hs b/ghc/tests/lib/should_run/stableptr001.hs
new file mode 100644 (file)
index 0000000..42ee1fe
--- /dev/null
@@ -0,0 +1,20 @@
+{-# OPTIONS -fglasgow-exts #-}
+
+module Main where
+
+import Foreign
+
+-- simple test for building/dereferencing stable ptrs
+
+main 
+  = do l <- mapM makeStablePtr [1..100000]
+       sum <- stable_sum l
+       print sum
+
+stable_sum :: [StablePtr Integer] -> IO Integer
+stable_sum [] = return 0
+stable_sum (x:xs) 
+  = do         x'  <- deRefStablePtr x
+       freeStablePtr x
+               xs' <- stable_sum xs
+        return (x' + xs')
diff --git a/ghc/tests/lib/should_run/stableptr001.stdout b/ghc/tests/lib/should_run/stableptr001.stdout
new file mode 100644 (file)
index 0000000..90ee71a
--- /dev/null
@@ -0,0 +1 @@
+5000050000