Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kliger <aleksey@xamarin.com>2016-07-26 00:25:33 +0300
committerAleksey Kliger <aleksey@xamarin.com>2016-07-26 02:01:00 +0300
commit083b5368f410aa3ea3b6b077d207a723ed4d5a38 (patch)
tree61df397e91ac29acf6e89b05ec514071823661d0 /mcs/class/Mono.Debugger.Soft
parent398320339ca70efdc3c92349a985e73d5a9013fd (diff)
[debugger-agent] Regression test for #42625
Check that we can suspend I/O blocked threadpool workers in coop GC mode.
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft')
-rw-r--r--mcs/class/Mono.Debugger.Soft/Makefile7
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs47
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest.cs16
3 files changed, 68 insertions, 2 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Makefile b/mcs/class/Mono.Debugger.Soft/Makefile
index d92fb61f8a9..1f20c1f89c6 100644
--- a/mcs/class/Mono.Debugger.Soft/Makefile
+++ b/mcs/class/Mono.Debugger.Soft/Makefile
@@ -15,10 +15,13 @@ VALID_TEST_PROFILE := $(filter net_4_x, $(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_HELPERS_SOURCES = \
+ ../test-helpers/NetworkHelpers.cs
+
test-local: dtest-app.exe dtest-excfilter.exe
-dtest-app.exe: Test/dtest-app.cs
- $(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
+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)
dtest-excfilter.exe: Test/dtest-excfilter.il
MONO_PATH=$(topdir)/class/lib/$(PROFILE) $(INTERNAL_ILASM) -out:$@ /exe /debug Test/dtest-excfilter.il
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
index 4b9d569b1ad..6587c37c0b5 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs
@@ -9,8 +9,11 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
using System.Threading;
+using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
+using System.Net.Sockets;
+using MonoTests.Helpers;
public class TestsBase
{
@@ -311,6 +314,10 @@ public class Tests : TestsBase, ITest2
wait_one ();
return 0;
}
+ if (args.Length >0 && args [0] == "threadpool-io") {
+ threadpool_io ();
+ return 0;
+ }
breakpoints ();
single_stepping ();
arguments ();
@@ -1541,6 +1548,46 @@ public class Tests : TestsBase, ITest2
public override string virtual_method () {
return "V2";
}
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static void threadpool_bp () { }
+
+ [MethodImplAttribute (MethodImplOptions.NoInlining)]
+ public static void threadpool_io () {
+ // Start a threadpool task that blocks on I/O.
+ // Regression test for #42625
+ const int nbytes = 16;
+ var bsOut = new byte[nbytes];
+ for (int i = 0; i < nbytes; i++) {
+ bsOut[i] = (byte)i;
+ }
+ var endPoint = NetworkHelpers.LocalEphemeralEndPoint ();
+ var l = new TcpListener (endPoint);
+ l.Start ();
+ Task<byte[]> t = Task.Run (async () => {
+ var c = new TcpClient ();
+ await c.ConnectAsync (endPoint.Address, endPoint.Port);
+ var streamIn = c.GetStream ();
+ var bs = new byte[nbytes];
+ int nread = 0;
+ while (nread < nbytes) {
+ nread += await streamIn.ReadAsync (bs, nread, nbytes);
+ }
+ streamIn.Close ();
+ return bs;
+ });
+ var s = l.AcceptTcpClient ();
+ l.Stop ();
+ // write bytes in two groups so that the task blocks on the ReadAsync
+ var streamOut = s.GetStream ();
+ var nbytesFirst = nbytes / 2;
+ var nbytesRest = nbytes - nbytesFirst;
+ streamOut.Write (bsOut, 0, nbytesFirst);
+ threadpool_bp ();
+ streamOut.Write (bsOut, nbytesFirst, nbytesRest);
+ streamOut.Close ();
+ var bsIn = t.Result;
+ }
}
class TypeLoadClass {
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
index c0af12cb38a..88ed411da35 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
@@ -4035,6 +4035,22 @@ public class DebuggerTests
// Make sure we are still in the cctor
Assert.AreEqual (".cctor", e.Thread.GetFrames ()[0].Location.Method.Name);
}
+
+ [Test]
+ public void ThreadpoolIOsinglestep () {
+ TearDown ();
+ Start ("dtest-app.exe", "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.
+ Event e = run_until ("threadpool_io");
+ // run until we sent the task half the bytes it
+ // expects, so that it blocks waiting for the rest.
+ e = run_until ("threadpool_bp");
+ var req = create_step (e);
+ e = step_out (); // leave threadpool_bp
+ e = step_out (); // leave threadpool_io
+ }
}
}