Imported Upstream version 4.8.0.520

Former-commit-id: b616177084b79e9a11491af6b1ad88f2f73a6093
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-03-15 10:36:24 +00:00
parent af08d800c3
commit dc50008e16
32 changed files with 143 additions and 821 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -221,7 +221,7 @@ namespace Mono.Data.Sqlite
case SQLiteDateFormats.UnixEpoch:
return ((long)(dateValue.Subtract(UnixEpoch).Ticks / TimeSpan.TicksPerSecond)).ToString();
default:
return dateValue.ToString(_datetimeFormats[5], CultureInfo.InvariantCulture);
return dateValue.ToString(_datetimeFormats[19], CultureInfo.InvariantCulture);
}
}

View File

@@ -19,6 +19,7 @@ namespace MonoTests.System.Threading {
// this bucket is used to avoid non-theadlocal issues
class Bucket {
public int count;
public ManualResetEventSlim mre = new ManualResetEventSlim (false);
}
[SetUp]
@@ -36,51 +37,22 @@ namespace MonoTests.System.Threading {
{
}
private void Callback2 (object foo)
{
Bucket b = foo as Bucket;
Interlocked.Increment (ref b.count);
b.mre.Set ();
}
[Test]
public void TestDueTime ()
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback (o), bucket, 200, Timeout.Infinite)) {
Thread.Sleep (50);
Assert.AreEqual (0, bucket.count, "#1");
Thread.Sleep (200);
Assert.AreEqual (1, bucket.count, "#2");
Thread.Sleep (500);
Assert.AreEqual (1, bucket.count, "#3");
t.Change (10, 10);
Thread.Sleep (1000);
Assert.IsTrue(bucket.count > 20, "#4");
}
}
[Test]
public void TestChange ()
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback (o), bucket, 10, 10)) {
Thread.Sleep (500);
int c = bucket.count;
Assert.IsTrue (c > 20, "#1 " + c.ToString ());
t.Change (100, 100);
c = bucket.count;
Thread.Sleep (500);
Assert.IsTrue (bucket.count <= c + 20, "#2 " + c.ToString ());
}
}
[Test]
public void TestZeroDueTime ()
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback (o), bucket, 0, Timeout.Infinite)) {
Thread.Sleep (100);
using (Timer t = new Timer (o => Callback2 (o), bucket, 200, Timeout.Infinite)) {
Assert.IsTrue (bucket.mre.Wait (5000), "#-1");
Assert.AreEqual (1, bucket.count, "#1");
t.Change (0, Timeout.Infinite);
Thread.Sleep (100);
Assert.AreEqual (2, bucket.count, "#2");
}
}
@@ -89,15 +61,44 @@ namespace MonoTests.System.Threading {
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback (o), bucket, 10, 10)) {
Thread.Sleep (200);
using (Timer t = new Timer (o => Callback2 (o), bucket, 10, 10)) {
Assert.IsTrue (bucket.mre.Wait (5000), "#-1");
}
Thread.Sleep (20);
//If the callback is called after dispose, it will NRE and be reported
bucket.mre = null;
int c = bucket.count;
Assert.IsTrue (bucket.count > 5, "#1");
Thread.Sleep (200);
Assert.AreEqual (c, bucket.count, "#2");
Assert.IsTrue (c > 0, "#1");
}
[Test]
public void TestChange ()
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback2 (o), bucket, 10, 10)) {
Assert.IsTrue (bucket.mre.Wait (5000), "#-1");
int c = bucket.count;
Assert.IsTrue (c > 0, "#1 " + c);
t.Change (100000, 1000000);
c = bucket.count;
Thread.Sleep (500);
Assert.IsTrue (bucket.count <= c + 1, "#2 " + c);
}
}
[Test]
public void TestZeroDueTime ()
{
Bucket bucket = new Bucket();
using (Timer t = new Timer (o => Callback2 (o), bucket, 0, Timeout.Infinite)) {
Assert.IsTrue (bucket.mre.Wait (5000), "#-1");
bucket.mre.Reset ();
Assert.AreEqual (1, bucket.count, "#1");
t.Change (0, Timeout.Infinite);
Assert.IsTrue (bucket.mre.Wait (5000), "#1.5");
Assert.AreEqual (2, bucket.count, "#2");
}
}
[Test] // bug #320950

View File

@@ -27,6 +27,7 @@
//
using System;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
@@ -57,7 +58,10 @@ namespace MonoTests.System {
[Test]
public void ReRegisterForFinalizeTest ()
{
Run_ReRegisterForFinalizeTest ();
var thread = new Thread (Run_ReRegisterForFinalizeTest);
thread.Start ();
thread.Join ();
var t = Task.Factory.StartNew (() => {
do {
GC.Collect ();

View File

@@ -24,10 +24,11 @@ test-simple: simple.exe
mono --debug $(the_lib) --cross default simple.exe -o foo && ./foo
mono --debug $(the_lib) --sdk `dirname \`which mono\``/.. simple.exe -o foo && ./foo
-rm DEMO.zip
mono-package-runtime `dirname \`which mono\``/.. DEMO
$(topdir)/../scripts/mono-package-runtime `dirname \`which mono\``/.. DEMO
mkdir -p ~/.mono/targets/DEMO
unzip -d ~/.mono/targets/DEMO DEMO.zip
mono --debug $(the_lib) --cross DEMO simple.exe -o foo && ./foo
mono --debug $(the_lib) --cross DEMO simple.exe -o foo | grep "Assembly.*mscorlib.dll"
./foo
simple.exe: Makefile
echo 'class X { static void Main () { System.Console.WriteLine ("OK");}}' > simple.cs && mcs simple.cs

View File

@@ -1082,14 +1082,14 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
static void LoadLocalizedAssemblies (List<string> assemblies)
{
var other = i18n.Select (x => "I18N." + x + (x.Length > 0 ? "." : "") + "dll");
bool error = false;
string error = null;
foreach (string name in other) {
try {
Assembly a = LoadAssembly (name);
if (a == null) {
error = true;
error = "Failed to load " + name;
continue;
}
@@ -1105,8 +1105,8 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
}
}
if (error) {
Error ("Couldn't load one or more of the i18n assemblies.");
if (error != null) {
Error ("Couldn't load one or more of the i18n assemblies: " + error);
Environment.Exit (1);
}
}
@@ -1114,6 +1114,7 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
static readonly Universe universe = new Universe ();
static readonly Dictionary<string, string> loaded_assemblies = new Dictionary<string, string> ();
static readonly string resourcePathSeparator = (Path.DirectorySeparatorChar == '\\') ? $"\\{Path.DirectorySeparatorChar}" : $"{Path.DirectorySeparatorChar}";
public static string GetAssemblyName (string path)
{
@@ -1126,7 +1127,7 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
string dir = Path.GetDirectoryName (path);
int idx = dir.LastIndexOf (Path.DirectorySeparatorChar);
if (idx >= 0) {
name = dir.Substring (idx + 1) + Path.DirectorySeparatorChar + name;
name = dir.Substring (idx + 1) + resourcePathSeparator + name;
Console.WriteLine ($"Storing satellite assembly '{path}' with name '{name}'");
} else if (!quiet)
Console.WriteLine ($"Warning: satellite assembly {path} doesn't have locale path prefix, name conflicts possible");
@@ -1158,7 +1159,7 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
Assembly a = universe.LoadFile (path);
foreach (AssemblyName an in a.GetReferencedAssemblies ()) {
LoadAssembly (an.FullName);
a = universe.Load (an.FullName);
if (!QueueAssembly (files, a.CodeBase))
return false;
}
@@ -1220,7 +1221,6 @@ void mono_register_config_for_assembly (const char* assembly_name, cons
static void Error (string msg, params object [] args)
{
Console.Error.WriteLine ("ERROR: {0}", string.Format (msg, args));
throw new Exception ();
Environment.Exit (1);
}