Revert "UTF8 Marshaling APIs (#3736)"
[mono.git] / mono / tests / Makefile.am
index d95f31f4a655bb38fef728cc96d1708f11a72d47..b33cb19ef982f9117fc10dc76898692456dda1f1 100644 (file)
@@ -1,6 +1,13 @@
 SUBDIRS = assemblyresolve gc-descriptors
 
-check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-cattr-type-load test-reflection-load-with-context test_platform test-process-exit test-console-output test-messages test-env-options test-unhandled-exception-2 test-appdomain-unload rm-empty-logs
+if INSTALL_MOBILE_STATIC
+FEATUREFUL_RUNTIME_TEST =  
+else
+FEATUREFUL_RUNTIME_TEST = test-appdomain-unload
+endif
+
+check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-multi-netmodule test-cattr-type-load test-reflection-load-with-context test_platform        \
+                test-console-output test-messages test-env-options test-unhandled-exception-2 $(FEATUREFUL_RUNTIME_TEST) test-process-stress rm-empty-logs
 check-full: test-sgen check-local
 check-parallel: compile-tests check-full
 
@@ -21,6 +28,14 @@ JITTEST_PROG_RUN = MONO_CFG_DIR=$(mono_build_root)/runtime/etc $(LIBTOOL) --mode
 
 RUNTIME_ARGS=--config tests-config --optimize=all --debug
 
+if HOST_WIN32
+TEST_RUNNER_ARGS=--config tests-config --runtime $(if $(MONO_EXECUTABLE),$(shell cygpath -w -a $(MONO_EXECUTABLE) | sed 's/\\/\\\\/g'),mono)
+else
+TEST_RUNNER_ARGS=--config tests-config --runtime $(if $(MONO_EXECUTABLE),$(MONO_EXECUTABLE),mono)
+endif
+
+TEST_RUNNER_ARGS += $(if $(V), --verbose,)
+
 CLASS=$(mcs_topdir)/class/lib/$(DEFAULT_PROFILE)
 
 with_mono_path = MONO_PATH=$(CLASS)
@@ -31,12 +46,27 @@ MKBUNDLE = \
        PKG_CONFIG_PATH=$(top_builddir):$(PKG_CONFIG_PATH) \
        $(RUNTIME) $(CLASS)/mkbundle.exe
 
-MCS = $(RUNTIME) $(mcs_topdir)/class/lib/build/mcs.exe -unsafe -debug \
+if INSTALL_MOBILE_STATIC
+PROFILE_MCS_FLAGS = -d:MOBILE,MOBILE_STATIC,MOBILE_LEGACY 
+endif
+
+MCS_NO_LIB = $(RUNTIME) $(mcs_topdir)/class/lib/build/mcs.exe -unsafe -debug \
+       -noconfig -nologo \
        -nowarn:0162 -nowarn:0168 -nowarn:0219 -nowarn:0414 -nowarn:0618 \
        -nowarn:0169 -nowarn:1690 -nowarn:0649 -nowarn:0612 -nowarn:3021 \
-       -nowarn:0197
+       -nowarn:0197 $(PROFILE_MCS_FLAGS)
+
+MCS = $(MCS_NO_LIB) -lib:$(CLASS)
+
 ILASM = $(RUNTIME) $(CLASS)/ilasm.exe
 
+if INSTALL_MOBILE_STATIC
+TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)" --aot-run-flags "$(AOT_RUN_FLAGS)" --aot-build-flags "$(AOT_BUILD_FLAGS)"
+else
+TEST_RUNNER = ./test-runner.exe --runtime $(top_builddir)/runtime/mono-wrapper --mono-path "$(CLASS)"
+endif
+
+
 BENCHSRC=fib.cs random.cs nested-loops.cs ackermann.cs tight-loop.cs sieve.cs
 
 STRESS_TESTS_SRC=      \
@@ -54,18 +84,80 @@ STRESS_TESTS_SRC=   \
        process-stress.cs       \
        assembly-load-stress.cs
 
+BASE_TEST_MOBILE_STATIC_NOT_SUPPORTED= \
+       remoting4.cs            # Needs remoting support \
+       remoting1.cs            # Needs remoting support \
+       remoting2.cs            # Needs remoting support \
+       remoting3.cs            # Needs remoting support \
+       remoting5.cs            # Needs remoting support \
+       appdomain.cs        # Needs appdomain support \
+       appdomain-client.cs     # Needs appdomain support \
+       appdomain-unload.cs # Needs appdomain support \
+       appdomain-async-invoke.cs       # Needs appdomain support \
+       appdomain-thread-abort.cs       # Needs appdomain support \
+       appdomain1.cs           # Needs appdomain support \
+       appdomain2.cs           # Needs appdomain support \
+       appdomain-exit.cs       # Needs appdomain support \
+       assemblyresolve_event2.2.cs     # Needs appdomain support \
+       appdomain-unload-callback.cs    # Needs appdomain support \
+       appdomain-unload-doesnot-raise-pending-events.cs        # Needs appdomain support \
+       unload-appdomain-on-shutdown.cs # Needs appdomain support \
+       bug-47295.cs # Needs SRE \
+       loader.cs # Needs SRE \
+       pinvoke2.cs # Needs SRE \
+       generic-type-builder.2.cs       # Needs SRE \
+       dynamic-generic-size.cs # Needs SRE \
+       cominterop.cs   # Needs COM \
+       dynamic-method-access.2.cs      # Need SRE \
+       dynamic-method-finalize.2.cs    # Need SRE \
+       dynamic-method-stack-traces.cs # Need SRE\
+       generic_type_definition.2.cs    # Need SRE \
+       bug-333798-tb.2.cs      # Need SRE \
+       bug-335131.2.cs # Need SRE \
+       bug-322722_patch_bx.2.cs        # Need SRE\
+       bug-322722_dyn_method_throw.2.cs        # Need SRE \
+       bug-389886-2.cs # Need SRE \
+       bug-349190.2.cs # Need SRE \
+       bug-389886-sre-generic-interface-instances.cs   # Need SRE \
+       bug-462592.cs   # Need SRE \
+       bug-575941.cs   # Need SRE \
+       bug-389886-3.cs # Need SRE \
+       constant-division.cs    # Need SRE \
+       dynamic-method-resurrection.cs  # Need SRE \
+       bug-80307.cs    # Need System.Web \
+       assembly_append_ordering.cs # Need SRE \
+       bug-544446.cs   # Needs AppDomains / TranparentProxy \
+       bug-36848.cs   # Needs AppDomains / TranparentProxy \
+       generic-marshalbyref.2.cs # Needs AppDomains \
+       stackframes-async.2.cs # Needs AppDomains \
+       transparentproxy.cs # Needs AppDomains / TranparentProxy \
+       bug-48015.cs # Needs AppDomains / TranparentProxy \
+       delegate9.cs # Needs AppDomains \
+       marshal-valuetypes.cs   # Needs AppDomains \
+       xdomain-threads.cs      # Needs AppDomains \
+       monitor.cs # Needs AppDomains \
+       generic-xdomain.2.cs # Needs AppDomains \
+       threadpool-exceptions7.cs # Needs AppDomains \
+       cross-domain.cs # Needs AppDomains \
+       generic-unloading.2.cs # Needs AppDomains \
+       namedmutex-destroy-race.cs # needs named Mutex \
+       thread6.cs # On MOBILE, ThreadAbortException doesn't have necessary field for this test
+
 # Disabled until ?mcs is fixed
 #      bug-331958.cs
-BASE_TEST_CS_SRC=              \
+# Note: only add tests that are compatible with mobile_static to this category
+BASE_TEST_CS_SRC_UNIVERSAL=            \
+       generic-unloading-sub.2.cs      \
+       create-instance.cs      \
        bug-2907.cs             \
        array-init.cs           \
        arraylist.cs            \
+       assembly-load-remap.cs  \
        assemblyresolve_event.cs        \
        assemblyresolve_event3.cs       \
        assemblyresolve_event4.cs       \
        checked.cs              \
        char-isnumber.cs        \
-       create-instance.cs      \
        field-layout.cs         \
        pack-layout.cs          \
        pack-bug.cs             \
@@ -102,7 +194,6 @@ BASE_TEST_CS_SRC=           \
        typeof-ptr.cs           \
        static-constructor.cs   \
        pinvoke.cs              \
-       pinvoke2.cs             \
        pinvoke3.cs             \
        pinvoke11.cs            \
        pinvoke13.cs            \
@@ -168,13 +259,6 @@ BASE_TEST_CS_SRC=          \
        jit-float.cs            \
        pop.cs                  \
        time.cs                 \
-       appdomain.cs        \
-       appdomain1.cs           \
-       appdomain2.cs           \
-       appdomain-client.cs     \
-       appdomain-unload.cs \
-       appdomain-async-invoke.cs       \
-       loader.cs       \
        pointer.cs              \
        hashcode.cs             \
        delegate1.cs            \
@@ -184,16 +268,10 @@ BASE_TEST_CS_SRC=         \
        delegate6.cs            \
        delegate7.cs            \
        delegate8.cs            \
-       delegate9.cs            \
        delegate10.cs           \
        delegate11.cs           \
        delegate12.cs           \
        delegate13.cs           \
-       remoting1.cs            \
-       remoting2.cs            \
-       remoting3.cs            \
-       remoting4.cs            \
-       remoting5.cs            \
        largeexp.cs             \
        largeexp2.cs            \
        marshalbyref1.cs        \
@@ -214,11 +292,9 @@ BASE_TEST_CS_SRC=          \
        marshal8.cs             \
        marshal9.cs             \
        marshalbool.cs          \
-       marshal-valuetypes.cs   \
        test-byval-in-struct.cs \
        thread.cs               \
        thread5.cs              \
-       thread6.cs              \
        thread-static.cs        \
        thread-static-init.cs   \
        context-static.cs       \
@@ -238,12 +314,9 @@ BASE_TEST_CS_SRC=          \
        threadpool-exceptions4.cs \
        threadpool-exceptions5.cs \
        threadpool-exceptions6.cs \
-       threadpool-exceptions7.cs \
        base-definition.cs      \
        bug-27420.cs            \
-       bug-47295.cs            \
        bug-46781.cs            \
-       bug-48015.cs            \
        bug-42136.cs            \
        bug-59286.cs            \
        bug-70561.cs            \
@@ -254,8 +327,6 @@ BASE_TEST_CS_SRC=           \
        bug-323114.cs           \
        bug-Xamarin-5278.cs     \
        interlocked.cs          \
-       cross-domain.cs         \
-       appdomain-exit.cs       \
        delegate-async-exit.cs  \
        delegate-delegate-exit.cs       \
        delegate-exit.cs        \
@@ -272,16 +343,13 @@ BASE_TEST_CS_SRC=         \
        main-returns.cs         \
        subthread-exit.cs       \
        desweak.cs              \
-       cominterop.cs           \
        exists.cs               \
        handleref.cs    \
-       transparentproxy.cs \
        dbnull-missing.cs       \
        test-type-ctor.cs       \
        soft-float-tests.cs     \
        thread-exit.cs          \
        finalize-parent.cs      \
-       assemblyresolve_event2.2.cs     \
        interlocked-2.2.cs      \
        pinvoke-2.2.cs          \
        bug-78431.2.cs          \
@@ -289,7 +357,6 @@ BASE_TEST_CS_SRC=           \
        catch-generics.2.cs     \
        event-get.2.cs          \
        safehandle.2.cs         \
-       stackframes-async.2.cs          \
        module-cctor-loader.2.cs        \
        generics-invoke-byref.2.cs      \
        generic-signature-compare.2.cs  \
@@ -311,14 +378,10 @@ BASE_TEST_CS_SRC=         \
        generic-virtual2.2.cs   \
        generic-valuetype-interface.2.cs        \
        generic-getgenericarguments.2.cs        \
-       generic-type-builder.2.cs       \
        generic-synchronized.2.cs       \
        generic-delegate-ctor.2.cs      \
        generic-array-iface-set.2.cs    \
        generic-typedef.2.cs    \
-       generic-marshalbyref.2.cs       \
-       generic-xdomain.2.cs    \
-       dynamic-generic-size.cs \
        bug-431413.2.cs \
        bug-459285.2.cs \
        generic-virtual-invoke.2.cs     \
@@ -334,27 +397,17 @@ BASE_TEST_CS_SRC=         \
        bug-479763.2.cs \
        bug-616463.cs   \
        bug-80392.2.cs          \
-       dynamic-method-access.2.cs      \
-       dynamic-method-finalize.2.cs    \
-       dynamic-method-stack-traces.cs  \
        bug-82194.2.cs  \
        anonarray.2.cs  \
        ienumerator-interfaces.2.cs     \
        array-enumerator-ifaces.2.cs    \
        generic_type_definition_encoding.2.cs \
-       generic_type_definition.2.cs    \
        bug-333798.2.cs         \
-       bug-333798-tb.2.cs              \
-       bug-335131.2.cs         \
-       bug-322722_patch_bx.2.cs                \
        bug-348522.2.cs         \
        bug-340662_bug.cs       \
-       bug-322722_dyn_method_throw.2.cs        \
-       bug-389886-2.cs \
        bug-325283.2.cs \
        thunks.cs \
        winx64structs.cs \
-       bug-349190.2.cs \
        nullable_boxing.2.cs    \
        valuetype-equals.cs     \
        custom-modifiers.2.cs   \
@@ -363,42 +416,30 @@ BASE_TEST_CS_SRC=         \
        bug-324535.cs   \
        modules.cs      \
        bug-81673.cs    \
-       bug-36848.cs    \
        bug-81691.cs    \
-       bug-80307.cs    \
        bug-415577.cs   \
        filter-stack.cs \
        vararg2.cs      \
-       bug-389886-sre-generic-interface-instances.cs   \
        bug-461867.cs   \
        bug-461941.cs   \
        bug-461261.cs   \
        bug-400716.cs   \
-       bug-462592.cs   \
        bug-459094.cs   \
-       generic-unloading.2.cs  \
-       generic-unloading-sub.2.cs      \
        bug-467456.cs   \
-       appdomain-unload-callback.cs    \
        bug-508538.cs   \
        bug-472692.2.cs         \
        gchandles.cs    \
        interlocked-3.cs        \
        interlocked-4.2.cs      \
-       appdomain-thread-abort.cs \
-       xdomain-threads.cs      \
        w32message.cs   \
-       bug-544446.cs   \
        gc-altstack.cs  \
        large-gc-bitmap.cs      \
        bug-561239.cs   \
        bug-562150.cs   \
-       bug-575941.cs   \
        bug-599469.cs   \
-       bug-389886-3.cs \
-       monitor.cs      \
        monitor-resurrection.cs \
-       dynamic-method-resurrection.cs  \
+       monitor-wait-abort.cs   \
+       monitor-abort.cs        \
        bug-666008.cs   \
        bug-685908.cs   \
        sgen-long-vtype.cs      \
@@ -410,13 +451,10 @@ BASE_TEST_CS_SRC=         \
        bug-bxc-795.cs  \
        bug-3903.cs     \
        async-with-cb-throws.cs \
-       appdomain-unload-doesnot-raise-pending-events.cs        \
        bug-6148.cs     \
-       assembly_append_ordering.cs     \
        bug-10127.cs    \
        bug-18026.cs    \
        allow-synchronous-major.cs      \
-       unload-appdomain-on-shutdown.cs \
        block_guard_restore_aligment_on_exit.cs \
        thread_static_gc_layout.cs \
        sleep.cs \
@@ -427,7 +465,20 @@ BASE_TEST_CS_SRC=          \
        pinvoke_ppcs.cs \
        pinvoke_ppci.cs \
        pinvoke_ppcf.cs \
-       pinvoke_ppcd.cs
+       pinvoke_ppcd.cs \
+       bug-29585.cs    \
+       priority.cs     \
+       abort-cctor.cs  \
+       thread-native-exit.cs
+
+if INSTALL_MOBILE_STATIC
+BASE_TEST_CS_SRC= \
+       $(BASE_TEST_CS_SRC_UNIVERSAL)
+else
+BASE_TEST_CS_SRC= \
+       $(BASE_TEST_MOBILE_STATIC_NOT_SUPPORTED) \
+       $(BASE_TEST_CS_SRC_UNIVERSAL)
+endif
 
 TEST_CS_SRC_DIST=      \
        $(BASE_TEST_CS_SRC)     \
@@ -576,6 +627,58 @@ endif
 
 endif
 
+if ENABLE_COOP
+COOP_DISABLED_TESTS= thunks.exe
+else
+COOP_DISABLED_TESTS= 
+endif
+
+if INSTALL_MOBILE_STATIC
+# Tests which rely on TypeLoadExceptions
+# In full-aot mode, these cause the relevant methods to be not AOTed.
+PROFILE_DISABLED_TESTS = \
+       typeload-unaligned.exe \
+       field-access.exe \
+       invalid_generic_instantiation.exe \
+       bug-481403.exe \
+       array_ldelema.exe \
+       array_load_exception.exe \
+       bug445361.exe \
+       generic-type-load-exception.2.exe \
+       invalid-token.exe \
+       call_missing_method.exe \
+       call_missing_class.exe \
+       ldfld_missing_field.exe \
+       ldfld_missing_class.exe \
+       vt-sync-method.exe
+
+# Tests which rely on remoting
+PROFILE_DISABLED_TESTS += \
+       context-static.exe \
+       bug-415577.exe \
+       generic-marshalbyref.2.exe \
+       unhandled-exception-7.exe
+
+# Tests which use unsupported pinvoke+full aot
+# functionality
+PROFILE_DISABLED_TESTS += \
+       marshal.exe \
+       marshal2.exe \
+       marshal6.exe \
+       marshal7.exe \
+       marshal8.exe \
+       pinvoke-2.2.exe \
+       pinvoke3.exe \
+       thunks.exe
+
+# Tests which load assemblies which are not
+# in the mobile_static profile
+PROFILE_DISABLED_TESTS += \
+       assembly-load-remap.exe
+else
+PROFILE_DISABLED_TESTS=
+endif
+
 # The two finalizer tests only work under sgen
 # gc-altstack.exe fails under boehm because it has no support for altstack
 # bug-459094.exe creates an extremely deep directory tree
@@ -589,7 +692,9 @@ DISABLED_TESTS=                     \
        delegate-invoke.exe \
        bug-Xamarin-5278.exe \
        $(PLATFORM_DISABLED_TESTS) \
-       $(EXTRA_DISABLED_TESTS)
+       $(EXTRA_DISABLED_TESTS) \
+       $(COOP_DISABLED_TESTS) \
+       $(PROFILE_DISABLED_TESTS)
 
 DISABLED_TESTS_WRENCH= \
        $(DISABLED_TESTS)       \
@@ -609,7 +714,14 @@ AOT_DISABLED_TESTS=constraints-load.exe
 TEST_CSC_SRC=                  \
        vararg.cs
 
-TEST_IL_SRC=                   \
+# constraints-load.il: 
+# Failed to load method 0x6000007 from '..../mono/tests/constraints-load.exe' due to 
+# Could not resolve type with token 01000002 assembly:mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 type:System.BrokenIComparable`1 member:<none>.
+IL_SRC_MOBILE_STATIC_NOT_SUPPORTED=    \
+       constraints-load.il \
+       bug-515884.il
+
+TEST_IL_SRC_UNIVERSAL=                 \
        field-access.il         \
        method-access.il        \
        ldftn-access.il         \
@@ -668,17 +780,23 @@ TEST_IL_SRC=                      \
        bug-463303.il   \
        bug469742.2.il  \
        bug-528055.il   \
-       constraints-load.il     \
        array_load_exception.il \
        bug-481403.il   \
        interface-with-static-method.il \
-       bug-515884.il   \
        bug-633291.il   \
        delegate-with-null-target.il    \
        bug-318677.il   \
        gsharing-valuetype-layout.il    \
        invalid_generic_instantiation.il
 
+if INSTALL_MOBILE_STATIC
+TEST_IL_SRC= \
+       $(TEST_IL_SRC_UNIVERSAL)
+else
+TEST_IL_SRC= \
+       $(TEST_IL_SRC_MOBILE_STATIC_NOT_SUPPORTED) \
+       $(TEST_IL_SRC_UNIVERSAL)
+endif
 
 # pre-requisite test sources: files that are not test themselves
 # but that need to be compiled
@@ -694,14 +812,33 @@ TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
 TESTBS=$(BENCHSRC:.cs=.exe)
 STRESS_TESTS=$(STRESS_TESTS_SRC:.cs=.exe)
 
+PREREQSI_IL_AOT=$(PREREQ_IL_SRC:.il=.exe$(PLATFORM_AOT_SUFFIX))
+PREREQSI_CS_AOT=$(PREREQ_CS_SRC:.cs=.exe$(PLATFORM_AOT_SUFFIX))
+
 EXTRA_DIST=test-driver test-runner.cs $(TEST_CS_SRC_DIST) $(TEST_IL_SRC) \
        $(BENCHSRC) $(STRESS_TESTS_SRC) stress-runner.pl $(PREREQ_IL_SRC) $(PREREQ_CS_SRC)
 
 %.exe: %.il
        $(ILASM) -out:$@ $<
 
-%.exe: %.cs TestDriver.dll
-       $(MCS) -r:TestDriver.dll -out:$@ $<
+if !INSTALL_MOBILE_STATIC
+TEST_DRIVER_HARD_KILL_FEATURE=-r:Mono.Posix.dll
+endif
+
+if INSTALL_MOBILE_STATIC
+TEST_DRIVER_DEPEND=TestDriver.dll$(PLATFORM_AOT_SUFFIX)
+else
+TEST_DRIVER_DEPEND=TestDriver.dll
+endif
+
+%.exe: %.cs $(TEST_DRIVER_DEPEND)
+       $(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll $(TEST_DRIVER_HARD_KILL_FEATURE) -out:$@ $<
+
+%.exe$(PLATFORM_AOT_SUFFIX): %.exe 
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $<
+
+%.dll$(PLATFORM_AOT_SUFFIX): %.dll 
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $<
 
 # mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
 if POWERPC
@@ -725,8 +862,22 @@ test_platform: test-eglib-remap
 endif
 endif
 
+AOT_EXTRA_LIBS =       \
+bug-382986-lib.dll$(PLATFORM_AOT_SUFFIX)       \
+bug-324535-il.dll$(PLATFORM_AOT_SUFFIX)        \
+bug-36848-a.dll$(PLATFORM_AOT_SUFFIX)  \
+bug-81691-b.dll$(PLATFORM_AOT_SUFFIX)  \
+bug-327438.2.exe$(PLATFORM_AOT_SUFFIX) \
+bug-81466-lib.dll$(PLATFORM_AOT_SUFFIX)
+
+if INSTALL_MOBILE_STATIC
+prereqs: $(PREREQSI_IL_AOT) $(PREREQSI_CS_AOT) $(AOT_EXTRA_LIBS)
+else
+prereqs: $(PREREQSI_IL) $(PREREQSI_CS)
+endif
+
 # Target to precompile the test executables
-tests: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS) $(GSHARED_TESTS)
+tests: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la prereqs $(GSHARED_TESTS)
 
 #
 # Test that no symbols are missed in eglib-remap.h
@@ -759,40 +910,25 @@ endif
 test-env-options:
        MONO_ENV_OPTIONS="--version" $(RUNTIME) array-init.exe | grep -q Architecture:
 
-if AMD64
-test-sgen : sgen-tests
-else
-if X86
-if HOST_WIN32
-test-sgen :
-else
-test-sgen : sgen-tests
-endif
-else
-if ARM
 test-sgen : sgen-tests
-else
-if S390X
-test-sgen : sgen-regular-tests
-endif
-endif
-endif
-endif
 
 # Precompile the test assemblies in parallel
 compile-tests:
        $(MAKE) -j4 $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
+if INSTALL_MOBILE_STATIC
+       $(MAKE) $(PREREQSI_IL_AOT) $(PREREQSI_CS_AOT) $(AOT_EXTRA_LIBS)
+endif
 
 # Remove empty .stdout and .stderr files for wrench
 rm-empty-logs:
        @echo "Removing empty logs..."
-       @find . '(' -name "*.stdout" -o -name "*.stderr" ')' -empty -exec rm {} \;
+       find . '(' -name "*.stdout" -o -name "*.stderr" ')' -size 0 -exec rm {} \;
 
 assemblyresolve/test/asm.dll:
        $(MAKE) -C assemblyresolve prereq
 
 TestDriver.dll:
-       $(MCS) -target:library -out:$@ $(srcdir)/../mini/TestDriver.cs
+       $(MCS) -target:library -out:$@ $(srcdir)/../mini/TestDriver.cs $(srcdir)/../mini/TestHelpers.cs
 
 test_cs: $(TEST_PROG) $(TESTSI_CS) libtest.la
        @failed=0; \
@@ -869,11 +1005,11 @@ runtest: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQS
 
 runtest-managed: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
        @if [ "x$$CI" = "x1" ]; then disabled_tests="$(DISABLED_TESTS_WRENCH)"; else disabled_tests="$(DISABLED_TESTS)"; fi; \
-       $(RUNTIME) --debug ./test-runner.exe -j a --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
+       $(RUNTIME) --debug $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name "runtime" --timeout 300 --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
 
 runtest-managed-serial: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
        @if [ "x$$CI" = "x1" ]; then disabled_tests="$(DISABLED_TESTS_WRENCH)"; else disabled_tests="$(DISABLED_TESTS)"; fi; \
-       $(RUNTIME) --debug ./test-runner.exe -j 1 --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
+       $(RUNTIME) --debug $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j 1 --testsuite-name "runtime" --disabled "$${disabled_tests}" $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
 
 testjit:
        @if test x$(M) != x0; then $(MAKE) runtest-managed; else $(MAKE) runtest; fi
@@ -923,7 +1059,7 @@ testbundle: console.exe
        @- rm -rf a.out
 
 EXTRA_DIST += load-missing.il t-missing.cs load-exceptions.cs
-test-type-load: TestDriver.dll
+test-type-load: $(TEST_DRIVER_DEPEND)
        @$(ILASM) /dll /output:load-missing.dll $(srcdir)/load-missing.il > /dev/null
        @$(MCS) -t:library -out:t.dll -d:FOUND $(srcdir)/t-missing.cs
        @$(MCS) -r:TestDriver.dll -r:load-missing.dll -r:t.dll -out:load-exceptions.exe $(srcdir)/load-exceptions.cs
@@ -931,8 +1067,16 @@ test-type-load: TestDriver.dll
        @echo "Testing load-exception.exe..."
        @$(RUNTIME) load-exceptions.exe > load-exceptions.exe.stdout 2> load-exceptions.exe.stderr
 
+EXTRA_DIST += test-multi-netmodule-1-netmodule.cs test-multi-netmodule-2-dll1.cs test-multi-netmodule-3-dll2.cs test-multi-netmodule-4-exe.cs
+test-multi-netmodule:
+       @$(MCS) -t:module test-multi-netmodule-1-netmodule.cs
+       @$(MCS) -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library test-multi-netmodule-2-dll1.cs
+       @$(MCS) -addmodule:test-multi-netmodule-1-netmodule.netmodule -t:library test-multi-netmodule-3-dll2.cs
+       @$(MCS) -r:test-multi-netmodule-2-dll1.dll test-multi-netmodule-4-exe.cs
+       $(RUNTIME) test-multi-netmodule-4-exe.exe > test-multi-netmodule-4-exe.exe.stdout 2> test-multi-netmodule-4-exe.exe.stderr
+
 EXTRA_DIST += custom-attr-errors.cs custom-attr-errors-lib.cs
-test-cattr-type-load: TestDriver.dll custom-attr-errors.cs custom-attr-errors-lib.cs
+test-cattr-type-load: $(TEST_DRIVER_DEPEND) custom-attr-errors.cs custom-attr-errors-lib.cs
        $(MCS) -D:WITH_MEMBERS /t:library $(srcdir)/custom-attr-errors-lib.cs
        $(MCS) -r:TestDriver.dll -r:custom-attr-errors-lib.dll  $(srcdir)/custom-attr-errors.cs
        $(MCS) /t:library $(srcdir)/custom-attr-errors-lib.cs
@@ -955,152 +1099,191 @@ debug-casts:
        @$(MCS) -r:TestDriver.dll $(srcdir)/debug-casts.cs
        @$(RUNTIME) --debug=casts debug-casts.exe
 
-EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs     finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs
+EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs     finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-new-threads-dont-join-stw-2.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs sgen-bridge-gchandle.cs
 
 
-#those are actually configurations, eg plain_sgen-descriptors.exe
-#DISABLE_SGEN_TESTS =
+sgen-tests:
+       $(MAKE) sgen-regular-tests
+if !S390X
+       $(MAKE) sgen-toggleref-tests
+       $(MAKE) sgen-bridge-tests
+       $(MAKE) sgen-bridge2-tests
+endif
+
+SGEN_REGULAR_TESTS_MOBILE_STATIC_NOT_SUPPORTED =       \
+       sgen-domain-unload.exe  \
+       sgen-domain-unload-2.exe
 
-SGEN_TESTS =   \
+SGEN_REGULAR_TESTS_UNIVERSAL = \
        finalizer-wait.exe      \
        critical-finalizers.exe \
        sgen-descriptors.exe    \
        sgen-gshared-vtype.exe  \
-       sgen-domain-unload.exe  \
-       sgen-domain-unload-2.exe        \
        sgen-weakref-stress.exe \
        sgen-cementing-stress.exe       \
        sgen-case-23400.exe     \
        sgen-new-threads-dont-join-stw.exe      \
+       sgen-new-threads-dont-join-stw-2.exe    \
        gc-graystack-stress.exe \
        bug-17590.exe
 
-SGEN_CONFIGURATIONS =  \
-       "|plain"        \
-       "major=marksweep-conc|ms-conc"  \
-       "major=marksweep-conc,minor=split|ms-conc-split"        \
-       "minor=split|ms-split"  \
-       "minor=split,alloc-ratio=95|ms-split-95"        \
-       "|plain-clear-at-gc|clear-at-gc"        \
-       "major=marksweep-conc|ms-conc-clear-at-gc|clear-at-gc"  \
-       "minor=split|ms-split-clear-at-gc|clear-at-gc"
-
-
-#FIXME We should move to use SGEN_CONFIGURATIONS once sgen supports trailling commas or its argument list.
-SGEN_BRIDGE_CONFIGURATIONS =   \
-       "|plain"        \
-       ",major=marksweep-conc|ms-conc" \
-       "minor=split|ms-split"  \
-       "bridge-implementation=new|plain-new-bridge"    \
-       "bridge-implementation=new,major=marksweep-conc|ms-conc-new-bridge"     \
-       "bridge-implementation=new,minor=split|ms-split-new-bridge"     \
-       "bridge-implementation=tarjan|plain-tarjan-bridge"      \
-       "bridge-implementation=tarjan,minor=split|ms-split-tarjan-bridge"
-
-sgen-regular-tests: $(SGEN_TESTS)
-       @failed=0; \
-       passed=0; \
-       failed_tests="";\
-       if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \
-       for test in $+; do      \
-               echo "...$$test";       \
-               for conf in $(SGEN_CONFIGURATIONS); do  \
-                       name=`echo $$conf | cut -d\| -f 2`;     \
-                       params=`echo $$conf | cut -d\| -f 1`;   \
-                       debug_opt=`echo $$conf | cut -d\| -f 3`;        \
-                       test_name="$${test}|$${name}";  \
-                       if MONO_GC_PARAMS="$$params" MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="$$debug_opt" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS);     \
-                       then \
-                               passed=`expr $${passed} + 1`; \
-                       else \
-                               if [ $$? = 2 ]; then break; fi; \
-                               failed=`expr $${failed} + 1`; \
-                               failed_tests="$${failed_tests} $$test_name"; \
-                       fi \
-               done    \
-       done;   \
-       echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
-       if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
-         for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
-
-sgen-bridge-tests1: sgen-bridge.exe sgen-bridge-major-fragmentation.exe
-       @failed=0; \
-       passed=0; \
-       failed_tests="";\
-       if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \
-       for test in $+; do      \
-               echo "...$$test";       \
-               for conf in $(SGEN_BRIDGE_CONFIGURATIONS); do   \
-                       name=`echo $$conf | cut -d\| -f 2`;     \
-                       params=`echo $$conf | cut -d\| -f 1`;   \
-                       test_name="$${test}|$${name}";  \
-                       if MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="$${params}" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS); \
-                       then \
-                               passed=`expr $${passed} + 1`; \
-                       else \
-                               if [ $$? = 2 ]; then break; fi; \
-                               failed=`expr $${failed} + 1`; \
-                               failed_tests="$${failed_tests} $$test_name"; \
-                       fi \
-               done    \
-       done;   \
-       echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
-       if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
-         for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
-
-sgen-bridge-tests2: sgen-bridge-xref.exe
-       @failed=0; \
-       passed=0; \
-       failed_tests="";\
-       if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \
-       for test in $+; do      \
-               echo "...$$test";       \
-               for conf in $(SGEN_BRIDGE_CONFIGURATIONS); do   \
-                       name=`echo $$conf | cut -d\| -f 2`;     \
-                       params=`echo $$conf | cut -d\| -f 1`;   \
-                       test_name="$${test}|$${name}";  \
-                       if MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="$${params}" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS);        \
-                       then \
-                               passed=`expr $${passed} + 1`; \
-                       else \
-                               if [ $$? = 2 ]; then break; fi; \
-                               failed=`expr $${failed} + 1`; \
-                               failed_tests="$${failed_tests} $$test_name"; \
-                       fi \
-               done    \
-       done;   \
-       echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
-       if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
-         for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
-
-sgen-toggleref-tests: sgen-toggleref.exe
-       @failed=0; \
-       passed=0; \
-       failed_tests="";\
-       if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \
-       for test in $+; do      \
-               echo "...$$test";       \
-               for conf in $(SGEN_CONFIGURATIONS); do  \
-                       name=`echo $$conf | cut -d\| -f 2`;     \
-                       params=`echo $$conf | cut -d\| -f 1`;   \
-                       test_name="$${test}|$${name}";  \
-                       if MONO_GC_PARAMS="toggleref-test,$$params" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS);  \
-                       then \
-                               passed=`expr $${passed} + 1`; \
-                       else \
-                               if [ $$? = 2 ]; then break; fi; \
-                               failed=`expr $${failed} + 1`; \
-                               failed_tests="$${failed_tests} $$test_name"; \
-                       fi \
-               done    \
-       done;   \
-       echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
-       if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
-         for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
+if INSTALL_MOBILE_STATIC
+SGEN_REGULAR_TESTS= \
+       $(SGEN_REGULAR_TESTS_UNIVERSAL)
+else
+SGEN_REGULAR_TESTS= \
+       $(SGEN_REGULAR_TESTS_MOBILE_STATIC_NOT_SUPPORTED) \
+       $(SGEN_REGULAR_TESTS_UNIVERSAL)
+endif
 
-sgen-bridge-tests: sgen-bridge-tests1 sgen-bridge-tests2
+sgen-regular-tests: $(SGEN_REGULAR_TESTS)
+       $(MAKE) sgen-regular-tests-ms
+       $(MAKE) sgen-regular-tests-ms-conc
+       $(MAKE) sgen-regular-tests-ms-conc-split
+       $(MAKE) sgen-regular-tests-ms-split
+       $(MAKE) sgen-regular-tests-ms-conc-split-95
+       $(MAKE) sgen-regular-tests-ms-clear-at-gc
+       $(MAKE) sgen-regular-tests-ms-conc-clear-at-gc
+       $(MAKE) sgen-regular-tests-ms-conc-split-clear-at-gc
+
+sgen-regular-tests-ms: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc-split: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-split: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc-split-95: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc,minor=split,alloc-ratio=95" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="major=marksweep" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+sgen-regular-tests-ms-conc-split-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="major=marksweep-conc,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS)
+
+SGEN_TOGGLEREF_TESTS=  \
+       sgen-toggleref.exe
+
+sgen-toggleref-tests: $(SGEN_TOGGLEREF_TESTS)
+       $(MAKE) sgen-toggleref-tests-plain
+       $(MAKE) sgen-toggleref-tests-ms-conc
+       $(MAKE) sgen-toggleref-tests-ms-conc-split
+       $(MAKE) sgen-toggleref-tests-ms-split
+       $(MAKE) sgen-toggleref-tests-ms-split-95
+       $(MAKE) sgen-toggleref-tests-plain-clear-at-gc
+       $(MAKE) sgen-toggleref-tests-ms-conc-clear-at-gc
+       $(MAKE) sgen-toggleref-tests-ms-split-clear-at-gc
+
+sgen-toggleref-tests-plain: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-conc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-conc-split: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-split: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-split-95: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,minor=split,alloc-ratio=95" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-plain-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-conc-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+sgen-toggleref-tests-ms-split-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS)
+
+SGEN_BRIDGE_TESTS=     \
+       sgen-bridge.exe \
+       sgen-bridge-major-fragmentation.exe
+
+sgen-bridge-tests: $(SGEN_BRIDGE_TESTS)
+       $(MAKE) sgen-bridge-tests-plain
+       $(MAKE) sgen-bridge-tests-ms-conc
+       $(MAKE) sgen-bridge-tests-ms-split
+       $(MAKE) sgen-bridge-tests-plain-new-bridge
+       $(MAKE) sgen-bridge-tests-ms-conc-new-bridge
+       $(MAKE) sgen-bridge-tests-ms-split-new-bridge
+       $(MAKE) sgen-bridge-tests-plain-tarjan-bridge
+       $(MAKE) sgen-bridge-tests-ms-split-tarjan-bridge
+
+sgen-bridge-tests-plain: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-ms-conc: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-ms-split: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-plain-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-ms-conc-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-ms-split-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-plain-tarjan-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+sgen-bridge-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS)
+
+SGEN_BRIDGE2_TESTS=    \
+       sgen-bridge-xref.exe
+
+sgen-bridge2-tests: $(SGEN_BRIDGE2_TESTS)
+       $(MAKE) sgen-bridge2-tests-plain
+       $(MAKE) sgen-bridge2-tests-ms-conc
+       $(MAKE) sgen-bridge2-tests-ms-split
+       $(MAKE) sgen-bridge2-tests-plain-new-bridge
+       $(MAKE) sgen-bridge2-tests-ms-conc-new-bridge
+       $(MAKE) sgen-bridge2-tests-ms-split-new-bridge
+       $(MAKE) sgen-bridge2-tests-plain-tarjan-bridge
+       $(MAKE) sgen-bridge2-tests-ms-split-tarjan-bridge
+
+sgen-bridge2-tests-plain: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-ms-conc: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-ms-split: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-plain-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-ms-conc-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-ms-split-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-plain-tarjan-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+sgen-bridge2-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS)
+
+SGEN_BRIDGE3_TESTS=    \
+       sgen-bridge-gchandle.exe
+
+sgen-bridge3-tests: $(SGEN_BRIDGE3_TESTS)
+       $(MAKE) sgen-bridge3-tests-plain
+       $(MAKE) sgen-bridge3-tests-ms-conc
+       $(MAKE) sgen-bridge3-tests-ms-split
+       $(MAKE) sgen-bridge3-tests-plain-new-bridge
+       $(MAKE) sgen-bridge3-tests-ms-conc-new-bridge
+       $(MAKE) sgen-bridge3-tests-ms-split-new-bridge
+       $(MAKE) sgen-bridge3-tests-plain-tarjan-bridge
+       $(MAKE) sgen-bridge3-tests-ms-split-tarjan-bridge
+
+sgen-bridge3-tests-plain: $(SGEN_bridge3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-conc: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-plain-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-conc-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split-new-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-plain-tarjan-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
+sgen-bridge3-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE3_TESTS) test-runner.exe
+       MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=3Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) $(TEST_RUNNER) --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE3_TESTS)
 
-sgen-tests: sgen-regular-tests sgen-bridge-tests sgen-toggleref-tests
 
 AOT_CONFIGURATIONS=    \
        "|regular"      \
@@ -1143,19 +1326,23 @@ test-aot:
 
 # Generated tests for runtime invoke
 EXTRA_DIST += gen-runtime-invoke.cs
-runtime-invoke.gen.exe: TestDriver.dll gen-runtime-invoke.exe
+runtime-invoke.gen.exe: $(TEST_DRIVER_DEPEND) gen-runtime-invoke.exe
        $(RUNTIME) gen-runtime-invoke.exe > runtime-invoke.gen.cs
        $(MCS) -out:runtime-invoke.gen.exe -r:TestDriver.dll runtime-invoke.gen.cs
 
 EXTRA_DIST += make-imt-test.cs
-imt_big_iface_test.exe: TestDriver.dll make-imt-test.exe
+imt_big_iface_test.exe: $(TEST_DRIVER_DEPEND) make-imt-test.exe
        $(RUNTIME) make-imt-test.exe > imt_big_iface_test.cs
        $(MCS) -out:imt_big_iface_test.exe -r:TestDriver.dll imt_big_iface_test.cs
 
 EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs
-test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs
+test-inline-call-stack-library.dll: $(TEST_DRIVER_DEPEND) $(srcdir)/test-inline-call-stack-library.cs
        $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
-test-inline-call-stack.exe: TestDriver.dll test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
+
+test-inline-call-stack.exe: $(TEST_DRIVER_DEPEND) test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
        $(MCS) -r:TestDriver.dll -r:test-inline-call-stack-library.dll -out:test-inline-call-stack.exe $(srcdir)/test-inline-call-stack.cs
 
 EXTRA_DIST += unhandled-exception-base-configuration.config
@@ -1190,7 +1377,7 @@ test-unhandled-exception: unhandled-exception-test-runner.2.exe unhandled-except
 
 # We use 'test-support-files' to handle an ordering issue between the 'mono/' and 'runtime/' directories
 bug-80307.exe: $(srcdir)/bug-80307.cs
-       $(MCS) -r:System.Web -out:$@ $(srcdir)/bug-80307.cs
+       $(MCS) -r:System.Web.dll -out:$@ $(srcdir)/bug-80307.cs
        cd $(top_builddir)/runtime && $(MAKE) test-support-files
 
 EXTRA_DIST += bug-81673-interface.cs
@@ -1198,12 +1385,18 @@ bug-81673.exe bug-81673-interface.dll: $(srcdir)/bug-81673.cs $(srcdir)/bug-8167
        $(MCS) -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
        $(MCS) -out:bug-81673.exe -r:bug-81673-interface.dll $(srcdir)/bug-81673.cs
        $(MCS) -define:WITH_STOP -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 
 EXTRA_DIST += bug-36848-a.cs
 bug-36848.exe bug-36848-a.dll: $(srcdir)/bug-36848.cs $(srcdir)/bug-36848-a.cs
        $(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs
        $(MCS) -r:bug-36848-a.dll -out:bug-36848.exe $(srcdir)/bug-36848.cs
        $(MCS) -target:library -out:bug-36848-a.dll $(srcdir)/bug-36848-a.cs /define:WITH_STOP
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 
 EXTRA_DIST += bug-81691-a.cs bug-81691-b.cs
 bug-81691.exe bug-81691-b.dll: $(srcdir)/bug-81691.cs $(srcdir)/bug-81691-a.cs $(srcdir)/bug-81691-b.cs
@@ -1216,24 +1409,37 @@ bug-81691.exe: bug-81691-b.dll
 EXTRA_DIST += bug-81466-lib.il
 bug-81466-lib.dll: bug-81466-lib.il
        $(ILASM) /dll /output:bug-81466-lib.dll $(srcdir)/bug-81466-lib.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 bug-81466.exe: bug-81466.il bug-81466-lib.dll
        $(ILASM) /exe /output:bug-81466.exe $(srcdir)/bug-81466.il
 
 EXTRA_DIST += bug-324535-il.il
 bug-324535-il.dll : bug-324535-il.il
        $(ILASM) /dll /output:bug-324535-il.dll $(srcdir)/bug-324535-il.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 bug-324535.exe : bug-324535.cs bug-324535-il.dll
        $(MCS) -r:bug-324535-il.dll -out:bug-324535.exe $(srcdir)/bug-324535.cs
 
 EXTRA_DIST += custom-modifiers.2.cs custom-modifiers-lib.il
 custom-modifiers-lib.dll: custom-modifiers-lib.il
        $(ILASM) /dll /output:custom-modifiers-lib.dll $(srcdir)/custom-modifiers-lib.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 custom-modifiers.2.exe: custom-modifiers.2.cs custom-modifiers-lib.dll
        $(MCS) -r:custom-modifiers-lib.dll -out:custom-modifiers.2.exe $(srcdir)/custom-modifiers.2.cs
 
 EXTRA_DIST += bug-382986-lib.cs
 bug-382986-lib.dll: bug-382986-lib.cs
        $(MCS) -target:library -out:$@ $(srcdir)/bug-382986-lib.cs
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
+
 bug-382986.exe: bug-382986.cs bug-382986-lib.dll
        $(MCS) -out:$@ -r:bug-382986-lib.dll $(srcdir)/bug-382986.cs
 
@@ -1243,7 +1449,7 @@ bug-17537-helper.exe: bug-17537-helper.cs
        chmod -x $@
 
 bug-17537.exe: bug-17537.cs bug-17537-helper.exe
-       $(MCS) -out:$@ $(srcdir)/bug-17537.cs
+       $(MCS) -r:System.dll -out:$@ $(srcdir)/bug-17537.cs
 
 EXTRA_DIST += coreclr-security.cs
 
@@ -1257,10 +1463,16 @@ test-coreclr-security : coreclr-security.exe
 EXTRA_DIST += generic-unboxing.2.il
 generic-unboxing.2.dll : generic-unboxing.2.il
        $(ILASM) /dll /output:generic-unboxing.2.dll $(srcdir)/generic-unboxing.2.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 
 EXTRA_DIST += generic-boxing.2.il
 generic-boxing.2.dll : generic-boxing.2.il generic-unboxing.2.dll
        $(ILASM) /dll /output:generic-boxing.2.dll $(srcdir)/generic-boxing.2.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 
 EXTRA_DIST += generic-unbox.2.cs
 generic-unbox.2.exe : generic-unbox.2.cs generic-unboxing.2.dll
@@ -1273,18 +1485,24 @@ generic-box.2.exe : generic-box.2.cs generic-unboxing.2.dll generic-boxing.2.dll
 EXTRA_DIST += generic-delegate2.2.cs generic-delegate2-lib.2.il
 generic-delegate2-lib.2.dll : generic-delegate2-lib.2.il
        $(ILASM) /dll /output:$@ $(srcdir)/generic-delegate2-lib.2.il
+if INSTALL_MOBILE_STATIC
+       $(RUNTIME) $(AOT_BUILD_FLAGS) $@
+endif
 generic-delegate2.2.exe : generic-delegate2.2.cs generic-delegate2-lib.2.dll
        $(MCS) -r:generic-delegate2-lib.2.dll -out:$@ $(srcdir)/generic-delegate2.2.cs
 
 bug-3903.exe: bug-3903.cs
-       $(MCS) -sdk:2 $(srcdir)/bug-3903.cs -out:$@
+       $(MCS_NO_LIB) -lib:$(srcdir)/../../external/binary-reference-assemblies/v2.0/ $(srcdir)/bug-3903.cs -r:System.Core.dll -out:$@
 
 gshared: test-generic-sharing
 
 gshared-aot:
        @$(MAKE) AOT=1 gshared
 
-GSHARED_TESTS = \
+GSHARED_TESTS_MOBILE_STATIC_NOT_SUPPORTED = \
+               generic-type-builder.2.exe
+
+GSHARED_TESTS_UNIVERSAL = \
                generics-sharing.2.exe shared-generic-methods.2.exe     \
                shared-generic-synchronized.2.exe generic-initobj.2.exe         \
                generics-sharing-other-exc.2.exe generic-box.2.exe              \
@@ -1300,7 +1518,7 @@ GSHARED_TESTS = \
                generic-exceptions.2.exe generic-delegate2.2.exe                \
                generic-virtual2.2.exe generic-valuetype-interface.2.exe        \
                generic-valuetype-newobj.2.exe generic-valuetype-newobj2.2.exe  \
-               generic-getgenericarguments.2.exe generic-type-builder.2.exe    \
+               generic-getgenericarguments.2.exe       \
                generic-synchronized.2.exe generic-delegate-ctor.2.exe          \
                generic-constrained.2.exe bug-431413.2.exe                      \
                generic-virtual-invoke.2.exe generic-typedef.2.exe              \
@@ -1312,6 +1530,15 @@ GSHARED_TESTS = \
                generic-type-load-exception.2.exe bug-616463.exe        \
                bug-1147.exe
 
+if INSTALL_MOBILE_STATIC
+GSHARED_TESTS= \
+       $(GSHARED_TESTS_UNIVERSAL)
+else
+GSHARED_TESTS= \
+       $(GSHARED_TESTS_MOBILE_STATIC_NOT_SUPPORTED) \
+       $(GSHARED_TESTS_UNIVERSAL)
+endif
+
 test-generic-sharing-normal: $(GSHARED_TESTS)
        @for fn in $+ ; do      \
                echo "Testing $$fn ...";        \
@@ -1323,7 +1550,7 @@ test-generic-sharing-normal: $(GSHARED_TESTS)
        done
 
 test-generic-sharing-managed: test-runner.exe $(GSHARED_TESTS)
-       @$(RUNTIME) ./test-runner.exe -j a --testsuite-name "gshared" --opt-sets "gshared gshared,shared gshared,-inline gshared,-inline,shared" $(GSHARED_TESTS)
+       @$(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name "gshared" --disabled "$(DISABLED_TESTS)" --opt-sets "gshared gshared,shared gshared,-inline gshared,-inline,shared" $(GSHARED_TESTS)
 
 if NACL_CODEGEN
 test-generic-sharing:
@@ -1342,7 +1569,7 @@ test-async-exceptions : async-exceptions.exe
 EXTRA_DIST += modules.cs modules-m1.cs
 modules-m1.netmodule: modules-m1.cs
        $(MCS) -out:$@ /target:module $(srcdir)/modules-m1.cs
-modules.exe: modules.cs modules-m1.netmodule TestDriver.dll
+modules.exe: modules.cs modules-m1.netmodule $(TEST_DRIVER_DEPEND) 
        $(MCS) -out:$@ /addmodule:modules-m1.netmodule -r:TestDriver.dll $(srcdir)/modules.cs
 
 # Useful if mono is compiled with --enable-shared=no
@@ -1379,25 +1606,35 @@ test-oom: $(OOM_TESTS)
 if HOST_WIN32
 test-unhandled-exception-2:
 else
-test-unhandled-exception-2: test-unhandled-exception-2-1 test-unhandled-exception-2-2 test-unhandled-exception-2-3 test-unhandled-exception-2-4        \
-                test-unhandled-exception-2-5 test-unhandled-exception-2-6 test-unhandled-exception-2-7 test-unhandled-exception-2-8
-
-test-unhandled-exception-2-1: unhandled-exception-1.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 1 $<
-test-unhandled-exception-2-2: unhandled-exception-2.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-3: unhandled-exception-3.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-4: unhandled-exception-4.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-5: unhandled-exception-5.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 255 $<
-test-unhandled-exception-2-6: unhandled-exception-6.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-7: unhandled-exception-7.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 0 $<
-test-unhandled-exception-2-8: unhandled-exception-8.exe test-runner.exe
-       @$(RUNTIME) ./test-runner.exe --testsuite-name $@ --expected-exit-code 3 $<
+
+# tests that expect a 1 exit code
+UNHANDLED_EXCEPTION_1_TESTS =  \
+       unhandled-exception-1.exe
+
+# tests that expect a 255 exit code
+UNHANDLED_EXCEPTION_255_TESTS =        \
+       unhandled-exception-2.exe       \
+       unhandled-exception-3.exe       \
+       unhandled-exception-4.exe       \
+       unhandled-exception-5.exe       \
+       unhandled-exception-6.exe       \
+       unhandled-exception-7.exe
+
+test-unhandled-exception-2: $(UNHANDLED_EXCEPTION_1_TESTS) $(UNHANDLED_EXCEPTION_255_TESTS)
+       $(MAKE) test-unhandled-exception-2-1-with-managed-handler
+       $(MAKE) test-unhandled-exception-2-1-without-managed-handler
+       $(MAKE) test-unhandled-exception-2-255-with-managed-handler
+       $(MAKE) test-unhandled-exception-2-255-without-managed-handler
+
+test-unhandled-exception-2-1-with-managed-handler: $(UNHANDLED_EXCEPTION_1_TESTS) test-runner.exe
+       $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --expected-exit-code 1 $(UNHANDLED_EXCEPTION_1_TESTS)
+test-unhandled-exception-2-1-without-managed-handler: $(UNHANDLED_EXCEPTION_1_TESTS) test-runner.exe
+       TEST_UNHANDLED_EXCEPTION_HANDLER=1 $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --expected-exit-code 1 $(UNHANDLED_EXCEPTION_1_TESTS)
+test-unhandled-exception-2-255-with-managed-handler: $(UNHANDLED_EXCEPTION_255_TESTS) test-runner.exe
+       $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --expected-exit-code 255 $(UNHANDLED_EXCEPTION_255_TESTS)
+test-unhandled-exception-2-255-without-managed-handler: $(UNHANDLED_EXCEPTION_255_TESTS) test-runner.exe
+       TEST_UNHANDLED_EXCEPTION_HANDLER=1 $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) -j a --testsuite-name $@ --disabled "$(DISABLED_TESTS)" --expected-exit-code 255 $(UNHANDLED_EXCEPTION_255_TESTS)
+
 endif
 
 EXTRA_DIST += appdomain-loader.cs appdomain-tester.cs
@@ -1414,6 +1651,15 @@ test-console-output: console-output.exe
        @diff -w console-output.exe.stdout $(srcdir)/console-output.exe.stdout.expected \
                && diff -w console-output.exe.stderr $(srcdir)/console-output.exe.stderr.expected
 
+PROCESS_STRESS_TESTS=  \
+               process-stress-1.exe    \
+               process-stress-2.exe    \
+               process-stress-3.exe    \
+               process-leak.exe
+
+test-process-stress: $(PROCESS_STRESS_TESTS) test-runner.exe
+       $(RUNTIME) $(TEST_RUNNER) $(TEST_RUNNER_ARGS) --testsuite-name $@ --timeout 600 $(PROCESS_STRESS_TESTS)
+
 coreclr-gcstress:
        $(MAKE) -C $(mono_build_root)/acceptance-tests coreclr-gcstress