From ae785972fef6fdbe960a2dbac46c02ff1e362e27 Mon Sep 17 00:00:00 2001 From: simonm <unknown> Date: Tue, 4 Aug 1998 15:21:17 +0000 Subject: [PATCH] [project @ 1998-08-04 15:21:15 by simonm] add a quick stable ptr stress test. --- ghc/tests/lib/should_run/Makefile | 3 ++- ghc/tests/lib/should_run/stableptr001.hs | 20 ++++++++++++++++++++ ghc/tests/lib/should_run/stableptr001.stdout | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ghc/tests/lib/should_run/stableptr001.hs create mode 100644 ghc/tests/lib/should_run/stableptr001.stdout diff --git a/ghc/tests/lib/should_run/Makefile b/ghc/tests/lib/should_run/Makefile index 0f59dc74d1fb..dfd259da63e9 100644 --- a/ghc/tests/lib/should_run/Makefile +++ b/ghc/tests/lib/should_run/Makefile @@ -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 index 000000000000..42ee1fe58cc1 --- /dev/null +++ b/ghc/tests/lib/should_run/stableptr001.hs @@ -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 index 000000000000..90ee71a08984 --- /dev/null +++ b/ghc/tests/lib/should_run/stableptr001.stdout @@ -0,0 +1 @@ +5000050000 -- GitLab