~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Debugger/Debugger.Tests/Tests/ControlFlow_MainThreadExit.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Threading;
 
6
 
 
7
namespace Debugger.Tests
 
8
{
 
9
        public class ControlFlow_MainThreadExit
 
10
        {
 
11
                static ManualResetEvent doSomething = new ManualResetEvent(false);
 
12
                
 
13
                public static void Main()
 
14
                {
 
15
                        System.Threading.Thread t = new System.Threading.Thread(WaitForALongTime);
 
16
                        t.Name = "Worker thread";
 
17
                        t.Start();
 
18
                        // Wait for the thread to start
 
19
                        System.Threading.Thread.Sleep(500);
 
20
                        System.Diagnostics.Debugger.Break();
 
21
                }
 
22
                
 
23
                static void WaitForALongTime()
 
24
                {
 
25
                        doSomething.WaitOne();
 
26
                }
 
27
        }
 
28
}
 
29
 
 
30
#if TEST_CODE
 
31
namespace Debugger.Tests {
 
32
        public partial class DebuggerTests
 
33
        {
 
34
                [NUnit.Framework.Test]
 
35
                public void ControlFlow_MainThreadExit()
 
36
                {
 
37
                        StartTest();
 
38
                        ObjectDump("ThreadsBeforeExit", process.Threads);
 
39
                        process.AsyncContinue();
 
40
                        // Wait for the main thread to exit
 
41
                        System.Threading.Thread.Sleep(500);
 
42
                        process.Break();
 
43
                        ObjectDump("ThreadsAfterExit", process.Threads);
 
44
                        process.Terminate();
 
45
                        EndTest();
 
46
                }
 
47
        }
 
48
}
 
49
#endif
 
50
 
 
51
#if EXPECTED_OUTPUT
 
52
<?xml version="1.0" encoding="utf-8"?>
 
53
<DebuggerTests>
 
54
  <Test
 
55
    name="ControlFlow_MainThreadExit.cs">
 
56
    <ProcessStarted />
 
57
    <ModuleLoaded>mscorlib.dll (No symbols)</ModuleLoaded>
 
58
    <ModuleLoaded>ControlFlow_MainThreadExit.exe (Has symbols)</ModuleLoaded>
 
59
    <DebuggingPaused>Break ControlFlow_MainThreadExit.cs:20,4-20,40</DebuggingPaused>
 
60
    <ThreadsBeforeExit
 
61
      Count="2"
 
62
      Selected="Thread Name =  Suspended = False">
 
63
      <Item>
 
64
        <Thread
 
65
          Callstack="{static void Debugger.Tests.ControlFlow_MainThreadExit.Main()}"
 
66
          CurrentExceptionType="0"
 
67
          IsAtSafePoint="True"
 
68
          IsInValidState="True"
 
69
          MostRecentStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()"
 
70
          Name=""
 
71
          Priority="Normal"
 
72
          RuntimeValue="{System.Threading.Thread}"
 
73
          SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.Main()" />
 
74
      </Item>
 
75
      <Item>
 
76
        <Thread
 
77
          Callstack="{static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
 
78
          CurrentExceptionType="0"
 
79
          IsAtSafePoint="True"
 
80
          IsInValidState="True"
 
81
          MostRecentStackFrame="static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
 
82
          Name="Worker thread"
 
83
          Priority="Normal"
 
84
          RuntimeValue="{System.Threading.Thread}" />
 
85
      </Item>
 
86
    </ThreadsBeforeExit>
 
87
    <DebuggingPaused>ForcedBreak ControlFlow_MainThreadExit.cs:25,4-25,26</DebuggingPaused>
 
88
    <ThreadsAfterExit
 
89
      Count="2"
 
90
      Selected="Thread Name = Worker thread Suspended = False">
 
91
      <Item>
 
92
        <Thread
 
93
          CurrentExceptionType="0"
 
94
          Name=""
 
95
          Priority="Normal"
 
96
          RuntimeValue="{Exception: The state of the thread is invalid. (Exception from HRESULT: 0x8013132D)}" />
 
97
      </Item>
 
98
      <Item>
 
99
        <Thread
 
100
          Callstack="{static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext), Boolean System.Threading.WaitHandle.WaitOne(), static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime(), static void System.Threading.ThreadHelper.ThreadStart_Context(Object state), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx), static void System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state), void System.Threading.ThreadHelper.ThreadStart()}"
 
101
          CurrentExceptionType="0"
 
102
          IsAtSafePoint="True"
 
103
          IsInValidState="True"
 
104
          MostRecentStackFrame="static Boolean System.Threading.WaitHandle.InternalWaitOne(SafeHandle waitableSafeHandle, Int64 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)"
 
105
          Name="Worker thread"
 
106
          Priority="Normal"
 
107
          RuntimeValue="{System.Threading.Thread}"
 
108
          SelectedStackFrame="static void Debugger.Tests.ControlFlow_MainThreadExit.WaitForALongTime()" />
 
109
      </Item>
 
110
    </ThreadsAfterExit>
 
111
    <ProcessExited />
 
112
  </Test>
 
113
</DebuggerTests>
 
114
#endif // EXPECTED_OUTPUT