Commit 27b7b4db authored by Tamar Christina's avatar Tamar Christina Committed by Ben Gamari

Windows: fix all failing tests.

This makes the testsuite pass clean on Windows again.
It also fixes the `libstdc++-6.dll` error harbormaster
was showing.

I'm marking some tests as isolated tests to reduce their
flakiness (mostly concurrency tests) when the test system
is under heavy load.

Updates process submodule.

Test Plan: ./validate

Reviewers: hvr, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4277
parent 4887c308
......@@ -34,7 +34,8 @@ test('hReady001', normal, compile_and_run, ['-cpp'])
# data to read. It relies on piping input from 'sleep 1', which doesn't
# work for the 'ghci' way because in that case we already pipe input from
# a script, so hence omit_ways(['ghci'])
test('hReady002', [cmd_prefix('sleep 1 |'), omit_ways(['ghci'])],
test('hReady002', [cmd_prefix('sleep 1 |'), omit_ways(['ghci']),
multi_cpu_race],
compile_and_run, [''])
test('hSeek001', normal, compile_and_run, [''])
......@@ -87,8 +88,10 @@ test('hDuplicateTo001', [], compile_and_run, [''])
test('countReaders001', [], compile_and_run, [''])
test('concio001', normal, run_command, ['$MAKE -s --no-print-directory test.concio001'])
test('concio001.thr', extra_files(['concio001.hs']), run_command, ['$MAKE -s --no-print-directory test.concio001.thr'])
test('concio001', [normal, multi_cpu_race],
run_command, ['$MAKE -s --no-print-directory test.concio001'])
test('concio001.thr', [extra_files(['concio001.hs']), multi_cpu_race],
run_command, ['$MAKE -s --no-print-directory test.concio001.thr'])
test('concio002', reqlib('process'), compile_and_run, [''])
......
Subproject commit 2fb7e739771f4a899a12b45f8b392e4874616b89
Subproject commit 2364a36549d461adc4886ef33f259638336a87d2
......@@ -21,6 +21,7 @@
#include <excpt.h>
#include <inttypes.h>
#include <dbghelp.h>
#include <signal.h>
/////////////////////////////////
// Exception / signal handlers.
......@@ -99,7 +100,8 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
if (!crash_dump && filter_called)
return EXCEPTION_CONTINUE_EXECUTION;
long action = EXCEPTION_CONTINUE_SEARCH;
long action = EXCEPTION_CONTINUE_SEARCH;
int exit_code = EXIT_FAILURE;
ULONG_PTR what;
fprintf (stderr, "\n");
......@@ -113,6 +115,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
case EXCEPTION_INT_DIVIDE_BY_ZERO:
fprintf(stderr, "divide by zero\n");
action = EXCEPTION_CONTINUE_EXECUTION;
exit_code = SIGFPE;
break;
case EXCEPTION_STACK_OVERFLOW:
fprintf(stderr, "C stack overflow in generated code\n");
......@@ -131,6 +134,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
->ExceptionInformation[1]
);
action = EXCEPTION_CONTINUE_EXECUTION;
exit_code = SIGSEGV;
break;
default:;
}
......@@ -143,7 +147,7 @@ long WINAPI __hs_exception_handler(struct _EXCEPTION_POINTERS *exception_data)
fflush(stderr);
generateStack (exception_data);
generateDump (exception_data);
stg_exit(EXIT_FAILURE);
stg_exit(exit_code);
}
}
......
......@@ -32,6 +32,7 @@ from junit import junit
# which result in test failures. Thus set TERM to a nice, simple, safe
# value.
os.environ['TERM'] = 'vt100'
ghc_env['TERM'] = 'vt100'
global config
config = getConfig() # get it from testglobals
......@@ -161,6 +162,7 @@ else:
h.close()
if v != '':
os.environ['LC_ALL'] = v
ghc_env['LC_ALL'] = v
print("setting LC_ALL to", v)
else:
print('WARNING: No UTF8 locale found.')
......@@ -173,14 +175,30 @@ get_compiler_info()
# enabled or not
from testlib import *
def format_path(path):
if windows:
if os.pathsep == ':':
# If using msys2 python instead of mingw we have to change the drive
# letter representation. Otherwise it thinks we're adding two env
# variables E and /Foo when we add E:/Foo.
path = re.sub('([a-zA-Z]):', '/\\1', path)
if config.cygwin:
# On cygwin we can't put "c:\foo" in $PATH, as : is a
# field separator. So convert to /cygdrive/c/foo instead.
# Other pythons use ; as the separator, so no problem.
path = re.sub('([a-zA-Z]):', '/cygdrive/\\1', path)
path = re.sub('\\\\', '/', path)
return path
# On Windows we need to set $PATH to include the paths to all the DLLs
# in order for the dynamic library tests to work.
if windows or darwin:
pkginfo = str(getStdout([config.ghc_pkg, 'dump']))
topdir = config.libdir
if windows:
mingw = os.path.join(topdir, '../mingw/bin')
os.environ['PATH'] = os.pathsep.join([os.environ.get("PATH", ""), mingw])
mingw = os.path.abspath(os.path.join(topdir, '../mingw/bin'))
mingw = format_path(mingw)
ghc_env['PATH'] = os.pathsep.join([ghc_env.get("PATH", ""), mingw])
for line in pkginfo.split('\n'):
if line.startswith('library-dirs:'):
path = line.rstrip()
......@@ -193,16 +211,11 @@ if windows or darwin:
path = re.sub('^"(.*)"$', '\\1', path)
path = re.sub('\\\\(.)', '\\1', path)
if windows:
if config.cygwin:
# On cygwin we can't put "c:\foo" in $PATH, as : is a
# field separator. So convert to /cygdrive/c/foo instead.
# Other pythons use ; as the separator, so no problem.
path = re.sub('([a-zA-Z]):', '/cygdrive/\\1', path)
path = re.sub('\\\\', '/', path)
os.environ['PATH'] = os.pathsep.join([path, os.environ.get("PATH", "")])
path = format_path(path)
ghc_env['PATH'] = os.pathsep.join([path, ghc_env.get("PATH", "")])
else:
# darwin
os.environ['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, os.environ.get("DYLD_LIBRARY_PATH", "")])
ghc_env['DYLD_LIBRARY_PATH'] = os.pathsep.join([path, ghc_env.get("DYLD_LIBRARY_PATH", "")])
global testopts_local
testopts_local.x = TestOptions()
......
......@@ -123,6 +123,12 @@ config = TestConfig()
def getConfig():
return config
import os
# Hold our modified GHC testrunning environment so we don't poison the current
# python's environment.
global ghc_env
ghc_env = os.environ.copy()
# -----------------------------------------------------------------------------
# Information about the current test run
......
......@@ -143,7 +143,8 @@ def _reqlib( name, opts, lib ):
cmd = strip_quotes(config.ghc_pkg)
p = subprocess.Popen([cmd, '--no-user-package-db', 'describe', lib],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
env=ghc_env)
# read from stdout and stderr to avoid blocking due to
# buffers filling
p.communicate()
......@@ -809,7 +810,7 @@ def do_test(name, way, func, args, files):
full_name = name + '(' + way + ')'
if_verbose(2, "=====> {0} {1} of {2} {3}".format(
full_name, t.total_tests, len(allTestNames),
full_name, t.total_tests, len(allTestNames),
[len(t.unexpected_passes),
len(t.unexpected_failures),
len(t.framework_failures)]))
......@@ -1744,6 +1745,7 @@ def normalise_prof (str):
def normalise_slashes_( str ):
str = re.sub('\\\\', '/', str)
str = re.sub('//', '/', str)
return str
def normalise_exe_( str ):
......@@ -1823,7 +1825,8 @@ def runCmd(cmd, stdin=None, stdout=None, stderr=None, timeout_multiplier=1.0, pr
r = subprocess.Popen([timeout_prog, timeout, cmd],
stdin=stdin_file,
stdout=subprocess.PIPE,
stderr=hStdErr)
stderr=hStdErr,
env=ghc_env)
stdout_buffer, stderr_buffer = r.communicate()
finally:
......@@ -1982,7 +1985,7 @@ def findTFiles(roots):
for root in roots:
for path, dirs, files in os.walk(root, topdown=True):
# Never pick up .T files in uncleaned .run directories.
dirs[:] = [dir for dir in sorted(dirs)
dirs[:] = [dir for dir in sorted(dirs)
if not dir.endswith(testdir_suffix)]
for filename in files:
if filename.endswith('.T'):
......
......@@ -4,6 +4,7 @@ else:
cleanup = 'CLEANUP=0'
test('T14304',
extra_files(['p', 'indef', 'th', 'Setup.hs']),
[extra_files(['p', 'indef', 'th', 'Setup.hs']),
unless(have_dynamic(), skip)],
run_command,
['$MAKE -s --no-print-directory T14304 ' + cleanup])
......@@ -158,7 +158,7 @@ else:
conc023_ways = normal
test('conc023', [when(fast(), skip),
reqlib('random'),
reqlib('random'), multi_cpu_race,
conc023_ways], compile_and_run, [''])
test('conc024', normal, compile_and_run, [''])
......
......@@ -101,7 +101,7 @@ T1407:
.PHONY: T13606
T13606:
echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -lD3DCompiler T13606.hs
echo ":q" | '$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -lgcc_s
.PHONY: big-obj
big-obj:
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
import Data.Bits (Bits(..))
import Data.Int (Int32)
import Data.Word (Word32)
import Foreign.C.String (CString, peekCString, withCString, withCStringLen)
import Foreign.Marshal.Alloc (alloca)
import Foreign.Ptr (Ptr, castPtr, nullPtr)
import Foreign.Storable (Storable(..))
import System.IO (IOMode(..), hGetContents, withFile)
#if defined(i386_HOST_ARCH)
# define WINDOWS_CCONV stdcall
#elif defined(x86_64_HOST_ARCH)
# define WINDOWS_CCONV ccall
#else
# error Unknown mingw32 arch
#endif
foreign import WINDOWS_CCONV "D3DCompile" c_d3dCompile
:: Ptr () -> Word32 -> CString ->
Ptr D3DShaderMacro -> Ptr ID3DInclude ->
CString -> CString -> D3DCompileFlag -> D3DCompileEffectFlag ->
Ptr (Ptr ID3DBlob) -> Ptr (Ptr ID3DBlob) -> IO HRESULT
maybePoke :: (Storable a) => Maybe a -> (Ptr a -> IO b) -> IO b
maybePoke Nothing proc = proc nullPtr
maybePoke (Just m) proc = alloca $ \ptr -> do
poke ptr m
proc ptr
maybeWithCString :: Maybe String -> (CString -> IO a) -> IO a
maybeWithCString Nothing proc = proc nullPtr
maybeWithCString (Just m) proc = withCString m proc
type HRESULT = LONG
data ID3DBlob = ID3DBlob
data ID3DInclude = ID3DInclue
type LONG = Int32
data D3DShaderMacro = D3DShaderMacro
{ _name :: String
, _definition :: String }
instance Storable D3DShaderMacro where
sizeOf _ = 8
alignment _ = 8
peek ptr = do
n <- peekByteOff ptr 0
d <- peekByteOff ptr 4
n' <- peekCString n
d' <- peekCString d
return $ D3DShaderMacro n' d'
poke ptr (D3DShaderMacro n d) = do
withCString n $ \n' -> withCString d $ \d' -> do
pokeByteOff ptr 0 n'
pokeByteOff ptr 4 d'
type D3DCompileFlag = Word32
type D3DCompileEffectFlag = Word32
d3dCompileEnableStrictness :: D3DCompileFlag
d3dCompileEnableStrictness = shift 1 11
d3dCompile
:: String -> Maybe String ->
Maybe D3DShaderMacro -> Ptr ID3DInclude ->
Maybe String -> String ->
[D3DCompileFlag] -> [D3DCompileEffectFlag] ->
IO (Either (HRESULT, Ptr ID3DBlob) (Ptr ID3DBlob))
d3dCompile source sourceName defines pInclude entryPoint target compileFlags effectFlags = do
withCStringLen source $ \(csource, len) -> withCString target $ \pTarget ->
maybeWithCString sourceName $ \pSourceName -> maybePoke defines $ \pDefines ->
maybeWithCString entryPoint $ \pEntryPoint -> alloca $ \ppCode -> alloca $ \ppErrorMsgs -> do
let sFlag = foldl (.|.) 0 compileFlags
let eFlag = foldl (.|.) 0 effectFlags
putStrLn "Before d3dCompile"
hr <- c_d3dCompile
(castPtr csource)
(fromIntegral len)
pSourceName
pDefines
pInclude
pEntryPoint
pTarget
sFlag
eFlag
ppCode
ppErrorMsgs
putStrLn "After d3dCompile"
if hr < 0
then do
pErrorMsgs <- peek ppErrorMsgs
return $ Left (hr, pErrorMsgs)
else do
pCode <- peek ppCode
return $ Right pCode
d3dCompileFromFile
:: String -> Maybe String ->
Maybe D3DShaderMacro -> Ptr ID3DInclude ->
Maybe String -> String ->
[D3DCompileFlag] -> [D3DCompileEffectFlag] ->
IO (Either (HRESULT, Ptr ID3DBlob) (Ptr ID3DBlob))
d3dCompileFromFile fileName sourceName defines pInclude entryPoint target compileFlags effectFlags =
withFile fileName ReadMode $ \handle -> do
contents <- hGetContents handle
d3dCompile contents sourceName defines pInclude entryPoint target compileFlags effectFlags
main :: IO ()
main = do
_vb <- compileShaderFromFile "Triangle.fx" "VS" "vs_4_0"
return ()
compileShaderFromFile :: String -> String -> String -> IO (Ptr ID3DBlob)
compileShaderFromFile fileName entryPoint shaderModel = do
Right res <- d3dCompileFromFile
fileName
Nothing
Nothing
nullPtr
(Just entryPoint)
shaderModel
[d3dCompileEnableStrictness]
[]
return res
float4 VS( float4 Pos : POSITION ) : SV_POSITION
{
return Pos;
}
float4 PS( float4 Pos : SV_POSITION ) : SV_Target
{
return float4( 1.0f, 1.0f, 0.0f, 1.0f ); // Yellow, with Alpha = 1
}
......@@ -39,8 +39,8 @@ test('T11072msvc', [extra_files(['A.c', 'T11072.hs', 'libAS.def', 'i686/', 'x86_
unless(doing_ghci, skip), unless(opsys('mingw32'), skip)],
run_command, ['$MAKE -s --no-print-directory compile_libAS_impl_msvc'])
test('T13606', [extra_files(['Triangle.fx']),
unless(doing_ghci, skip), unless(opsys('mingw32'), skip)],
test('T13606', [unless(doing_ghci, skip), unless(opsys('mingw32'), skip),
exit_code(0)],
run_command, ['$MAKE -s --no-print-directory T13606'])
test('big-obj', [extra_files(['big-obj-c.c', 'big-obj.hs']),
......
......@@ -656,9 +656,10 @@ test('T5837',
# 2016-04-06: 24199320 (x86/Linux, 64-bit machine) TypeInType
# 2017-03-24: 27028956 (x86/Linux, 64-bit machine)
(platform('x86_64-unknown-mingw32'), 59161648, 7),
(platform('x86_64-unknown-mingw32'), 54793816, 7),
# 2017-02-19 59161648 (x64/Windows) - Unknown
# 2017-04-21 54985248 (x64/Windows) - Unknown
# 2017-12-24 54793816 (x64/Windows) - Unknown
(wordsize(64), 52089424, 7)])
# sample: 3926235424 (amd64/Linux, 15/2/2012)
......@@ -1184,14 +1185,18 @@ test('Naperian',
[ reqlib('vector'),
only_ways(['optasm']),
compiler_stats_num_field('bytes allocated',
[(wordsize(64), 2381935784, 10)])
[(platform('x86_64-unknown-mingw32'), 54116696, 10),
# 2017-12-24 54116696 (x64/Windows) - Unknown
(wordsize(64), 2381935784, 10)])
],
compile,
[''])
test ('T9630',
[ compiler_stats_num_field('max_bytes_used', # Note [residency]
[(wordsize(64), 41568168, 15)
[(platform('x86_64-unknown-mingw32'), 39867088, 15),
# 2017-12-24: 34171816 (x64/Windows)
(wordsize(64), 41568168, 15)
# initial: 56955240
# 2017-06-07: 41568168 Stop the specialiser generating loopy code
]),
......
......@@ -6,8 +6,9 @@ test('haddock.base',
[extra_files(['../../../../libraries/base/dist-install/haddock.t']),
unless(in_tree_compiler(), skip), req_haddock
,stats_num_field('bytes allocated',
[(platform('x86_64-unknown-mingw32'), 24286343184, 5)
[(platform('x86_64-unknown-mingw32'), 18733710728, 5)
# 2017-02-19 24286343184 (x64/Windows) - Generalize kind of (->)
# 2017-12-24 18733710728 (x64/Windows) - Unknown
,(wordsize(64), 19694554424, 5)
# 2012-08-14: 5920822352 (amd64/Linux)
......@@ -144,7 +145,9 @@ test('haddock.compiler',
[extra_files(['../../../../compiler/stage2/haddock.t']),
unless(in_tree_compiler(), skip), req_haddock
,stats_num_field('bytes allocated',
[(wordsize(64), 51592019560, 10)
[(platform('x86_64-unknown-mingw32'), 56775301896, 10),
# 2017-12-24: 56775301896 (x64/Windows)
(wordsize(64), 51592019560, 10)
# 2012-08-14: 26070600504 (amd64/Linux)
# 2012-08-29: 26353100288 (amd64/Linux, new CG)
# 2012-09-18: 26882813032 (amd64/Linux)
......
......@@ -108,9 +108,10 @@ test('lazy-bs-alloc',
test('T876',
[stats_num_field('bytes allocated',
[(platform('x86_64-unknown-mingw32'), 66928, 5),
[(platform('x86_64-unknown-mingw32'), 53472, 5),
# 2015-04-03: 71904 (amd64/Windows, unknown cause)
# 2016-11-27: 66928 (amd64/Windows, unknown cause)
# 2017-12-24: 53472 (amd64/Windows, unknown cause)
(wordsize(64), 58128, 5),
# 2013-02-14: 1263712 (x86_64/Linux)
......@@ -542,7 +543,9 @@ test('DeriveNullTermination', normal, compile_and_run, [''])
test('T13623',
[stats_num_field('bytes allocated',
[ (wordsize(64), 50936, 5) ]),
[(platform('x86_64-unknown-mingw32'), 47232, 10),
# 2017-12-24 47232 unknown
(wordsize(64), 50936, 5)]),
# 2017-05-02 50936 initial
only_ways(['normal'])],
compile_and_run,
......
......@@ -10,6 +10,6 @@ T4150:
-'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -c T4150.hs
T14028:
'$(TEST_HC)' $(TEST_HC_OPTS) T14028Quote.hs
'$(TEST_HC)' $(TEST_HC_OPTS) -c T14028C.c
'$(TEST_HC)' $(TEST_HC_OPTS) -fexternal-interpreter T14028 T14028C.o
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T14028Quote.hs
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -c T14028C.c
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -fexternal-interpreter T14028 T14028C.o
......@@ -3,4 +3,7 @@ import Language.Haskell.TH
import Language.Haskell.TH.Quote
here :: QuasiQuoter
here = QuasiQuoter { quoteExp = litE . stringL }
here = QuasiQuoter { quoteExp = litE . stringL,
quotePat = undefined ,
quoteType = undefined,
quoteDec = undefined }
import string
import re
#--------------------------------------
# Python normalization functions
#--------------------------------------
def normalise_search_dirs (str):
str = re.sub(r"directories searched:\s+.+$",
r"directories searched: (none)", str, flags=re.MULTILINE)
str = re.sub(r"^\s+[A-Za-z]:[\\\/].+$", "", str, flags=re.MULTILINE)
return str
#--------------------------------------
# Test functions
#--------------------------------------
test('T13082_good',
[extra_files(['foo.c', 'main.hs', 'foo_dll.c']),
unless(opsys('mingw32'), skip)],
run_command, ['$MAKE -s --no-print-directory T13082_good'])
test('T13082_fail', [extra_files(['main.hs']), unless(opsys('mingw32'), skip)],
test('T13082_fail', [extra_files(['main.hs']), unless(opsys('mingw32'), skip),
normalise_errmsg_fun(normalise_search_dirs)],
run_command, ['$MAKE -s --no-print-directory T13082_fail'])
......@@ -35,7 +35,7 @@ test('derefnull',
when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(139)]),
when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(139)]),
when(platform('powerpc-apple-darwin'), [ignore_stderr, exit_code(139)]),
when(opsys('mingw32'), [ignore_stderr, exit_code(127)]),
when(opsys('mingw32'), [ignore_stderr, exit_code(11)]),
# since these test are supposed to crash the
# profile report will be empty always.
# so disable the check for profiling
......@@ -54,7 +54,7 @@ test('divbyzero',
# C programs compiled with gcc exit normally, so do we.
when(platform('powerpc64-unknown-linux'), [ignore_stdout, exit_code(0)]),
when(platform('powerpc64le-unknown-linux'), [ignore_stdout, exit_code(0)]),
when(opsys('mingw32'), [ignore_stderr, exit_code(127)]),
when(opsys('mingw32'), [ignore_stderr, exit_code(8)]),
# The output under OS X is too unstable to readily compare
when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(136)]),
when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]),
......
......@@ -285,5 +285,7 @@ test('T14140',
test('T14272', normal, compile, [''])
test('T14270a', normal, compile, [''])
test('T14152', [ only_ways(['optasm']), check_errmsg(r'dead code') ], compile, ['-ddump-simpl'])
test('T14152a', [ only_ways(['optasm']), check_errmsg(r'dead code') ], compile, ['-fno-exitification -ddump-simpl'])
test('T14152a', [extra_files(['T14152.hs']), pre_cmd('cp T14152.hs T14152a.hs'),
only_ways(['optasm']), check_errmsg(r'dead code') ],
compile, ['-fno-exitification -ddump-simpl'])
test('T13990', normal, compile, ['-dcore-lint -O'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment