You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -1,12 +1,32 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Mono.Unix.Android
|
||||
{
|
||||
// Another version of this class is used by the Xamarin.Android test suite
|
||||
// It is here to keep the test code #ifdef free as much as possible
|
||||
public class TestHelper
|
||||
{
|
||||
static bool areRealTimeSignalsSafe;
|
||||
|
||||
static TestHelper ()
|
||||
{
|
||||
#if MONODROID
|
||||
var method = typeof (Mono.Unix.Native.NativeConvert).Assembly.GetType ("Mono.Unix.Android.AndroidUtils").GetMethod ("AreRealTimeSignalsSafe", BindingFlags.Public | BindingFlags.Static);
|
||||
areRealTimeSignalsSafe = (bool)method.Invoke (null, null);
|
||||
#else
|
||||
areRealTimeSignalsSafe = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool CanUseRealTimeSignals ()
|
||||
{
|
||||
if (!areRealTimeSignalsSafe) {
|
||||
Assert.Ignore ("Real-time signals aren't supported on this Android architecture");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,13 @@ namespace MonoTests.Mono.Unix {
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void BXC10074 ()
|
||||
{
|
||||
var result = UnixMarshal.StringToHeap (null, Encoding.ASCII);
|
||||
Assert.AreEqual (IntPtr.Zero, result, "This used to crash due to a NullReferenceException");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStringToHeap ()
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user