Debug test case and test suite way
authorPeter Wortmann <scpmw@leeds.ac.uk>
Sun, 7 Dec 2014 00:04:05 +0000 (01:04 +0100)
committerAustin Seipp <austin@well-typed.com>
Tue, 16 Dec 2014 21:02:42 +0000 (15:02 -0600)
Adds a test way for debug (-g -dannot-lint) as well as a test covering
basic source tick functionality.

The debug way fails for a number of test cases because of annotation
linting: Tracing simplification (e.g. rule firings) will see
duplicated output, and sometimes expression matching might take so
long that the test case timeouts. We blacklist these tests.

(From Phabricator D169)

libraries/base/tests/all.T
testsuite/config/ghc
testsuite/tests/codeGen/should_compile/Makefile
testsuite/tests/codeGen/should_compile/all.T
testsuite/tests/codeGen/should_compile/debug.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_compile/debug.stdout [new file with mode: 0644]
testsuite/tests/programs/barton-mangler-bug/test.T
testsuite/tests/typecheck/should_run/all.T

index d4686e5..1154a53 100644 (file)
@@ -174,7 +174,8 @@ test('T8766',
 
 test('T9111', normal, compile, [''])
 test('T9395', normal, compile_and_run, [''])
-test('T9532', normal, compile_and_run, [''])
+# Fails for debug way due to annotation linting timeout
+test('T9532', omit_ways(['debug']), compile_and_run, [''])
 test('T9586', normal, compile, [''])
 test('T9681', normal, compile_fail, [''])
 test('T8089', normal, compile_and_run, [''])
index 84b89d4..10565dd 100644 (file)
@@ -28,7 +28,8 @@ config.other_ways         = ['prof',
                              'llvm', 'debugllvm',
                              'profllvm', 'profoptllvm', 'profthreadedllvm',
                              'threaded1llvm', 'threaded2llvm',
-                             'dynllvm']
+                             'dynllvm',
+                             'debug']
 
 if (ghc_with_native_codegen == 1):
     config.compile_ways.append('optasm')
@@ -104,6 +105,7 @@ config.way_flags = lambda name : {
     'prof_hr'      : ['-O', '-prof', '-static', '-auto-all'],
     'dyn'          : ['-O', '-dynamic'],
     'static'       : ['-O', '-static'],
+    'debug'        : ['-O', '-g', '-dannot-lint'],
     # llvm variants...
     'profllvm'         : ['-prof', '-static', '-auto-all', '-fllvm'],
     'profoptllvm'      : ['-O', '-prof', '-static', '-auto-all', '-fllvm'],
@@ -136,6 +138,7 @@ config.way_rts_flags = {
     'prof_hr'      : ['-hr'],
     'dyn'          : [],
     'static'       : [],
+    'debug'        : [],
     # llvm variants...
     'profllvm'         : ['-p'],
     'profoptllvm'      : ['-hc', '-p'],
index c804a12..b186e0d 100644 (file)
@@ -5,3 +5,28 @@ include $(TOP)/mk/test.mk
 T2578:
        '$(TEST_HC)' $(TEST_HC_OPTS) --make T2578 -fforce-recomp -v0
 
+debug:
+       # Without optimisations, we should get annotations for basically
+       # all expressions in the example program.
+       echo == Dbg ==
+       '$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -dppr-ticks -ddump-cmm \
+               | grep -o src\<debug.hs:.*\> | sort -u
+       ./debug
+
+       # With optimisations we will get fewer annotations.
+       echo == Dbg -O2 ==
+       '$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -dppr-ticks -ddump-cmm -O2 \
+               > debug.cmm
+       cat debug.cmm | grep -o src\<debug.hs:.*\> | sort -u
+
+       # Common block elimination should elimation should merge the
+       # blocks corresponding to alternatives 1 and 2, therefore there
+       # must be a block containing exactly these two annotations
+       # directly next to each other.
+       echo == CBE ==
+       cat debug.cmm | grep -A1 -B1 src\<debug.hs:3:.*\> \
+                  | grep src\<debug.hs:4:.*\> \
+                  | grep -o src\<.*\> | sort -u
+
+       ./debug
+       rm debug
index a6b6894..b571839 100644 (file)
@@ -25,3 +25,7 @@ test('T8205', normal, compile, ['-O0'])
 test('T9155', normal, compile, ['-O2'])
 test('T9303', normal, compile, ['-O2'])
 test('T9329', [cmm_src], compile, [''])
+
+test('debug', extra_clean(['debug.cmm']),
+     run_command,
+     ['$MAKE -s --no-print-directory debug'])
diff --git a/testsuite/tests/codeGen/should_compile/debug.hs b/testsuite/tests/codeGen/should_compile/debug.hs
new file mode 100644 (file)
index 0000000..dfb6d60
--- /dev/null
@@ -0,0 +1,6 @@
+module Main where
+fib :: Int -> Int
+fib 0 = 1 -- GHC should merge the blocks
+fib 1 = 1 -- of these two alternatives
+fib n = fib (n-1) + fib (n-2)
+main = print $ fib 10
diff --git a/testsuite/tests/codeGen/should_compile/debug.stdout b/testsuite/tests/codeGen/should_compile/debug.stdout
new file mode 100644 (file)
index 0000000..59332ff
--- /dev/null
@@ -0,0 +1,24 @@
+== Dbg ==
+src<debug.hs:(3,1)-(5,29)>
+src<debug.hs:3:9>
+src<debug.hs:4:9>
+src<debug.hs:5:13-17>
+src<debug.hs:5:14>
+src<debug.hs:5:21-29>
+src<debug.hs:5:25-29>
+src<debug.hs:5:26>
+src<debug.hs:5:9-17>
+src<debug.hs:5:9-29>
+src<debug.hs:6:1-21>
+89
+== Dbg -O2 ==
+src<debug.hs:(3,1)-(5,29)>
+src<debug.hs:3:9>
+src<debug.hs:4:9>
+src<debug.hs:5:25-29>
+src<debug.hs:5:9-29>
+src<debug.hs:6:1-21>
+src<debug.hs:6:16-21>
+== CBE ==
+src<debug.hs:4:9>
+89
index bb140f5..f6ad425 100644 (file)
@@ -9,6 +9,8 @@ test('barton-mangler-bug',
                    'Plot.hi',              'Plot.o',
                    'PlotExample.hi',       'PlotExample.o',
                    'TypesettingTricks.hi', 'TypesettingTricks.o']),
-      omit_compiler_types(['hugs'])],
+      omit_compiler_types(['hugs']),
+      omit_ways('debug') # Fails for debug way due to annotation linting timeout
+      ],
      multimod_compile_and_run, ['Main', ''])
 
index 53c97ea..5b20034 100755 (executable)
@@ -107,7 +107,7 @@ test('T6117', normal, compile_and_run, [''])
 test('T5751', normal, compile_and_run, [''])
 test('T5913', normal, compile_and_run, [''])
 test('T7748', normal, compile_and_run, [''])
-test('T7861', exit_code(1), compile_and_run, [''])
+test('T7861', [omit_ways('debug'), exit_code(1)], compile_and_run, [''])
 test('TcTypeNatSimpleRun', normal, compile_and_run, [''])
 test('T8119', normal, ghci_script, ['T8119.script'])
 test('T8492', normal, compile_and_run, [''])