testsuite: Add test for #14257
authorBen Gamari <bgamari.foss@gmail.com>
Tue, 21 Nov 2017 23:30:17 +0000 (18:30 -0500)
committerBen Gamari <ben@smart-cactus.org>
Wed, 22 Nov 2017 02:11:17 +0000 (21:11 -0500)
Subscribers: rwbarton, thomie, duog

GHC Trac Issues: #14257

Differential Revision: https://phabricator.haskell.org/D4201

testsuite/tests/profiling/should_run/Makefile
testsuite/tests/profiling/should_run/T14257.hs [new file with mode: 0644]
testsuite/tests/profiling/should_run/T14257.stdout [new file with mode: 0644]
testsuite/tests/profiling/should_run/all.T

index 9adb0a1..33d8d9a 100644 (file)
@@ -33,3 +33,11 @@ T11489:
        # then continue to run and exit normally.
        # Caused a segmentation fault in GHC <= 7.10.3
        ./T11489 +RTS -hr{} -hc
+
+.PHONY: T14257
+T14257:
+       $(RM) T14257
+       "$(TEST_HC)" -O2 --make -prof -v0 -fprof-auto T14257.hs
+       ./T14257 +RTS -hc
+       # Make sure that samples are monotonically increasing
+       awk 'BEGIN{t=0} /BEGIN_SAMPLE/{if ($$2 < t) print "uh oh", $$t, $$0; t=$$2;}' T14257.hp
diff --git a/testsuite/tests/profiling/should_run/T14257.hs b/testsuite/tests/profiling/should_run/T14257.hs
new file mode 100644 (file)
index 0000000..af67239
--- /dev/null
@@ -0,0 +1,16 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module Main where
+
+eval :: forall a b. (a -> b -> b) -> b -> [a] -> b
+eval f b xs = load xs []
+  where
+    load :: [a] -> [a] -> b
+    load [] stk          = unload b stk
+    load (x:xs) stk      = load xs (x : stk)
+
+    unload :: b -> [a] -> b
+    unload  v []         = v
+    unload  v (x  : stk) = unload ((f $! x) $! v) stk
+
+main :: IO ()
+main = print (eval (||) False (True : replicate 10000000 False))
diff --git a/testsuite/tests/profiling/should_run/T14257.stdout b/testsuite/tests/profiling/should_run/T14257.stdout
new file mode 100644 (file)
index 0000000..0ca9514
--- /dev/null
@@ -0,0 +1 @@
+True
index 530d2fc..7d14f77 100644 (file)
@@ -132,3 +132,5 @@ test('toplevel_scc_1',
      [''])
 
 test('T12962', [], compile_and_run, [''])
+
+test('T14257', [], run_command, ['$MAKE -s --no-print-directory T14257'])