Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
One more test is migrated.
Browse files Browse the repository at this point in the history
svn path=/trunk/debugger/; revision=59155
  • Loading branch information
Martin Baulig committed Apr 6, 2006
1 parent de5894f commit 137207d
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 84 deletions.
82 changes: 0 additions & 82 deletions test/mono-debugger.tests/TestAbort.exp

This file was deleted.

23 changes: 22 additions & 1 deletion test/testsuite/NUnit.cs
Expand Up @@ -139,7 +139,18 @@ public void AssertExecuteException (string text, string exp_exception)
public void AssertFrame (Thread thread, string function, int line)
{
try {
StackFrame frame = thread.CurrentFrame;
AssertFrame (thread.CurrentFrame, 0, function, line);
} catch (TargetException ex) {
Assert.Fail ("Cannot get current frame: {0}.", ex.Message);
}
}

public void AssertFrame (StackFrame frame, int level, string function, int line)
{
try {
Assert.AreEqual (level, frame.Level,
"Stack frame is from level {0}, but expected {1}.",
level, frame.Level);
SourceLocation location = frame.SourceAddress.Location;
Assert.AreEqual (function, location.Method.Name,
"Target stopped in method `{0}', but expected `{1}'.",
Expand All @@ -152,6 +163,16 @@ public void AssertFrame (Thread thread, string function, int line)
}
}

public void AssertInternalFrame (StackFrame frame, int level)
{
Assert.AreEqual (level, frame.Level,
"Stack frame is from level {0}, but expected {1}.",
level, frame.Level);
Assert.AreEqual ("<method called from mdb>", frame.Name.ToString (),
"Got frame `{0}', but expected a method " +
"called from mdb.", frame);
}

public void AssertTargetOutput (string line)
{
string output = inferior_stdout.ReadLine ();
Expand Down
107 changes: 107 additions & 0 deletions test/testsuite/TestAbort.cs
@@ -0,0 +1,107 @@
using System;
using NUnit.Framework;

using Mono.Debugger;
using Mono.Debugger.Languages;
using Mono.Debugger.Frontend;

namespace Mono.Debugger.Tests
{
[TestFixture]
public class TestAbort : TestSuite
{
public TestAbort ()
: base ("TestAbort")
{ }

[Test]
public void Main ()
{
Process process = Interpreter.Start ();
Assert.IsTrue (process.IsManaged);
Assert.IsTrue (process.MainThread.IsStopped);
Thread thread = process.MainThread;

const int line_main = 33;
const int line_hello = 13;
const int line_hello_2 = 20;
const int line_hello_3 = 22;
const int line_hello_4 = 23;

AssertStopped (thread, "X.Main()", line_main);

AssertExecute ("call Hello()");
AssertStopped (thread, "X.Hello()", line_hello);

Backtrace bt = thread.GetBacktrace (-1);
if (bt.Count != 3)
Assert.Fail ("Backtrace has {0} frames, but expected {1}.",
bt.Count, 3);

AssertFrame (bt [0], 0, "X.Hello()", line_hello);
AssertInternalFrame (bt [1], 1);
AssertFrame (bt [2], 2, "X.Main()", line_main);

AssertExecute ("continue");
AssertTargetOutput ("Hello World");
AssertStopped (thread, "X.Main()", line_main);

AssertExecute ("call Hello()");
AssertStopped (thread, "X.Hello()", line_hello);

AssertExecute ("return -yes");
AssertStopped (thread, "X.Main()", line_main);

AssertExecute ("call Hello (8)");
AssertStopped (thread, "X.Hello(System.Int32)", line_hello_2);
AssertExecute ("return -yes");
AssertStopped (thread, "X.Main()", line_main);

AssertExecute ("call Hello (9)");
AssertStopped (thread, "X.Hello(System.Int32)", line_hello_2);
AssertExecute ("step");
AssertStopped (thread, "X.Hello(System.Int32)", line_hello_3);
AssertExecute ("return -yes");
AssertTargetOutput ("Done: 9 18 1");
AssertNoTargetOutput ();
AssertStopped (thread, "X.Main()", line_main);

bt = thread.GetBacktrace (-1);
if (bt.Count != 1)
Assert.Fail ("Backtrace has {0} frames, but expected {1}.",
bt.Count, 1);

AssertFrame (bt [0], 0, "X.Main()", line_main);

AssertExecute ("call Hello (7)");
AssertStopped (thread, "X.Hello(System.Int32)", line_hello_2);
AssertExecute ("step");
AssertStopped (thread, "X.Hello(System.Int32)", line_hello_3);
AssertExecute ("step");
AssertStopped (thread, "X.Hello()", line_hello);

bt = thread.GetBacktrace (-1);
if (bt.Count != 4)
Assert.Fail ("Backtrace has {0} frames, but expected {1}.",
bt.Count, 4);

AssertFrame (bt [0], 0, "X.Hello()", line_hello);
AssertFrame (bt [1], 1, "X.Hello(System.Int32)", line_hello_4);
AssertInternalFrame (bt [2], 2);
AssertFrame (bt [3], 3, "X.Main()", line_main);

AssertExecute ("return -yes -invocation");
AssertTargetOutput ("Done: 7 14 2");
AssertNoTargetOutput ();

AssertStopped (thread, "X.Main()", line_main);

bt = thread.GetBacktrace (-1);
if (bt.Count != 1)
Assert.Fail ("Backtrace has {0} frames, but expected {1}.",
bt.Count, 1);

AssertFrame (bt [0], 0, "X.Main()", line_main);
}
}
}
2 changes: 1 addition & 1 deletion test/testsuite/TestDelegate.cs
Expand Up @@ -64,7 +64,7 @@ public void Main ()
AssertTargetOutput ("Boston: 3");
AssertNoTargetOutput ();

int bpt = AssertBreakpoint ("-invoke x.Foo");
AssertBreakpoint ("-invoke x.Foo");
AssertExecute ("continue");
AssertTargetOutput ("Back in main");
AssertNoTargetOutput ();
Expand Down

0 comments on commit 137207d

Please sign in to comment.