diff options
author | Marek Safar <marek.safar@gmail.com> | 2015-02-12 16:20:53 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2015-02-12 16:21:24 +0300 |
commit | 45448a3f16c1b9a2695b44d5eda39eff00e250ba (patch) | |
tree | 789002e6a3a161b57fe5c1fb3855d261197c5b5e /mcs/class/corlib | |
parent | 9eea9b6d705d363fc5116befc3b7b1ec3712e28b (diff) |
[corlib] Add timeout to more tests
Diffstat (limited to 'mcs/class/corlib')
-rw-r--r-- | mcs/class/corlib/Test/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs | 10 | ||||
-rw-r--r-- | mcs/class/corlib/Test/System/LazyTest.cs | 24 |
2 files changed, 18 insertions, 16 deletions
diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs index 2a6165aff57..d6216f73dbe 100644 --- a/mcs/class/corlib/Test/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs +++ b/mcs/class/corlib/Test/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTest.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_4_5 - using System; using System.Threading; using System.Threading.Tasks; @@ -40,12 +38,15 @@ namespace MonoTests.System.Runtime.CompilerServices [TestFixture] public class AsyncTaskMethodBuilderTest { +#if !MONOTOUCH + // For some reason MT excludes CallContext handling + [Test] public void CallContextFlow () { CallContext.LogicalSetData ("name0", "0"); - Task.WhenAll (Work ("A"), Work ("B")).Wait (); + Assert.IsTrue (Task.WhenAll (Work ("A"), Work ("B")).Wait (4000), "#0"); Assert.IsNull (CallContext.LogicalGetData ("A"), "#A"); Assert.IsNull (CallContext.LogicalGetData ("B"), "#B"); } @@ -60,7 +61,6 @@ namespace MonoTests.System.Runtime.CompilerServices var found = CallContext.LogicalGetData ("name"); Assert.AreEqual (name, found, "#2" + name); } +#endif } } - -#endif
\ No newline at end of file diff --git a/mcs/class/corlib/Test/System/LazyTest.cs b/mcs/class/corlib/Test/System/LazyTest.cs index 6fb77f4d0fe..ce75180cb1b 100644 --- a/mcs/class/corlib/Test/System/LazyTest.cs +++ b/mcs/class/corlib/Test/System/LazyTest.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if NET_4_0 - using System; using System.Reflection; using System.Threading; @@ -113,26 +111,32 @@ namespace MonoTests.System static int counter; [Test] - public void EnsureSingleThreadSafeExecution () { + public void EnsureSingleThreadSafeExecution () + { counter = 42; var l = new Lazy<int> (delegate () { return counter ++; }, true); - + bool failed = false; object monitor = new object (); - var threads = new Thread [10]; - for (int i = 0; i < 10; ++i) { + var threads = new Thread [4]; + for (int i = 0; i < threads.Length; ++i) { threads [i] = new Thread (delegate () { lock (monitor) { - Monitor.Wait (monitor); + if (!Monitor.Wait (monitor, 2000)) + failed = true; } int val = l.Value; }); } - for (int i = 0; i < 10; ++i) + for (int i = 0; i < threads.Length; ++i) threads [i].Start (); lock (monitor) Monitor.PulseAll (monitor); - + + for (int i = 0; i < threads.Length; ++i) + threads [i].Join (); + + Assert.IsFalse (failed); Assert.AreEqual (42, l.Value); } @@ -315,5 +319,3 @@ namespace MonoTests.System } } - -#endif |