[commit: testsuite] master: Tests for #5435 (init/init_array/constr handling by linker) (1935c70)

git at git.haskell.org git at git.haskell.org
Sat Sep 14 03:11:50 CEST 2013


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1935c70f3d7ff77b4990040643d0f282e635b150/testsuite

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

commit 1935c70f3d7ff77b4990040643d0f282e635b150
Author: Edward Z. Yang <ezyang at mit.edu>
Date:   Fri Sep 13 16:43:11 2013 -0700

    Tests for #5435 (init/init_array/constr handling by linker)
    
    Signed-off-by: Edward Z. Yang <ezyang at mit.edu>


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

1935c70f3d7ff77b4990040643d0f282e635b150
 tests/rts/Makefile         |   14 ++++++++++++++
 tests/rts/T5435.c          |   15 +++++++++++++++
 tests/rts/T5435.hs         |   25 +++++++++++++++++++++++++
 tests/rts/T5435_dyn.stdout |    3 +++
 tests/rts/T5435_v.stdout   |    3 +++
 tests/rts/all.T            |   10 ++++++++++
 6 files changed, 70 insertions(+)

diff --git a/tests/rts/Makefile b/tests/rts/Makefile
index e7895c8..9fbf7de 100644
--- a/tests/rts/Makefile
+++ b/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/tests/rts/T5435.c b/tests/rts/T5435.c
new file mode 100644
index 0000000..7e240fe
--- /dev/null
+++ b/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/tests/rts/T5435.hs b/tests/rts/T5435.hs
new file mode 100644
index 0000000..fb54317
--- /dev/null
+++ b/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/tests/rts/T5435_dyn.stdout b/tests/rts/T5435_dyn.stdout
new file mode 100644
index 0000000..4c34470
--- /dev/null
+++ b/tests/rts/T5435_dyn.stdout
@@ -0,0 +1,3 @@
+initializer1 run
+initializer2 run
+success
diff --git a/tests/rts/T5435_v.stdout b/tests/rts/T5435_v.stdout
new file mode 100644
index 0000000..4c34470
--- /dev/null
+++ b/tests/rts/T5435_v.stdout
@@ -0,0 +1,3 @@
+initializer1 run
+initializer2 run
+success
diff --git a/tests/rts/all.T b/tests/rts/all.T
index 8a09609..227dc82 100644
--- a/tests/rts/all.T
+++ b/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']),




More information about the ghc-commits mailing list