NUnitMoonHelper.cs
-../../test-helpers/NetworkHelpers.cs
FeatureBased/Features.Client/AsyncCallTesterProxy.cs
FeatureBased/Features.Client/AsyncPatternServer.cs
FeatureBased/Features.Client/DataContractTesterProxy.cs
using System.Security.Permissions;
using System.Collections.Generic;
using System.Threading;
+using MonoTests.Helpers;
namespace MonoTests.System.Runtime.CompilerServices {
var cwt = new ConditionalWeakTable <object,object> ();
List<object> keepAlive = null;
List<WeakReference> keys = null;
- Thread t = new Thread (delegate () {
+ FinalizerHelpers.PerformNoPinAction (delegate () {
FillStuff (cwt, out keepAlive, out keys);
});
- t.Start ();
- t.Join ();
GC.Collect ();
cwt.Add (b, new object ());
List<WeakReference> res = null;
- ThreadStart dele = () => { res = FillWithNetwork (cwt); };
- var th = new Thread(dele);
- th.Start ();
- th.Join ();
+ FinalizerHelpers.PerformNoPinAction (() => { res = FillWithNetwork (cwt); });
GC.Collect ();
GC.Collect ();
List<WeakReference> res, res2;
res = res2 = null;
- ThreadStart dele = () => {
+ FinalizerHelpers.PerformNoPinAction (() => {
res = FillWithNetwork2 (cwt);
ForcePromotion ();
k = FillReachable (cwt);
res2 = FillWithNetwork2 (cwt);
- };
-
- var th = new Thread(dele);
- th.Start ();
- th.Join ();
+ });
GC.Collect ();
Assert.Ignore ("Not working on Boehm.");
lock (_lock1) {
var cwt = new ConditionalWeakTable <object,object> ();
- ThreadStart dele = () => { FillWithFinalizable (cwt); };
- var th = new Thread(dele);
- th.Start ();
- th.Join ();
+ FinalizerHelpers.PerformNoPinAction (() => { FillWithFinalizable (cwt); });
GC.Collect ();
GC.Collect ();
System/AggregateExceptionTests.cs
System.Threading/ThreadLocalTests.cs
System.Threading/SpinLockTests.cs
-
+../../test-helpers/TestHelpers.cs
--- /dev/null
+../../../mono/mini/TestHelpers.cs
\ No newline at end of file
%.exe: %.il
$(ILASM) -output=$@ $<
-TestDriver.dll: $(srcdir)/TestDriver.cs
- $(MCS) -out:$@ -target:library $<
+TestDriver.dll: $(srcdir)/TestDriver.cs $(srcdir)/TestHelpers.cs
+ $(MCS) -out:$@ -target:library $^
generics-variant-types.dll: generics-variant-types.il
$(ILASM) -dll -output=$@ $<
CLEANFILES= $(BUILT_SOURCES) *.exe *.dll
EXTRA_DIST = TestDriver.cs \
+ TestHelpers.cs \
genmdesc.pl \
emitnunit.pl \
$(test_sources) \
--- /dev/null
+using System;
+using System.Threading;
+
+namespace MonoTests.Helpers {
+
+ public static class FinalizerHelpers {
+ private static IntPtr aptr;
+
+ private static unsafe void NoPinActionHelper (int depth, Action act)
+ {
+ // Avoid tail calls
+ int* values = stackalloc int [20];
+ aptr = new IntPtr (values);
+
+ if (depth <= 0)
+ act ();
+ else
+ NoPinActionHelper (depth - 1, act);
+ }
+
+ public static void PerformNoPinAction (Action act)
+ {
+ Thread thr = new Thread (() => NoPinActionHelper (1024, act));
+ thr.Start ();
+ thr.Join ();
+ }
+ }
+}
+
$(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; \
using System.Threading;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
+using MonoTests.Helpers;
public class Toggleref {
public int __test;
static int test_0_root_keeps_child ()
{
Console.WriteLine ("test_0_root_keeps_child");
- var t = new Thread (SetupLinks);
- t.Start ();
- t.Join ();
+ FinalizerHelpers.PerformNoPinAction (SetupLinks);
GC.Collect ();
GC.WaitForPendingFinalizers ();
{
Console.WriteLine ("test_0_child_goes_away");
- var t = new Thread (SetupLinks2);
- t.Start ();
- t.Join ();
+ FinalizerHelpers.PerformNoPinAction (SetupLinks2);
GC.Collect ();
GC.WaitForPendingFinalizers ();
{
Console.WriteLine ("test_0_CWT_keep_child_alive");
- var t = new Thread (SetupLinks3);
- t.Start ();
- t.Join ();
+ FinalizerHelpers.PerformNoPinAction (SetupLinks3);
GC.Collect ();
GC.WaitForPendingFinalizers ();
return TestDriver.RunTests (typeof (Driver), args);
}
-}
\ No newline at end of file
+}