diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-10-15 15:12:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-15 15:12:19 +0300 |
commit | 8d1dd6aa65a558fe87c5e1870c25750ff104f5ea (patch) | |
tree | 9dba232918a2dcead6c0cfcb8d58394b5dc66fd3 /mcs/class/Mono.Debugger.Soft | |
parent | fa79aa7e8b190936b77cd00fc1c3ad9b5d358783 (diff) |
Fix Mono.Debugger.Soft to use test exe's from different directory (#11033)
And make it work for the monodroid_tools profile.
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft')
-rw-r--r-- | mcs/class/Mono.Debugger.Soft/Makefile | 43 | ||||
-rw-r--r-- | mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 51 |
2 files changed, 59 insertions, 35 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Makefile b/mcs/class/Mono.Debugger.Soft/Makefile index 42fb0976d0e..7c2203aaeb0 100644 --- a/mcs/class/Mono.Debugger.Soft/Makefile +++ b/mcs/class/Mono.Debugger.Soft/Makefile @@ -8,18 +8,24 @@ LIB_REFS = System Mono.Cecil System.Core LIB_MCS_FLAGS = /unsafe -D:MONO_DATACONVERTER_STATIC_METHODS /publicsign KEYFILE = $(LIBRARY_SNK) -TEST_MCS_FLAGS = +# special case monodroid_tools since it doesn't contain mscorlib etc but we need to compile the tests against something +# and want dtest-app.exe etc to end up in the monodroid profile +ifeq ($(PROFILE), monodroid_tools) +TEST_MCS_FLAGS = -d:MONODROID_TEST +DEFAULT_REFERENCES = +LIB_REFS += mscorlib +dtest_profile = monodroid +TEST_LIB_REFS = Mono.Cecil ../$(dtest_profile)/mscorlib ../$(dtest_profile)/System ../$(dtest_profile)/System.Core +else TEST_LIB_REFS = Mono.Cecil System System.Core +dtest_profile = $(PROFILE) +endif -VALID_TEST_PROFILE := $(filter net_4_x, $(PROFILE)) +VALID_TEST_PROFILE := $(filter net_4_x monodroid_tools, $(PROFILE)) -# The test exe is not profile specific, and compiling a 2.0 will make the 4.5 tests fail ifdef VALID_TEST_PROFILE -test-local: dtest-app.exe dtest-excfilter.exe - -dtest-excfilter.exe: Test/dtest-excfilter.il - $(ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il +test-local: build-dtest else @@ -28,21 +34,30 @@ check: endif +test_output_dir=$(topdir)/class/lib/$(dtest_profile)/tests + +$(test_output_dir): + mkdir -p $@ + +build-dtest: $(test_output_dir)/dtest-app.exe $(test_output_dir)/dtest-excfilter.exe + +$(test_output_dir)/dtest-excfilter.exe: Test/dtest-excfilter.il | $(test_output_dir) + $(ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il + +$(test_output_dir)/dtest-app.exe: Test/dtest-app.cs $(TEST_HELPERS_SOURCES) | $(test_output_dir) + $(CSCOMPILE) -r:$(topdir)/class/lib/$(dtest_profile)/mscorlib.dll -r:$(topdir)/class/lib/$(dtest_profile)/System.Core.dll -r:$(topdir)/class/lib/$(dtest_profile)/System.dll -sourcelink:Test/sourcelink.json -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES) + TEST_HELPERS_SOURCES = \ ../test-helpers/NetworkHelpers.cs \ Test/TypeLoadClass.cs -dtest-app.exe: Test/dtest-app.cs $(TEST_HELPERS_SOURCES) - $(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/mscorlib.dll -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -sourcelink:Test/sourcelink.json -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES) - -CLEAN_FILES = dtest-app.exe dtest-app.exe.mdb dtest-app.pdb dtest-excfilter.exe dtest-excfilter.exe.mdb dtest-excfilter.pdb - EXTRA_DISTFILES = \ Test/dtest-app.cs \ Test/dtest.cs \ Test/dtest-excfilter.il \ - Test/sourcelink.json + Test/sourcelink.json \ + $(TEST_HELPERS_SOURCES) -#NO_TEST = yes +CLEAN_FILES = $(addprefix $(test_output_dir)/, dtest-app.exe dtest-app.exe.mdb dtest-app.pdb dtest-excfilter.exe dtest-excfilter.exe.mdb dtest-excfilter.pdb) include ../../build/library.make diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index c0109315a85..b5a544a6f7e 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -47,6 +47,15 @@ public class DebuggerTests public static string runtime = Environment.GetEnvironmentVariable ("DBG_RUNTIME"); public static string runtime_args = Environment.GetEnvironmentVariable ("DBG_RUNTIME_ARGS"); public static string agent_args = Environment.GetEnvironmentVariable ("DBG_AGENT_ARGS"); +#if MONODROID_TEST + // AssemblyInfo.Location doesn't work on Android, we expect test .exe's to be in the working dir + public static string this_assembly_path = ""; +#else + // expect test .exe's to be next to this assembly + public static string this_assembly_path = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location); +#endif + + public static string dtest_app_path = Path.Combine (this_assembly_path, "dtest-app.exe"); // Not currently used, but can be useful when debugging individual tests. void StackTraceDump (Event e) @@ -74,16 +83,16 @@ public class DebuggerTests if (runtime != null) { pi.FileName = runtime; - } else if (Path.DirectorySeparatorChar == '\\') { + } else { string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName; if (processExe != null) { string fileName = Path.GetFileName (processExe); - if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe")) + if (fileName.StartsWith ("mono")) pi.FileName = processExe; } } if (string.IsNullOrEmpty (pi.FileName)) - pi.FileName = "mono"; + throw new ArgumentException ("Couldn't find mono runtime."); pi.Arguments = String.Join (" ", args); if (runtime_args != null) pi.Arguments = runtime_args + " " + pi.Arguments; @@ -362,7 +371,7 @@ public class DebuggerTests [SetUp] public void SetUp () { ThreadMirror.NativeTransitions = false; - Start (new string [] { "dtest-app.exe" }); + Start (new string [] { dtest_app_path }); } [TearDown] @@ -494,7 +503,7 @@ public class DebuggerTests public void IsDynamicAssembly () { vm.Detach (); - Start (new string[] {"dtest-app.exe", "ref-emit-test"}); + Start (new string[] { dtest_app_path, "ref-emit-test"}); run_until ("ref_emit_call"); var assemblyMirrors = entry_point.DeclaringType.Assembly.Domain.GetAssemblies (); @@ -672,7 +681,7 @@ public class DebuggerTests public void ClassLocalReflection () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "local-reflect" }); + Start (new string [] { dtest_app_path, "local-reflect" }); MethodMirror m = entry_point.DeclaringType.Assembly.GetType ("LocalReflectClass").GetMethod ("RunMe"); @@ -2575,7 +2584,7 @@ public class DebuggerTests public void Suspend () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "suspend-test" }); + Start (new string [] { dtest_app_path, "suspend-test" }); Event e = run_until ("suspend"); @@ -3054,7 +3063,7 @@ public class DebuggerTests public void InvokeSingleThreaded () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "invoke-single-threaded" }); + Start (new string [] { dtest_app_path, "invoke-single-threaded" }); Event e = run_until ("invoke_single_threaded_2"); @@ -3135,7 +3144,7 @@ public class DebuggerTests public void InvokeAbort () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "invoke-abort" }); + Start (new string [] { dtest_app_path, "invoke-abort" }); Event e = run_until ("invoke_abort"); @@ -3468,7 +3477,7 @@ public class DebuggerTests public void ExceptionFilter2 () { vm.Detach (); - Start (new string [] { "dtest-excfilter.exe" }); + Start (new string [] { Path.Combine (this_assembly_path, "dtest-excfilter.exe") }); MethodMirror filter_method = entry_point.DeclaringType.GetMethod ("Filter"); Assert.IsNotNull (filter_method); @@ -3568,7 +3577,7 @@ public class DebuggerTests public void MemberInOtherDomain () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "domain-test" }); + Start (new string [] { dtest_app_path, "domain-test" }); vm.EnableEvents (EventType.AppDomainCreate, EventType.AppDomainUnload, EventType.AssemblyUnload); @@ -3584,7 +3593,7 @@ public class DebuggerTests public void Domains () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "domain-test" }); + Start (new string [] { dtest_app_path, "domain-test" }); vm.EnableEvents (EventType.AppDomainCreate, EventType.AppDomainUnload, EventType.AssemblyUnload); @@ -3707,7 +3716,7 @@ public class DebuggerTests public void RefEmit () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "ref-emit-test" }); + Start (new string [] { dtest_app_path, "ref-emit-test" }); Event e = run_until ("ref_emit_call"); @@ -3743,7 +3752,7 @@ public class DebuggerTests // Check that stack traces can be produced for threads in native code vm.Detach (); - Start (new string [] { "dtest-app.exe", "frames-in-native" }); + Start (new string [] { dtest_app_path, "frames-in-native" }); var e = run_until ("frames_in_native"); @@ -4117,7 +4126,7 @@ public class DebuggerTests public void UnhandledException () { vm.Exit (0); - Start (new string [] { "dtest-app.exe", "unhandled-exception" }); + Start (new string [] { dtest_app_path, "unhandled-exception" }); var req = vm.CreateExceptionRequest (null, false, true); req.Enable (); @@ -4136,7 +4145,7 @@ public class DebuggerTests public void UnhandledException_2 () { vm.Exit (0); - Start (new string [] { "dtest-app.exe", "unhandled-exception-endinvoke" }); + Start (new string [] { dtest_app_path, "unhandled-exception-endinvoke" }); var req = vm.CreateExceptionRequest (null, false, true); req.Enable (); @@ -4160,7 +4169,7 @@ public class DebuggerTests vm.Detach (); // Exceptions caught in non-user code are treated as unhandled - Start (new string [] { "dtest-app.exe", "unhandled-exception-user" }); + Start (new string [] { dtest_app_path, "unhandled-exception-user" }); var req = vm.CreateExceptionRequest (null, false, true); req.AssemblyFilter = new List<AssemblyMirror> () { entry_point.DeclaringType.Assembly }; @@ -4231,7 +4240,7 @@ public class DebuggerTests [Test] public void InspectThreadSuspenedOnWaitOne () { TearDown (); - Start (true, "dtest-app.exe", "wait-one" ); + Start (true, dtest_app_path, "wait-one" ); ThreadMirror.NativeTransitions = true; @@ -4403,7 +4412,7 @@ public class DebuggerTests [Test] public void ThreadpoolIOsinglestep () { TearDown (); - Start ("dtest-app.exe", "threadpool-io"); + Start (dtest_app_path, "threadpool-io"); // This is a regression test for #42625. It tests the // interaction (particularly in coop GC) of the // threadpool I/O mechanism and the soft debugger. @@ -4420,7 +4429,7 @@ public class DebuggerTests [Category("NotWorking")] // flaky, see https://github.com/mono/mono/issues/6997 public void StepOutAsync () { vm.Detach (); - Start (new string [] { "dtest-app.exe", "step-out-void-async" }); + Start (new string [] { dtest_app_path, "step-out-void-async" }); var e = run_until ("step_out_void_async_2"); create_step (e); var e2 = step_out (); @@ -4470,7 +4479,7 @@ public class DebuggerTests vm.Exit (0); // Launch the app using server=y,suspend=n - var pi = CreateStartInfo (new string[] { "--debugger-agent=transport=dt_socket,address=127.0.0.1:10000,server=y,suspend=n", "dtest-app.exe", "attach" }); + var pi = CreateStartInfo (new string[] { "--debugger-agent=transport=dt_socket,address=127.0.0.1:10000,server=y,suspend=n", dtest_app_path, "attach" }); var process = Diag.Process.Start (pi); // Wait for the app to reach the Sleep () in attach (). |