summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-09-15 14:07:59 -0700
committerEdward Z. Yang <ezyang@mit.edu>2013-09-15 23:53:59 -0700
commitc65a3cdb90bd0f213e67899fb7ae65d3af90ecf9 (patch)
treee2f75dcf21f550578d55c725513d43ae3a199fcd /testsuite/tests/rts
parent4141f8b994b095fa7fdda1d083b83d7afb6ba6ae (diff)
downloadhaskell-c65a3cdb90bd0f213e67899fb7ae65d3af90ecf9.tar.gz
T5435 test improvements, see #5435 for details.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Diffstat (limited to 'testsuite/tests/rts')
-rw-r--r--testsuite/tests/rts/Makefile19
-rw-r--r--testsuite/tests/rts/T5435.c13
-rw-r--r--testsuite/tests/rts/T5435.hs13
-rw-r--r--testsuite/tests/rts/T5435_dyn.stdout3
-rw-r--r--testsuite/tests/rts/T5435_dyn_mingw32.stdout2
-rw-r--r--testsuite/tests/rts/T5435_v.stdout3
-rw-r--r--testsuite/tests/rts/all.T7
7 files changed, 38 insertions, 22 deletions
diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile
index 0b146a1afb..ae2a418b94 100644
--- a/testsuite/tests/rts/Makefile
+++ b/testsuite/tests/rts/Makefile
@@ -50,14 +50,25 @@ T5435_v:
$(RM) T5435_c_v.o T5435_v$(exeext)
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 -c T5435.c -o T5435_c_v.o
'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf v_o -o T5435_v$(exeext)
- ./T5435_v T5435_c_v.o
+ ./T5435_v v ./T5435_c_v.o
+# This doesn't work on Windows, which expects *no* file extension
+# File extension here is not right for Mac OS X, where it should be dylib.
+# Note that this is DLL-loading from a *static* executable; we probably
+# also ought to provide the dynamic way via the usual channels.
.PHONY: T5435_dyn
T5435_dyn:
$(RM) T5435_c_dyn.o T5435_dyn$(exeext)
- '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -dynamic -fPIC -c T5435.c -o T5435_c_dyn.o
- '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -dynamic -fPIC T5435.hs -osuf dyn_o -o T5435_dyn$(exeext)
- ./T5435_dyn T5435_c_dyn.o
+ '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -v0 -fPIC -shared -c T5435.c -osuf dyn_o -o T5435_c.so
+ '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf dyn_o -o T5435_dyn$(exeext)
+ ./T5435_dyn dyn ./T5435_c.so
+
+.PHONY: T5435_dyn_mingw32
+T5435_dyn_mingw32:
+ $(RM) T5435_c_dyn.o T5435_dyn$(exeext)
+ '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -v0 -fPIC -shared -c T5435.c -osuf dyn_o -o T5435_c.dll
+ '$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf dyn_o -o T5435_dyn$(exeext)
+ ./T5435_dyn dyn ./T5435_c
T6006_setup :
'$(TEST_HC)' $(TEST_HC_OPTS) -c T6006.hs
diff --git a/testsuite/tests/rts/T5435.c b/testsuite/tests/rts/T5435.c
index 7e240fe3cd..7aabc0a975 100644
--- a/testsuite/tests/rts/T5435.c
+++ b/testsuite/tests/rts/T5435.c
@@ -1,15 +1,8 @@
#include <stdio.h>
-static void initializer1(void) __attribute__((constructor));
-static void initializer2(void) __attribute__((constructor));
+static void initializer(void) __attribute__((constructor));
-static void initializer1(void)
+static void initializer(void)
{
- printf("initializer1 run\n");
- fflush(stdout);
-}
-
-static void initializer2(void)
-{
- printf("initializer2 run\n");
+ printf("initializer run\n");
fflush(stdout);
}
diff --git a/testsuite/tests/rts/T5435.hs b/testsuite/tests/rts/T5435.hs
index fb54317319..6aaa9cf782 100644
--- a/testsuite/tests/rts/T5435.hs
+++ b/testsuite/tests/rts/T5435.hs
@@ -2,6 +2,7 @@
import Foreign.C.String
import Control.Monad
import System.Environment
+import Foreign.Ptr
#if defined(mingw32_HOST_OS)
type PathString = CWString
@@ -12,14 +13,20 @@ withPathString = withCString
#endif
main = do
- [object] <- getArgs
+ [ty, object] <- getArgs
initLinker
- r <- withPathString object $ \s -> loadObj s
- when (r /= 1) $ error "loadObj failed"
+ if ty == "dyn"
+ then do
+ r <- withPathString object $ \s -> addDLL s
+ when (r /= nullPtr) $ error =<< peekCString r
+ else do
+ r <- withPathString object $ \s -> loadObj s
+ when (r /= 1) $ error "loadObj failed"
r <- resolveObjs
when (r /= 1) $ error "resolveObj failed"
putStrLn "success"
foreign import ccall "initLinker" initLinker :: IO ()
+foreign import ccall "addDLL" addDLL :: PathString -> IO CString
foreign import ccall "loadObj" loadObj :: PathString -> IO Int
foreign import ccall "resolveObjs" resolveObjs :: IO Int
diff --git a/testsuite/tests/rts/T5435_dyn.stdout b/testsuite/tests/rts/T5435_dyn.stdout
index 4c344707ba..ef3b86d88e 100644
--- a/testsuite/tests/rts/T5435_dyn.stdout
+++ b/testsuite/tests/rts/T5435_dyn.stdout
@@ -1,3 +1,2 @@
-initializer1 run
-initializer2 run
+initializer run
success
diff --git a/testsuite/tests/rts/T5435_dyn_mingw32.stdout b/testsuite/tests/rts/T5435_dyn_mingw32.stdout
new file mode 100644
index 0000000000..ef3b86d88e
--- /dev/null
+++ b/testsuite/tests/rts/T5435_dyn_mingw32.stdout
@@ -0,0 +1,2 @@
+initializer run
+success
diff --git a/testsuite/tests/rts/T5435_v.stdout b/testsuite/tests/rts/T5435_v.stdout
index 4c344707ba..ef3b86d88e 100644
--- a/testsuite/tests/rts/T5435_v.stdout
+++ b/testsuite/tests/rts/T5435_v.stdout
@@ -1,3 +1,2 @@
-initializer1 run
-initializer2 run
+initializer run
success
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index 08d4a6b8d3..595821b68a 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -136,10 +136,15 @@ test('T5435_v',
['$MAKE -s --no-print-directory T5435_v'])
test('T5435_dyn',
- extra_clean(['T5435_c_dyn.o']),
+ [when(opsys('mingw32'), skip), extra_clean(['T5435_c.so'])],
run_command,
['$MAKE -s --no-print-directory T5435_dyn'])
+test('T5435_dyn_mingw32',
+ [when(not opsys('mingw32'), skip), extra_clean(['T5435_c.dll'])],
+ run_command,
+ ['$MAKE -s --no-print-directory T5435_dyn_mingw32'])
+
test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
test('T6006', [ omit_ways(prof_ways + ['ghci']),