Compare commits

...
4 changed files with 76 additions and 2 deletions

No files matched your search

+4 -1
View File
@@ -19,11 +19,14 @@ TEST_HELPERS_SOURCES = \
../test-helpers/NetworkHelpers.cs \
Test/TypeLoadClass.cs
test-local: dtest-app.exe dtest-excfilter.exe
test-local: dtest-app.exe dtest-excfilter.exe appdomain-client.exe
dtest-app.exe: Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -out:$@ -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- Test/dtest-app.cs $(TEST_HELPERS_SOURCES)
appdomain-client.exe: ../../../mono/tests/appdomain-client.cs
$(CSCOMPILE) -r:$(topdir)/class/lib/$(PROFILE)/System.Core.dll -r:$(topdir)/class/lib/$(PROFILE)/System.dll -out:appdomain-client.exe -unsafe $(PLATFORM_DEBUG_FLAGS) -optimize- ../../../mono/tests/appdomain-client.cs
dtest-excfilter.exe: Test/dtest-excfilter.il
MONO_PATH=$(topdir)/class/lib/$(PROFILE) $(INTERNAL_ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il
@@ -21,7 +21,7 @@ namespace Mono.Debugger.Soft
}
}
internal long Id {
public long Id {
get {
return id;
}
@@ -292,6 +292,30 @@ public class Tests : TestsBase, ITest2
evt.WaitOne ();
}
static void LoadDomain()
{
while(true) {
var setup = new AppDomainSetup();
setup.ApplicationBase = ".";
AppDomain newDomain = AppDomain.CreateDomain("multi_domain_load_domain", null, setup);
string[] args = { "1", "2", "3" };
newDomain.ExecuteAssembly("appdomain-client.exe", null, args);
AppDomain.Unload(newDomain);
}
}
static void multi_domain_load()
{
var threads = new Thread[10];
for (int i=0;i<threads.Length;i++) {
threads[i] = new Thread(new ThreadStart(LoadDomain));
threads[i].Start();
}
}
public static int Main (String[] args) {
tls_i = 42;
@@ -323,6 +347,7 @@ public class Tests : TestsBase, ITest2
return 0;
}
assembly_load ();
multi_domain_load();
breakpoints ();
single_stepping ();
arguments ();
@@ -2497,6 +2497,52 @@ public class DebuggerTests
vm = null;
}
[Test]
public void MultiDomainLoad () {
Event e = run_until ("multi_domain_load");
vm.EnableEvents (EventType.AppDomainCreate, EventType.AppDomainUnload, EventType.AssemblyUnload, EventType.AssemblyLoad);
vm.Resume ();
var listOfAllAssembliesLoaded=new List<AssemblyMirror>();
bool exitLoop = false;
while (!exitLoop) {
e = GetNextEvent ();
switch(e)
{
case AssemblyLoadEvent al:
Console.WriteLine($"({al.Assembly.Id})Assembly loaded {al.Assembly.Location} in {al.Assembly.Domain.FriendlyName} at thread:{e.Thread.Name}");
listOfAllAssembliesLoaded.Add(((AssemblyLoadEvent)e).Assembly);
vm.Resume();
break;
case AssemblyUnloadEvent au:
Console.WriteLine($"({au.Assembly.Id})Assembly unloaded {au.Assembly.Location} in {au.Assembly.Domain.FriendlyName} at thread:{e.Thread.Name}");
vm.Resume();
break;
case AppDomainCreateEvent dc:
Console.WriteLine($"Domain created {dc.Domain.FriendlyName} at thread:{e.Thread.Name}");
vm.Resume();
break;
case AppDomainUnloadEvent du:
Console.WriteLine($"Domain unloaded {du.Domain.FriendlyName} at thread:{e.Thread.Name}");
vm.Resume();
break;
case VMDeathEvent vmd:
exitLoop=true;
break;
default:
Console.WriteLine(e.GetType().FullName);
vm.Resume();
break;
}
}
Assert.AreEqual(
1/*Mono.Security.dll which loads before AppDomains are created*/+
2/*appdomain-client.exe which loads twice for 2 domains, see dtest-app.cs*/+
1/*System.Core.dll which loads at end*/
,listOfAllAssembliesLoaded.Count);
}
[Test]
public void AssemblyLoad () {
Event e = run_until ("assembly_load");