Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -52,6 +52,16 @@ namespace MonoTests.System.Diagnostics
}
}
[Test] // Covers #26363
[NUnit.Framework.Category ("MobileNotWorking")]
public void GetProcesses_StartTime ()
{
foreach (var p in Process.GetProcesses ()) {
if (!p.HasExited && p.StartTime.Year < 1800)
Assert.Fail ("Process should not be started since the 18th century.");
}
}
[Test]
public void PriorityClass_NotStarted ()
{
@@ -768,12 +778,80 @@ namespace MonoTests.System.Diagnostics
Assert.AreEqual (true, r, "Null Argument Events Raised");
}
private ProcessStartInfo GetCrossPlatformStartInfo ()
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void TestEnableEventsAfterExitedEvent ()
{
return RunningOnUnix ? new ProcessStartInfo ("/bin/ls", "/") : new ProcessStartInfo ("help", "");
Process p = new Process ();
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
var exitedCalledCounter = 0;
p.Exited += (object sender, EventArgs e) => {
exitedCalledCounter++;
Assert.IsTrue (p.HasExited);
};
p.EnableRaisingEvents = true;
p.Start ();
p.BeginErrorReadLine ();
p.BeginOutputReadLine ();
p.WaitForExit ();
Assert.AreEqual (1, exitedCalledCounter);
Thread.Sleep (50);
Assert.AreEqual (1, exitedCalledCounter);
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void TestEnableEventsBeforeExitedEvent ()
{
Process p = new Process ();
p.StartInfo = GetCrossPlatformStartInfo ();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.EnableRaisingEvents = true;
var exitedCalledCounter = 0;
p.Exited += (object sender, EventArgs e) => {
exitedCalledCounter++;
Assert.IsTrue (p.HasExited);
};
p.Start ();
p.BeginErrorReadLine ();
p.BeginOutputReadLine ();
p.WaitForExit ();
Assert.AreEqual (1, exitedCalledCounter);
Thread.Sleep (50);
Assert.AreEqual (1, exitedCalledCounter);
}
ProcessStartInfo GetCrossPlatformStartInfo ()
{
if (RunningOnUnix) {
string path;
#if MONODROID
path = "/system/bin/ls";
#else
path = "/bin/ls";
#endif
return new ProcessStartInfo (path, "/");
} else
return new ProcessStartInfo ("help", "");
}
[Test]
public void ProcessName_NotStarted ()
{
@@ -842,6 +920,7 @@ namespace MonoTests.System.Diagnostics
}
[Test]
[NUnit.Framework.Category ("MobileNotWorking")]
public void DisposeWithDisposedStreams ()
{
var psi = GetCrossPlatformStartInfo ();
@@ -854,5 +933,40 @@ namespace MonoTests.System.Diagnostics
p.StandardOutput.BaseStream.Dispose ();
p.Dispose ();
}
[Test]
public void Modules () {
var modules = Process.GetCurrentProcess ().Modules;
foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
var found = false;
var name = a.GetName ();
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("Could not found: {0} {1}\n", name.Name, name.Version);
sb.AppendLine ("Looked in assemblies:");
foreach (var o in modules) {
var m = (ProcessModule) o;
sb.AppendFormat (" {0} {1}.{2}.{3}\n", m.FileName.ToString (),
m.FileVersionInfo.FileMajorPart,
m.FileVersionInfo.FileMinorPart,
m.FileVersionInfo.FileBuildPart);
if (!m.FileName.StartsWith ("[In Memory] " + name.Name))
continue;
var fv = m.FileVersionInfo;
if (fv.FileBuildPart != name.Version.Build ||
fv.FileMinorPart != name.Version.Minor ||
fv.FileMajorPart != name.Version.Major)
continue;
found = true;
}
Assert.IsTrue (found, sb.ToString ());
}
}
}
}