Merge pull request #1949 from lewurm/fixtype
[mono.git] / mcs / class / System / Test / System.Diagnostics / ProcessTest.cs
index 14e5dcdca8e22c5dd813e0ce04260e854b2953ad..d4372a1ddddc76083a6022ab54d46aa4212ec533 100644 (file)
@@ -732,8 +732,6 @@ namespace MonoTests.System.Diagnostics
 
                public int bytesRead = -1;
 
-// Not technically a 2.0 only test, but I use lambdas, so I need gmcs
-
                [Test]
                [NUnit.Framework.Category ("MobileNotWorking")]
                // This was for bug #459450
@@ -791,9 +789,11 @@ namespace MonoTests.System.Diagnostics
                        p.StartInfo.RedirectStandardError = true;
 
                        var exitedCalledCounter = 0;
+                       var exited = new ManualResetEventSlim ();
                        p.Exited += (object sender, EventArgs e) => {
                                exitedCalledCounter++;
                                Assert.IsTrue (p.HasExited);
+                               exited.Set ();
                        };
 
                        p.EnableRaisingEvents = true;
@@ -803,6 +803,7 @@ namespace MonoTests.System.Diagnostics
                        p.BeginOutputReadLine ();
                        p.WaitForExit ();
 
+                       exited.Wait (10000);
                        Assert.AreEqual (1, exitedCalledCounter);
                        Thread.Sleep (50);
                        Assert.AreEqual (1, exitedCalledCounter);
@@ -822,9 +823,11 @@ namespace MonoTests.System.Diagnostics
                        p.EnableRaisingEvents = true;
 
                        var exitedCalledCounter = 0;
+                       var exited = new ManualResetEventSlim ();
                        p.Exited += (object sender, EventArgs e) => {
                                exitedCalledCounter++;
                                Assert.IsTrue (p.HasExited);
+                               exited.Set ();
                        };
 
                        p.Start ();
@@ -832,15 +835,25 @@ namespace MonoTests.System.Diagnostics
                        p.BeginOutputReadLine ();
                        p.WaitForExit ();
 
+                       exited.Wait (10000);
                        Assert.AreEqual (1, exitedCalledCounter);
                        Thread.Sleep (50);
                        Assert.AreEqual (1, exitedCalledCounter);
                }
 
                
-               private ProcessStartInfo GetCrossPlatformStartInfo ()
+               ProcessStartInfo GetCrossPlatformStartInfo ()
                {
-                       return RunningOnUnix ? new ProcessStartInfo ("/bin/ls", "/") : new ProcessStartInfo ("help", "");
+                       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]
@@ -911,6 +924,7 @@ namespace MonoTests.System.Diagnostics
                }
 
                [Test]
+               [NUnit.Framework.Category ("MobileNotWorking")]
                public void DisposeWithDisposedStreams ()
                {
                        var psi = GetCrossPlatformStartInfo ();
@@ -924,6 +938,21 @@ namespace MonoTests.System.Diagnostics
                        p.Dispose ();
                }
 
+               [Test]
+               [NUnit.Framework.Category ("MobileNotWorking")]
+               public void StandardInputWrite ()
+               {
+                       var psi = GetCrossPlatformStartInfo ();
+                       psi.RedirectStandardInput = true;
+                       psi.RedirectStandardOutput = true;
+                       psi.UseShellExecute = false;
+
+                       using (var p = Process.Start (psi)) {
+                               for (int i = 0; i < 1024 * 9; ++i)
+                                       p.StandardInput.Write ('x');
+                       }
+               }
+
                [Test]
                public void Modules () {
                        var modules = Process.GetCurrentProcess ().Modules;