testsuite: move tests related to linker under tests/rts/linker
authorArtem Pyanykh <artem.pyanykh@gmail.com>
Tue, 16 Apr 2019 16:10:31 +0000 (19:10 +0300)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Sun, 21 Apr 2019 13:19:29 +0000 (09:19 -0400)
53 files changed:
testsuite/tests/rts/Makefile
testsuite/tests/rts/all.T
testsuite/tests/rts/linker/LinkerUnload.hs [moved from testsuite/tests/rts/LinkerUnload.hs with 100% similarity]
testsuite/tests/rts/linker/Makefile
testsuite/tests/rts/linker/T11223/Makefile [moved from testsuite/tests/rts/T11223/Makefile with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_a_b_2_fail.stderr [moved from testsuite/tests/rts/T11223/T11223_link_order_a_b_2_fail.stderr with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_a_b_2_fail.stderr-ws-32-mingw32 [moved from testsuite/tests/rts/T11223/T11223_link_order_a_b_2_fail.stderr-ws-32-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_a_b_2_fail.stderr-ws-64-mingw32 [moved from testsuite/tests/rts/T11223/T11223_link_order_a_b_2_fail.stderr-ws-64-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_a_b_succeed.stdout [moved from testsuite/tests/rts/T11223/T11223_link_order_a_b_succeed.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_b_a_2_succeed.stdout [moved from testsuite/tests/rts/T11223/T11223_link_order_b_a_2_succeed.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_link_order_b_a_succeed.stdout [moved from testsuite/tests/rts/T11223/T11223_link_order_b_a_succeed.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_duplicate_lib.stderr [moved from testsuite/tests/rts/T11223/T11223_simple_duplicate_lib.stderr with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_duplicate_lib.stderr-ws-32-mingw32 [moved from testsuite/tests/rts/T11223/T11223_simple_duplicate_lib.stderr-ws-32-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_duplicate_lib.stderr-ws-64-mingw32 [moved from testsuite/tests/rts/T11223/T11223_simple_duplicate_lib.stderr-ws-64-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_link.stdout [moved from testsuite/tests/rts/T11223/T11223_simple_link.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_link_lib.stdout [moved from testsuite/tests/rts/T11223/T11223_simple_link_lib.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/T11223_simple_unused_duplicate_lib.stdout [moved from testsuite/tests/rts/T11223/T11223_simple_unused_duplicate_lib.stdout with 100% similarity]
testsuite/tests/rts/linker/T11223/all.T [moved from testsuite/tests/rts/T11223/all.T with 100% similarity]
testsuite/tests/rts/linker/T11223/bar.c [moved from testsuite/tests/rts/T11223/bar.c with 100% similarity]
testsuite/tests/rts/linker/T11223/foo.c [moved from testsuite/tests/rts/T11223/foo.c with 100% similarity]
testsuite/tests/rts/linker/T11223/foo.hs [moved from testsuite/tests/rts/T11223/foo.hs with 100% similarity]
testsuite/tests/rts/linker/T11223/foo2.hs [moved from testsuite/tests/rts/T11223/foo2.hs with 100% similarity]
testsuite/tests/rts/linker/T11223/foo3.hs [moved from testsuite/tests/rts/T11223/foo3.hs with 100% similarity]
testsuite/tests/rts/linker/T11223/power.c [moved from testsuite/tests/rts/T11223/power.c with 100% similarity]
testsuite/tests/rts/linker/T11223/power.hs [moved from testsuite/tests/rts/T11223/power.hs with 100% similarity]
testsuite/tests/rts/linker/T11223/power3.hs [moved from testsuite/tests/rts/T11223/power3.hs with 100% similarity]
testsuite/tests/rts/linker/T11223/power_slow.c [moved from testsuite/tests/rts/T11223/power_slow.c with 100% similarity]
testsuite/tests/rts/linker/T2615.hs [moved from testsuite/tests/rts/T2615.hs with 100% similarity]
testsuite/tests/rts/linker/T2615.stdout [moved from testsuite/tests/rts/T2615.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435.hs [moved from testsuite/tests/rts/T5435.hs with 100% similarity]
testsuite/tests/rts/linker/T5435_asm.c [moved from testsuite/tests/rts/T5435_asm.c with 100% similarity]
testsuite/tests/rts/linker/T5435_dyn_asm.stdout [moved from testsuite/tests/rts/T5435_dyn_asm.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435_dyn_asm.stdout-darwin [moved from testsuite/tests/rts/T5435_dyn_asm.stdout-darwin with 100% similarity]
testsuite/tests/rts/linker/T5435_dyn_asm.stdout-mingw32 [moved from testsuite/tests/rts/T5435_dyn_asm.stdout-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T5435_dyn_gcc.stdout [moved from testsuite/tests/rts/T5435_dyn_gcc.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435_gcc.c [moved from testsuite/tests/rts/T5435_gcc.c with 100% similarity]
testsuite/tests/rts/linker/T5435_v_asm.stdout [moved from testsuite/tests/rts/T5435_v_asm.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435_v_asm_a.stdout [moved from testsuite/tests/rts/T5435_v_asm_a.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435_v_asm_a.stdout-darwin [moved from testsuite/tests/rts/T5435_v_asm_a.stdout-darwin with 100% similarity]
testsuite/tests/rts/linker/T5435_v_asm_a.stdout-mingw32 [moved from testsuite/tests/rts/T5435_v_asm_a.stdout-mingw32 with 100% similarity]
testsuite/tests/rts/linker/T5435_v_asm_b.stdout [moved from testsuite/tests/rts/T5435_v_asm_b.stdout with 100% similarity]
testsuite/tests/rts/linker/T5435_v_gcc.stdout [moved from testsuite/tests/rts/T5435_v_gcc.stdout with 100% similarity]
testsuite/tests/rts/linker/Test.hs [moved from testsuite/tests/rts/Test.hs with 100% similarity]
testsuite/tests/rts/linker/all.T
testsuite/tests/rts/linker/libfoo_T2615.c [moved from testsuite/tests/rts/libfoo_T2615.c with 100% similarity]
testsuite/tests/rts/linker/libfoo_script_T2615.so [moved from testsuite/tests/rts/libfoo_script_T2615.so with 100% similarity]
testsuite/tests/rts/linker/linker_error.c [moved from testsuite/tests/rts/linker_error.c with 100% similarity]
testsuite/tests/rts/linker/linker_error2.c [moved from testsuite/tests/rts/linker_error2.c with 100% similarity]
testsuite/tests/rts/linker/linker_error3.c [moved from testsuite/tests/rts/linker_error3.c with 100% similarity]
testsuite/tests/rts/linker/linker_unload.c [moved from testsuite/tests/rts/linker_unload.c with 100% similarity]
testsuite/tests/rts/linker/linker_unload.stdout [moved from testsuite/tests/rts/linker_unload.stdout with 100% similarity]
testsuite/tests/rts/linker/rdynamic.hs [moved from testsuite/tests/rts/rdynamic.hs with 100% similarity]
testsuite/tests/rts/linker/rdynamic.stdout [moved from testsuite/tests/rts/rdynamic.stdout with 100% similarity]

index 08d2051..32c2b17 100644 (file)
@@ -16,11 +16,6 @@ outofmem2::
        $(MAKE) -s --no-print-directory outofmem2-prep
        @ulimit -m 1000000 2>/dev/null; ./outofmem2 +RTS -M5m -RTS || echo "exit($$?)"
 
-T2615-prep:
-       $(RM) libfoo_T2615.so
-       '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -c libfoo_T2615.c -o libfoo_T2615.o
-       '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -shared -no-auto-link-packages libfoo_T2615.o -o libfoo_T2615.so
-
 .PHONY: T4059
 T4059:
        $(RM) T4059_c.o T4059.o T4059.hi
@@ -62,38 +57,6 @@ T9405:
 #           | asm // manually laid out sections
 # $(0) = obj-src
 
-define run_T5435_v
-$(RM) T5435_load_v_$(1) T5435_v_$(1)$(exeext)
-'$(TEST_HC)' $(TEST_HC_OPTS) -optc-D$(HostOS)_HOST_OS -optc-DLOAD_CONSTR=$(2) -v0 -c T5435_$(1).c -o T5435_load_v_$(1).o
-'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_v_$(1)_o -o T5435_v_$(1)$(exeext)
-./T5435_v_$(1) v ./T5435_load_v_$(1).o
-endef
-
-define run_T5435_dyn
-$(RM) T5435_load_dyn_$(1) T5435_dyn_$(1)$(exeext)
-'$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -optc-D$(HostOS)_HOST_OS -v0 -fPIC -shared -c T5435_$(1).c -osuf dyn_$(1)_o -o T5435_load_dyn_$(1)$(dllext)
-'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_dyn_$(1)_o -o T5435_dyn_$(1)$(exeext)
-./T5435_dyn_$(1) dyn ./T5435_load_dyn_$(1)$(dllext)
-endef
-
-.PHONY: T5435_v_gcc
-T5435_v_gcc :
-       $(call run_T5435_v,gcc,0)
-
-.PHONY: T5435_v_asm_a T5435_v_asm_b
-T5435_v_asm_a :
-       $(call run_T5435_v,asm,0)
-T5435_v_asm_b :
-       $(call run_T5435_v,asm,1)
-
-.PHONY: T5435_dyn_gcc
-T5435_dyn_gcc :
-       $(call run_T5435_dyn,gcc)
-
-.PHONY: T5435_dyn_asm
-T5435_dyn_asm :
-       $(call run_T5435_dyn,asm)
-
 T6006_setup :
        '$(TEST_HC)' $(TEST_HC_OPTS) -c T6006.hs
 
@@ -121,52 +84,6 @@ T10296a:
        '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -threaded T10296a.hs T10296a_c.c -o T10296a
        ./T10296a +RTS -N2
 
-.PHONY: linker_unload
-linker_unload:
-       $(RM) Test.o Test.hi
-       "$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0
-       # -rtsopts causes a warning
-       "$(TEST_HC)" LinkerUnload.hs -package ghc $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror
-       ./linker_unload "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
-
-# -----------------------------------------------------------------------------
-# Testing failures in the RTS linker.  We should be able to repeatedly
-# load bogus object files of various kinds without crashing and
-# without any memory leaks.
-#
-# Check for memory leaks manually by running e.g.
-#
-# make linker_error1
-# valgrind --leak-check=full --show-reachable=yes ./linker_error1 linker_error1_o.o
-
-# linker_error1: not a valid object file
-
-.PHONY: linker_error1
-linker_error1:
-       "$(TEST_HC)" -c linker_error.c -o linker_error1.o
-       "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug -threaded
-       ./linker_error1 linker_error.c
-
-# linker_error2: the object file has an unknown symbol (fails in
-# resolveObjs())
-
-.PHONY: linker_error2
-linker_error2:
-       "$(TEST_HC)" -c linker_error.c -o linker_error2.o
-       "$(TEST_HC)" -c linker_error2.c -o linker_error2_o.o
-       "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug -threaded
-       ./linker_error2 linker_error2_o.o
-
-# linker_error3: the object file duplicates an existing symbol (fails
-# in loadObj())
-
-.PHONY: linker_error3
-linker_error3:
-       "$(TEST_HC)" -c linker_error.c -o linker_error3.o
-       "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o
-       "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded
-       ./linker_error3 linker_error3_o.o
-
  .PHONY: T11788
 T11788:
        "$(TEST_HC)" -c T11788.c -o T11788_obj.o
index 4d2be2b..86f79c2 100644 (file)
@@ -119,21 +119,6 @@ test('rtsflags001', [ only_ways(['normal']), exit_code(1), extra_run_opts('+RTS
 # Crashed with 7.2 and earlier
 test('rtsflags002', [ only_ways(['normal']) ], compile_and_run, ['-with-rtsopts="-B -B -B"'])
 
-# Test to see if linker scripts link properly to real ELF files
-test('T2615',
-     [extra_files(['libfoo_T2615.c', 'libfoo_script_T2615.so']),
-       when(opsys('mingw32'), skip),
-       # OS X doesn't seem to support linker scripts
-       when(opsys('darwin'), skip),
-       # Solaris' linker does not support GNUish linker scripts
-       when(opsys('solaris2'), skip),
-       pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
-       # Add current directory to dlopen search path
-       cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
-       extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
-     compile_and_run,
-     ['-package ghc'])
-
 # omit dyn and profiling ways, because we don't build dyn_l or p_l
 # variants of the RTS by default
 test('traceEvent', [ omit_ways(['dyn', 'ghci'] + prof_ways),
@@ -185,49 +170,6 @@ test('T5250', [extra_files(['spalign.c']),
 
 test('T5423', [], makefile_test, ['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', 'success']:
-        return True
-    elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
-        return True
-    elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
-        return True
-    else:
-        if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
-        return False
-
-# T5435_v_asm got split into two tests because depending
-# on the linker, .init_array and .ctors sections are loaded
-# in a different order (but all entries within a section
-# do get loaded in a deterministic order). So we test each
-# separately now.
-# These should have extra_clean() arguments, but I need
-# to somehow extract out the name of DLLs to do that
-test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']),
-                     when(arch('powerpc64') or arch('powerpc64le'),
-                          expect_broken(11259))],
-     makefile_test, ['T5435_v_asm_a'])
-# this one just needs to run on linux, as darwin/mingw32 are covered
-# by the _a test already.
-test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']),
-                      when(arch('powerpc64') or arch('powerpc64le'),
-                          expect_broken(11259)),
-                      when(opsys('darwin') or opsys('mingw32'), skip)],
-     makefile_test, ['T5435_v_asm_b'])
-test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']),
-                     when(arch('powerpc64') or arch('powerpc64le'),
-                          expect_broken(11259))],
-     makefile_test, ['T5435_v_gcc'])
-test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']),
-                       check_stdout(checkDynAsm)],
-     makefile_test, ['T5435_dyn_asm'])
-test('T5435_dyn_gcc', extra_files(['T5435.hs', 'T5435_gcc.c']) , makefile_test, ['T5435_dyn_gcc'])
-
 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
 
 test('T6006', [ omit_ways(prof_ways + ['ghci']),
@@ -277,11 +219,6 @@ test('T7919', [when(fast(), skip), omit_ways(prof_ways)], compile_and_run,
 
 test('T8035', normal, compile_and_run, [''])
 
-test('linker_unload',
-     [extra_files(['LinkerUnload.hs', 'Test.hs']),
-      when(arch('powerpc64') or arch('powerpc64le'), expect_broken(11259))],
-     makefile_test, ['linker_unload'])
-
 test('T8209', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
               compile_and_run, [''])
 
@@ -312,13 +249,6 @@ test('T10017', [ when(opsys('mingw32'), skip)
 
 test('T11108', normal, compile_and_run, [''])
 
-test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
-                 # this needs runtime infrastructure to do in ghci:
-                 #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
-                 , omit_ways(['ghci'])
-                 ],
-     compile_and_run, ['-rdynamic -package ghc'])
-
 test('GcStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
      compile_and_run, [''])
 test('ListStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
@@ -330,15 +260,6 @@ test('overflow1', [ exit_code(251), when(wordsize(32), expect_broken(15255)) ],
 test('overflow2', [ exit_code(251) ], compile_and_run, [''])
 test('overflow3', [ exit_code(251) ], compile_and_run, [''])
 
-test('linker_error1', [extra_files(['linker_error.c']),
-                       ignore_stderr], makefile_test, ['linker_error1'])
-
-test('linker_error2', [extra_files(['linker_error.c']),
-                       ignore_stderr], makefile_test, ['linker_error2'])
-
-test('linker_error3', [extra_files(['linker_error.c']),
-                       ignore_stderr], makefile_test, ['linker_error3'])
-
 def grep_stderr(pattern):
     def wrapper(cmd, pattern=pattern):
         swap12 = '3>&1 1>&2 2>&3 3>&-' # Swap file descriptors 1 and 2.
index edbd291..de4c19b 100644 (file)
@@ -11,3 +11,88 @@ section_alignment:
        cc -c -o section_alignment.o section_alignment.c
        '$(TEST_HC)' $(TEST_HC_OPTS_NO_RTSOPTS) -v0 --make -no-rtsopts-suggestions -no-hs-main -o runner runner.c
        ./runner section_alignment.o isAligned
+
+T2615-prep:
+       $(RM) libfoo_T2615.so
+       '$(TEST_HC)' $(TEST_HC_OPTS) -fPIC -c libfoo_T2615.c -o libfoo_T2615.o
+       '$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -shared -no-auto-link-packages libfoo_T2615.o -o libfoo_T2615.so
+
+#--------------------------------------------------------------------
+define run_T5435_v
+$(RM) T5435_load_v_$(1) T5435_v_$(1)$(exeext)
+'$(TEST_HC)' $(TEST_HC_OPTS) -optc-D$(HostOS)_HOST_OS -optc-DLOAD_CONSTR=$(2) -v0 -c T5435_$(1).c -o T5435_load_v_$(1).o
+'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_v_$(1)_o -o T5435_v_$(1)$(exeext)
+./T5435_v_$(1) v ./T5435_load_v_$(1).o
+endef
+
+define run_T5435_dyn
+$(RM) T5435_load_dyn_$(1) T5435_dyn_$(1)$(exeext)
+'$(TEST_HC)' $(filter-out -rtsopts, $(TEST_HC_OPTS)) -optc-D$(HostOS)_HOST_OS -v0 -fPIC -shared -c T5435_$(1).c -osuf dyn_$(1)_o -o T5435_load_dyn_$(1)$(dllext)
+'$(TEST_HC)' $(TEST_HC_OPTS) -v0 T5435.hs -osuf main_dyn_$(1)_o -o T5435_dyn_$(1)$(exeext)
+./T5435_dyn_$(1) dyn ./T5435_load_dyn_$(1)$(dllext)
+endef
+
+.PHONY: T5435_v_gcc
+T5435_v_gcc :
+       $(call run_T5435_v,gcc,0)
+
+.PHONY: T5435_v_asm_a T5435_v_asm_b
+T5435_v_asm_a :
+       $(call run_T5435_v,asm,0)
+T5435_v_asm_b :
+       $(call run_T5435_v,asm,1)
+
+.PHONY: T5435_dyn_gcc
+T5435_dyn_gcc :
+       $(call run_T5435_dyn,gcc)
+
+.PHONY: T5435_dyn_asm
+T5435_dyn_asm :
+       $(call run_T5435_dyn,asm)
+
+#--------------------------------------------------------------------
+.PHONY: linker_unload
+linker_unload:
+       $(RM) Test.o Test.hi
+       "$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0
+       # -rtsopts causes a warning
+       "$(TEST_HC)" LinkerUnload.hs -package ghc $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror
+       ./linker_unload "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`"
+
+# -----------------------------------------------------------------------------
+# Testing failures in the RTS linker.  We should be able to repeatedly
+# load bogus object files of various kinds without crashing and
+# without any memory leaks.
+#
+# Check for memory leaks manually by running e.g.
+#
+# make linker_error1
+# valgrind --leak-check=full --show-reachable=yes ./linker_error1 linker_error1_o.o
+
+# linker_error1: not a valid object file
+
+.PHONY: linker_error1
+linker_error1:
+       "$(TEST_HC)" -c linker_error.c -o linker_error1.o
+       "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug -threaded
+       ./linker_error1 linker_error.c
+
+# linker_error2: the object file has an unknown symbol (fails in
+# resolveObjs())
+
+.PHONY: linker_error2
+linker_error2:
+       "$(TEST_HC)" -c linker_error.c -o linker_error2.o
+       "$(TEST_HC)" -c linker_error2.c -o linker_error2_o.o
+       "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug -threaded
+       ./linker_error2 linker_error2_o.o
+
+# linker_error3: the object file duplicates an existing symbol (fails
+# in loadObj())
+
+.PHONY: linker_error3
+linker_error3:
+       "$(TEST_HC)" -c linker_error.c -o linker_error3.o
+       "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o
+       "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded
+       ./linker_error3 linker_error3_o.o
index be2e972..f57edc4 100644 (file)
@@ -8,9 +8,94 @@ test('unsigned_reloc_macho_x64',
      ],
      run_command, ['$MAKE -s --no-print-directory unsigned_reloc_macho_x64'])
 
+######################################
 test('section_alignment',
      [
          extra_files(['runner.c', 'section_alignment.c']),
          unless(opsys('darwin') and arch('x86_64'), expect_broken(13624))
      ],
      run_command, ['$MAKE -s --no-print-directory section_alignment'])
+
+######################################
+# Test to see if linker scripts link properly to real ELF files
+test('T2615',
+     [extra_files(['libfoo_T2615.c', 'libfoo_script_T2615.so']),
+       when(opsys('mingw32'), skip),
+       # OS X doesn't seem to support linker scripts
+       when(opsys('darwin'), skip),
+       # Solaris' linker does not support GNUish linker scripts
+       when(opsys('solaris2'), skip),
+       pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
+       # Add current directory to dlopen search path
+       cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
+       extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
+     compile_and_run,
+     ['-package ghc'])
+
+######################################
+# 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', 'success']:
+        return True
+    elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
+        return True
+    elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
+        return True
+    else:
+        if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
+        return False
+
+# T5435_v_asm got split into two tests because depending
+# on the linker, .init_array and .ctors sections are loaded
+# in a different order (but all entries within a section
+# do get loaded in a deterministic order). So we test each
+# separately now.
+# These should have extra_clean() arguments, but I need
+# to somehow extract out the name of DLLs to do that
+test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']),
+                     when(arch('powerpc64') or arch('powerpc64le'),
+                          expect_broken(11259))],
+     makefile_test, ['T5435_v_asm_a'])
+# this one just needs to run on linux, as darwin/mingw32 are covered
+# by the _a test already.
+test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']),
+                      when(arch('powerpc64') or arch('powerpc64le'),
+                          expect_broken(11259)),
+                      when(opsys('darwin') or opsys('mingw32'), skip)],
+     makefile_test, ['T5435_v_asm_b'])
+test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']),
+                     when(arch('powerpc64') or arch('powerpc64le'),
+                          expect_broken(11259))],
+     makefile_test, ['T5435_v_gcc'])
+test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']),
+                       check_stdout(checkDynAsm)],
+     makefile_test, ['T5435_dyn_asm'])
+test('T5435_dyn_gcc', extra_files(['T5435.hs', 'T5435_gcc.c']) , makefile_test, ['T5435_dyn_gcc'])
+
+######################################
+test('linker_unload',
+     [extra_files(['LinkerUnload.hs', 'Test.hs']),
+      when(arch('powerpc64') or arch('powerpc64le'), expect_broken(11259))],
+     makefile_test, ['linker_unload'])
+
+######################################
+test('linker_error1', [extra_files(['linker_error.c']),
+                       ignore_stderr], makefile_test, ['linker_error1'])
+
+test('linker_error2', [extra_files(['linker_error.c']),
+                       ignore_stderr], makefile_test, ['linker_error2'])
+
+test('linker_error3', [extra_files(['linker_error.c']),
+                       ignore_stderr], makefile_test, ['linker_error3'])
+
+######################################
+test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
+                 # this needs runtime infrastructure to do in ghci:
+                 #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
+                 , omit_ways(['ghci'])
+                 ],
+     compile_and_run, ['-rdynamic -package ghc'])