Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -10,6 +10,7 @@
using NUnit.Framework;
using System;
using System.Diagnostics;
using System.Text;
using System.Threading;
using Mono.Unix;
@@ -25,12 +26,12 @@ namespace MonoTests.Mono.Unix {
static Thread CreateWaitSignalThread (UnixSignal signal, int timeout)
{
Thread t1 = new Thread(delegate() {
DateTime start = DateTime.Now;
var sw = Stopwatch.StartNew ();
bool r = signal.WaitOne (timeout, false);
DateTime end = DateTime.Now;
sw.Stop ();
Assert.AreEqual (signal.Count, 1);
Assert.AreEqual (r, true);
if ((end - start) > new TimeSpan (0, 0, timeout/1000))
if (sw.Elapsed > new TimeSpan (0, 0, timeout/1000))
throw new InvalidOperationException ("Signal slept too long");
});
return t1;
@@ -248,12 +249,12 @@ namespace MonoTests.Mono.Unix {
{
Thread t1 = new Thread (delegate () {
using (UnixSignal a = new UnixSignal (Signum.SIGINT)) {
DateTime start = DateTime.Now;
var sw = Stopwatch.StartNew ();
bool r = a.WaitOne (5000, false);
DateTime end = DateTime.Now;
sw.Stop ();
Assert.AreEqual (a.Count, 1);
Assert.AreEqual (r, true);
if ((end - start) > new TimeSpan (0, 0, 5))
if (sw.Elapsed > new TimeSpan (0, 0, 5))
throw new InvalidOperationException ("Signal slept too long");
}
});
@@ -272,12 +273,12 @@ namespace MonoTests.Mono.Unix {
{
Thread t1 = new Thread (delegate () {
using (UnixSignal a = new UnixSignal (Signum.SIGINT)) {
DateTime start = DateTime.Now;
var sw = Stopwatch.StartNew ();
int idx = UnixSignal.WaitAny (new UnixSignal[]{a}, 5000);
DateTime end = DateTime.Now;
sw.Stop ();
Assert.AreEqual (idx, 0);
Assert.AreEqual (a.Count, 1);
if ((end - start) > new TimeSpan (0, 0, 5))
if (sw.Elapsed > new TimeSpan (0, 0, 5))
throw new InvalidOperationException ("Signal slept too long");
}
});
@@ -297,13 +298,13 @@ namespace MonoTests.Mono.Unix {
Thread t1 = new Thread (delegate () {
using (UnixSignal a = new UnixSignal (Signum.SIGINT))
using (UnixSignal b = new UnixSignal (Signum.SIGTERM)) {
DateTime start = DateTime.Now;
var sw = Stopwatch.StartNew ();
int idx = UnixSignal.WaitAny (new UnixSignal[]{a, b}, 5000);
DateTime end = DateTime.Now;
sw.Stop ();
Assert.AreEqual (idx, 1);
Assert.AreEqual (a.Count, 0);
Assert.AreEqual (b.Count, 1);
if ((end - start) > new TimeSpan (0, 0, 5))
if (sw.Elapsed > new TimeSpan (0, 0, 5))
throw new InvalidOperationException ("Signal slept too long");
}
});
@@ -321,12 +322,12 @@ namespace MonoTests.Mono.Unix {
public void TestNoEmit ()
{
using (UnixSignal u = new UnixSignal (Signum.SIGINT)) {
DateTime start = DateTime.Now;
var sw = Stopwatch.StartNew ();
bool r = u.WaitOne (5100, false);
Assert.AreEqual (r, false);
DateTime end = DateTime.Now;
if ((end - start) < new TimeSpan (0, 0, 5))
throw new InvalidOperationException ("Signal didn't block for 5s; blocked for " + (end-start).ToString());
sw.Stop ();
if (sw.Elapsed < new TimeSpan (0, 0, 5))
throw new InvalidOperationException ("Signal didn't block for 5s; blocked for " + sw.Elapsed.TotalSeconds.ToString());
}
}