Author: martin
Date: 2006-04-25 09:10:57 -0400 (Tue, 25 Apr 2006)
New Revision: 59853
Modified:
trunk/debugger/test/testsuite/NUnit.cs
trunk/debugger/test/testsuite/TestAttach.cs
trunk/debugger/test/testsuite/testnativeattach.cs
Log:
Updated the tests.
Modified: trunk/debugger/test/testsuite/NUnit.cs
===================================================================
--- trunk/debugger/test/testsuite/NUnit.cs 2006-04-25 12:53:56 UTC (rev
59852)
+++ trunk/debugger/test/testsuite/NUnit.cs 2006-04-25 13:10:57 UTC (rev
59853)
@@ -247,6 +247,12 @@
Assert.Fail ("Got unexpected debugger output
`{0}'.", output);
}
+ public string ReadDebuggerOutput ()
+ {
+ debugger_output.Wait ();
+ return debugger_output.ReadLine ();
+ }
+
public void AssertFrame (string frame, int exp_index, string
exp_func, int exp_line)
{
Match match = frame_regex.Match (frame);
@@ -298,7 +304,7 @@
int thread = Int32.Parse (match.Groups [1].Value);
string frame = match.Groups [2].Value;
- if (thread != exp_thread.ID)
+ if ((exp_thread != null) && (thread != exp_thread.ID))
Assert.Fail ("Thread {0} stopped at {1}, but
expected thread {2} to stop.",
thread, frame, exp_thread.ID);
@@ -427,6 +433,21 @@
return interpreter.GetThread (id);
}
+ public Thread AssertThreadCreated ()
+ {
+ debugger_output.Wait ();
+ string output = debugger_output.ReadLine ();
+ if (output == null)
+ Assert.Fail ("Failed to created thread
(received `{0}').", output);
+
+ Match match = thread_created_regex.Match (output);
+ if (!match.Success)
+ Assert.Fail ("Failed to created thread
(received `{0}').", output);
+
+ int id = Int32.Parse (match.Groups [2].Value);
+ return interpreter.GetThread (id);
+ }
+
public void AssertProcessExited (Process process)
{
debugger_output.Wait ();
@@ -693,7 +714,7 @@
waiting = true;
}
- wait_event.WaitOne ();
+ wait_event.WaitOne (50, false);
}
public string ReadLine ()
Modified: trunk/debugger/test/testsuite/TestAttach.cs
===================================================================
--- trunk/debugger/test/testsuite/TestAttach.cs 2006-04-25 12:53:56 UTC (rev
59852)
+++ trunk/debugger/test/testsuite/TestAttach.cs 2006-04-25 13:10:57 UTC (rev
59853)
@@ -11,23 +11,103 @@
[TestFixture]
public class TestAttach : TestSuite
{
+ SD.Process child;
+
public TestAttach ()
: base ("TestAttach")
{ }
+ public override void SetUp ()
+ {
+ base.SetUp ();
+
+ child = SD.Process.Start (MonoExecutable, "--debug " +
ExeFileName);
+ }
+
+ public override void TearDown ()
+ {
+ base.TearDown ();
+
+ if (!child.HasExited)
+ child.Kill ();
+ }
+
[Test]
- [Category("NotWorking")]
+ [Category("Attach")]
public void Main ()
{
- SD.Process child = SD.Process.Start (MonoExecutable,
ExeFileName);
- Console.WriteLine (child.Id);
+ Process process = Interpreter.Attach (child.Id);
+ Assert.IsTrue (process.MainThread.IsStopped);
- try {
- Process process = Interpreter.Attach (child.Id);
- Console.WriteLine ("TEST: {0}", process);
- } finally {
- child.Kill ();
- }
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+
+ StackFrame frame = process.MainThread.CurrentFrame;
+ Assert.IsNotNull (frame);
+ Backtrace bt = process.MainThread.GetBacktrace (-1);
+ if (bt.Count < 1)
+ Assert.Fail ("Cannot get backtrace.");
+
+ process.Detach ();
+ AssertProcessExited (process);
+ AssertTargetExited ();
}
+
+ [Test]
+ [Category("Attach")]
+ public void AttachAgain ()
+ {
+ Process process = Interpreter.Attach (child.Id);
+ Assert.IsTrue (process.MainThread.IsStopped);
+
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+
+ StackFrame frame = process.MainThread.CurrentFrame;
+ Assert.IsNotNull (frame);
+ Backtrace bt = process.MainThread.GetBacktrace (-1);
+ if (bt.Count < 1)
+ Assert.Fail ("Cannot get backtrace.");
+
+ process.Detach ();
+ AssertProcessExited (process);
+ AssertTargetExited ();
+ }
+
+ [Test]
+ [Category("Attach")]
+ public void Kill ()
+ {
+ Process process = Interpreter.Attach (child.Id);
+ Assert.IsTrue (process.MainThread.IsStopped);
+
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+ AssertThreadCreated ();
+
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+ AssertStopped (null, null, -1);
+
+ StackFrame frame = process.MainThread.CurrentFrame;
+ Assert.IsNotNull (frame);
+ Backtrace bt = process.MainThread.GetBacktrace (-1);
+ if (bt.Count < 1)
+ Assert.Fail ("Cannot get backtrace.");
+
+ Interpreter.Kill ();
+ AssertTargetExited ();
+ child.WaitForExit ();
+ }
}
}
Modified: trunk/debugger/test/testsuite/testnativeattach.cs
===================================================================
--- trunk/debugger/test/testsuite/testnativeattach.cs 2006-04-25 12:53:56 UTC
(rev 59852)
+++ trunk/debugger/test/testsuite/testnativeattach.cs 2006-04-25 13:10:57 UTC
(rev 59853)
@@ -33,7 +33,7 @@
}
[Test]
- [Category("Fork")]
+ [Category("Attach")]
public void Main ()
{
Process process = Interpreter.Attach (child.Id);
@@ -53,7 +53,7 @@
}
[Test]
- [Category("Fork")]
+ [Category("Attach")]
public void AttachAgain ()
{
Process process = Interpreter.Attach (child.Id);
@@ -73,7 +73,7 @@
}
[Test]
- [Category("Fork")]
+ [Category("Attach")]
public void Kill ()
{
Process process = Interpreter.Attach (child.Id);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches