[commit: ghc] master: Fix #5435, adding new test config check_stdout. (f8e12e2)

git at git.haskell.org git at git.haskell.org
Wed Apr 9 09:35:31 UTC 2014


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

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

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

commit f8e12e2b396e0c475e1403ab8ac3fc4d63c1681e
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Wed Apr 9 02:32:21 2014 -0700

    Fix #5435, adding new test config check_stdout.
    
    check_stdout(f) allows you to override the test framework's
    diff based output checking with another mechanism.  f is
    a function which takes two arguments: the first is the
    filename containing the observed stdout, the second is the
    normaliser that would have been applied (in case you want
    to read, normalise, and then do something.)
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>


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

f8e12e2b396e0c475e1403ab8ac3fc4d63c1681e
 testsuite/driver/testglobals.py |    5 +++++
 testsuite/driver/testlib.py     |   16 +++++++++++++++-
 testsuite/tests/rts/all.T       |   19 +++++++++++++++++--
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py
index 203d85f..7b9bd9a 100644
--- a/testsuite/driver/testglobals.py
+++ b/testsuite/driver/testglobals.py
@@ -252,6 +252,11 @@ class TestOptions:
        # Extra output normalisation
        self.extra_normaliser = lambda x: x
 
+       # Custom output checker, otherwise do a comparison with expected
+       # stdout file.  Accepts two arguments: filename of actual stdout
+       # output, and a normaliser function given other test options
+       self.check_stdout = None
+
        # Extra normalisation for compiler error messages
        self.extra_errmsg_normaliser = lambda x: x
 
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index d8fbd02..0657db8 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -468,6 +468,14 @@ def _compile_cmd_prefix( name, opts, prefix ):
 
 # ----
 
+def check_stdout( f ):
+    return lambda name, opts, f=f: _check_stdout(name, opts, f)
+
+def _check_stdout( name, opts, f ):
+    opts.check_stdout = f
+
+# ----
+
 def normalise_slashes( name, opts ):
     opts.extra_normaliser = normalise_slashes_
 
@@ -1487,8 +1495,14 @@ def check_stdout_ok( name ):
       else:
          return normalise_output(str)
 
+   two_norm = two_normalisers(norm, getTestOpts().extra_normaliser)
+
+   check_stdout = getTestOpts().check_stdout
+   if check_stdout:
+      return check_stdout(actual_stdout_file, two_norm)
+
    return compare_outputs('stdout', \
-                          two_normalisers(norm, getTestOpts().extra_normaliser), \
+                          two_norm, \
                           expected_stdout_file, actual_stdout_file)
 
 def dump_stdout( name ):
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index f7c4986..9239f44 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -130,13 +130,28 @@ test('T5423',
      run_command,
      ['$MAKE -s --no-print-directory T5423'])
 
+# Workaround bug #8458: old dlopen opens sections in the wrong order,
+# so we just accept both orders.
+def checkDynAsm(actual_file, normaliser):
+    actual_raw = read_no_crs(actual_file)
+    actual_str = normaliser(actual_raw)
+    actual = actual_str.split()
+    if actual == ['initArray1', 'initArray2', 'ctors1', 'ctors2', 'success']:
+        return 1
+    elif actual == ['ctors1', 'ctors2', 'initArray1', 'initArray2', 'success']:
+        if_verbose(1, 'T5435_dyn_asm detected old-style dlopen, see #8458')
+        return 1
+    else:
+        if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
+        return 0
+
 # These should have extra_clean() arguments, but I need
 # to somehow extract out the name of DLLs to do that
 
 test('T5435_v_asm', normal, run_command, ['$MAKE -s --no-print-directory T5435_v_asm'])
 test('T5435_v_gcc', normal, run_command, ['$MAKE -s --no-print-directory T5435_v_gcc'])
-test('T5435_dyn_asm', normal, run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
-test('T5435_dyn_gcc', normal, run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
+test('T5435_dyn_asm', check_stdout(checkDynAsm), run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
+test('T5435_dyn_gcc', normal , run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
 
 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
 



More information about the ghc-commits mailing list