summaryrefslogtreecommitdiff
path: root/testsuite/tests/rts
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@mit.edu>2013-09-13 16:43:11 -0700
committerEdward Z. Yang <ezyang@mit.edu>2013-09-13 16:49:08 -0700
commit226a18b9f1fdd4db712e4b339f92081771fbbaa0 (patch)
tree15047823f20644837f435d4433f96ba409bb4e59 /testsuite/tests/rts
parent5dd3e990b53532d9275eb4b2aa54c8b5c856de3a (diff)
downloadhaskell-226a18b9f1fdd4db712e4b339f92081771fbbaa0.tar.gz
Tests for #5435 (init/init_array/constr handling by linker)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Diffstat (limited to 'testsuite/tests/rts')
-rw-r--r--testsuite/tests/rts/Makefile14
-rw-r--r--testsuite/tests/rts/T5435.c15
-rw-r--r--testsuite/tests/rts/T5435.hs25
-rw-r--r--testsuite/tests/rts/T5435_dyn.stdout3
-rw-r--r--testsuite/tests/rts/T5435_v.stdout3
-rw-r--r--testsuite/tests/rts/all.T10
6 files changed, 70 insertions, 0 deletions
diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile
index e7895c8029..9fbf7de5fa 100644
--- a/testsuite/tests/rts/Makefile
+++ b/testsuite/tests/rts/Makefile
@@ -45,6 +45,20 @@ T5423:
"$(TEST_HC)" $(TEST_HC_OPTS) -v0 T5423.o T5423_cmm.o -o T5423$(exeext)
./T5423
+.PHONY: T5435_v
+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 -o T5435_v$(exeext)
+ ./T5435_v T5435_c_v.o
+
+.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 -o T5435_dyn$(exeext)
+ ./T5435_dyn T5435_c_dyn.o
+
T6006_setup :
'$(TEST_HC)' $(TEST_HC_OPTS) -c T6006.hs
diff --git a/testsuite/tests/rts/T5435.c b/testsuite/tests/rts/T5435.c
new file mode 100644
index 0000000000..7e240fe3cd
--- /dev/null
+++ b/testsuite/tests/rts/T5435.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+static void initializer1(void) __attribute__((constructor));
+static void initializer2(void) __attribute__((constructor));
+
+static void initializer1(void)
+{
+ printf("initializer1 run\n");
+ fflush(stdout);
+}
+
+static void initializer2(void)
+{
+ printf("initializer2 run\n");
+ fflush(stdout);
+}
diff --git a/testsuite/tests/rts/T5435.hs b/testsuite/tests/rts/T5435.hs
new file mode 100644
index 0000000000..fb54317319
--- /dev/null
+++ b/testsuite/tests/rts/T5435.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE ForeignFunctionInterface, CPP #-}
+import Foreign.C.String
+import Control.Monad
+import System.Environment
+
+#if defined(mingw32_HOST_OS)
+type PathString = CWString
+withPathString = withCWString
+#else
+type PathString = CString
+withPathString = withCString
+#endif
+
+main = do
+ [object] <- getArgs
+ initLinker
+ 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 "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
new file mode 100644
index 0000000000..4c344707ba
--- /dev/null
+++ b/testsuite/tests/rts/T5435_dyn.stdout
@@ -0,0 +1,3 @@
+initializer1 run
+initializer2 run
+success
diff --git a/testsuite/tests/rts/T5435_v.stdout b/testsuite/tests/rts/T5435_v.stdout
new file mode 100644
index 0000000000..4c344707ba
--- /dev/null
+++ b/testsuite/tests/rts/T5435_v.stdout
@@ -0,0 +1,3 @@
+initializer1 run
+initializer2 run
+success
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index 8a0960980d..227dc821d1 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -130,6 +130,16 @@ test('T5423',
run_command,
['$MAKE -s --no-print-directory T5423'])
+test('T5435_v',
+ extra_clean(['T5435_c_v.o']),
+ run_command,
+ ['$MAKE -s --no-print-directory T5435_v'])
+
+test('T5435_dyn',
+ extra_clean(['T5435_c_dyn.o']),
+ run_command,
+ ['$MAKE -s --no-print-directory T5435_dyn'])
+
test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
test('T6006', [ omit_ways(prof_ways + ['ghci']),