Browse Source

Process.Terminate blocks until the process is terminated.

Improved termination unit tests

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3158 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
08b3a84a5d
  1. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs
  2. 16
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Exception.cs
  3. 3
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/TerminatePausedProcess.cs
  4. 30
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/TerminateRunningProcess.cs

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-StateControl.cs

@ -223,9 +223,15 @@ namespace Debugger @@ -223,9 +223,15 @@ namespace Debugger
}
/// <summary> Terminates the execution of the process </summary>
/// <remarks> The process does not terminate immediately
/// after the call </remarks>
public void Terminate()
{
AsyncTerminate();
// Wait until ExitProcess callback is received
WaitForExit();
}
/// <summary> Terminates the execution of the process </summary>
public void AsyncTerminate()
{
// Resume stoped tread
if (this.IsPaused) {
@ -240,8 +246,8 @@ namespace Debugger @@ -240,8 +246,8 @@ namespace Debugger
corProcess.Stop(uint.MaxValue);
corProcess.Terminate(0);
// Just give the command and continue without marking the process as
// exited. We will get ExitProcess callback soon
// Do not mark the process as exited
// This is done once ExitProcess callback is received
}
void SelectSomeThread()

16
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Exception.cs

@ -13,6 +13,8 @@ namespace Debugger.Tests.TestPrograms @@ -13,6 +13,8 @@ namespace Debugger.Tests.TestPrograms
{
public static void Main()
{
System.Diagnostics.Debugger.Break();
throw new System.Exception("test");
}
}
@ -20,6 +22,8 @@ namespace Debugger.Tests.TestPrograms @@ -20,6 +22,8 @@ namespace Debugger.Tests.TestPrograms
#if TEST_CODE
namespace Debugger.Tests {
using NUnit.Framework;
public partial class DebuggerTests
{
[NUnit.Framework.Test]
@ -27,6 +31,16 @@ namespace Debugger.Tests { @@ -27,6 +31,16 @@ namespace Debugger.Tests {
{
StartTest("Exception.cs");
process.ExceptionThrown += delegate {
process.Terminate();
};
process.Paused += delegate {
// Should not be raised for dead process
Assert.Fail();
};
process.AsyncContinue();
process.WaitForExit();
EndTest();
}
}
@ -40,8 +54,8 @@ namespace Debugger.Tests { @@ -40,8 +54,8 @@ namespace Debugger.Tests {
<ProcessStarted />
<ModuleLoaded symbols="False">mscorlib.dll</ModuleLoaded>
<ModuleLoaded symbols="True">Exception.exe</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<ExceptionThrown>test</ExceptionThrown>
<DebuggingPaused>Exception</DebuggingPaused>
<ProcessExited />
</Test>
</DebuggerTests>

3
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/TerminatePausedProcess.cs

@ -27,11 +27,10 @@ namespace Debugger.Tests { @@ -27,11 +27,10 @@ namespace Debugger.Tests {
{
StartTest("TerminatePausedProcess.cs");
process.Terminate();
process.WaitForExit();
StartTest("TerminatePausedProcess.cs");
process.Terminate();
process.WaitForExit();
CheckXmlOutput();
}
}

30
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/TerminateRunningProcess.cs

@ -16,6 +16,8 @@ namespace Debugger.Tests.TestPrograms @@ -16,6 +16,8 @@ namespace Debugger.Tests.TestPrograms
public static void Main()
{
int i = 42;
System.Diagnostics.Debugger.Break();
doSomething.WaitOne();
}
}
@ -23,18 +25,24 @@ namespace Debugger.Tests.TestPrograms @@ -23,18 +25,24 @@ namespace Debugger.Tests.TestPrograms
#if TEST_CODE
namespace Debugger.Tests {
using NUnit.Framework;
public partial class DebuggerTests
{
[NUnit.Framework.Test]
public void TerminateRunningProcess()
{
StartTest("TerminateRunningProcess.cs", false);
process.Terminate();
process.WaitForExit();
for(int i = 0; i < 2; i++) {
StartTest("TerminateRunningProcess.cs");
process.SelectedStackFrame.StepOver();
process.Paused += delegate {
Assert.Fail("Should not have received any callbacks after Terminate");
};
process.SelectedStackFrame.AsyncStepOver();
ObjectDump("Log", "Calling terminate");
process.Terminate();
}
StartTest("TerminateRunningProcess.cs", false);
process.Terminate();
process.WaitForExit();
CheckXmlOutput();
}
}
@ -46,8 +54,18 @@ namespace Debugger.Tests { @@ -46,8 +54,18 @@ namespace Debugger.Tests {
<DebuggerTests>
<Test name="TerminateRunningProcess.cs">
<ProcessStarted />
<ModuleLoaded symbols="False">mscorlib.dll</ModuleLoaded>
<ModuleLoaded symbols="True">TerminateRunningProcess.exe</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<DebuggingPaused>StepComplete</DebuggingPaused>
<Log>Calling terminate</Log>
<ProcessExited />
<ProcessStarted />
<ModuleLoaded symbols="False">mscorlib.dll</ModuleLoaded>
<ModuleLoaded symbols="True">TerminateRunningProcess.exe</ModuleLoaded>
<DebuggingPaused>Break</DebuggingPaused>
<DebuggingPaused>StepComplete</DebuggingPaused>
<Log>Calling terminate</Log>
<ProcessExited />
</Test>
</DebuggerTests>

Loading…
Cancel
Save