コード例 #1
0
        public TargetEventArgs AssertTargetEvent(Thread thread, TargetEventType type)
        {
            DebuggerEvent e = AssertEvent();

            if (e.Type != DebuggerEventType.TargetEvent)
            {
                Assert.Fail("Received event {0}, but expected {1}.", e, type);
            }

            if ((thread != null) && (e.Data != thread))
            {
                Assert.Fail("Received event {0} while waiting for {1} in thread {2}.",
                            e, type, thread);
            }

            TargetEventArgs args = (TargetEventArgs)e.Data2;

            if (args.Type != type)
            {
                Assert.Fail("Received event {0} while waiting for {1} in thread {2}.",
                            e, type, thread);
            }

            return(args);
        }
コード例 #2
0
        public void AssertTargetExited()
        {
            while (true)
            {
                DebuggerEvent e = Interpreter.Wait();
                if (e == null)
                {
                    Assert.Fail("Time-out while waiting for target to exit.");
                }

                if (e.Type == DebuggerEventType.TargetExited)
                {
                    break;
                }
                else if ((e.Type == DebuggerEventType.ThreadExited) ||
                         (e.Type == DebuggerEventType.ProcessExited))
                {
                    continue;
                }
                else if (e.Type == DebuggerEventType.TargetEvent)
                {
                    TargetEventArgs args = (TargetEventArgs)e.Data2;
                    if ((args.Type == TargetEventType.TargetExited) ||
                        (args.Type == TargetEventType.TargetSignaled))
                    {
                        continue;
                    }
                }

                Assert.Fail("Received event {0} while waiting for target to exit.", e);
            }

            AssertNoTargetOutput();
        }
コード例 #3
0
        public Thread AssertProcessCreated()
        {
            AssertEvent(DebuggerEventType.ProcessCreated);
            DebuggerEvent ee = AssertEvent(DebuggerEventType.ThreadCreated);

            return((Thread)ee.Data);
        }
コード例 #4
0
 public void AssertNoEvent()
 {
     if (Interpreter.HasEvent)
     {
         DebuggerEvent e = Interpreter.Wait();
         Assert.Fail("Received unexpected event {0}.", e);
     }
 }
コード例 #5
0
 internal void AddEvent(DebuggerEvent e)
 {
     Report.Debug(DebugFlags.NUnit, "ADD EVENT: {0}", e);
     lock (queue.SyncRoot) {
         queue.Enqueue(e);
         wait_event.Set();
     }
 }
コード例 #6
0
        private void AssertMainProcessCreated(Process process)
        {
            DebuggerEvent e    = AssertEvent(DebuggerEventType.MainProcessCreated);
            Process       main = (Process)e.Data;

            Assert.AreEqual(process, main,
                            "Created main process `{0}', but expected `{1}'.",
                            main, process);
        }
コード例 #7
0
        public void AssertNestedBreakState(Thread exp_thread, string exp_func, int exp_line)
        {
            bool seen_stopped = false, seen_enter = false;

            while (!seen_stopped || !seen_enter)
            {
                DebuggerEvent e = Interpreter.Wait();
                if (e == null)
                {
                    Assert.Fail("Time-out while waiting for nested break state.");
                }

                if (e.Type == DebuggerEventType.EnterNestedBreakState)
                {
                    if (e.Data != exp_thread)
                    {
                        Assert.Fail("Received event {0} while waiting for nested break state.", e);
                    }

                    seen_enter = true;
                }
                else if (e.Type == DebuggerEventType.TargetEvent)
                {
                    if (e.Data != exp_thread)
                    {
                        Assert.Fail("Received event {0} while waiting for nested break state.", e);
                    }

                    TargetEventArgs args = (TargetEventArgs)e.Data2;
                    if ((args.Type == TargetEventType.TargetStopped) && ((int)args.Data != 0))
                    {
                        Assert.Fail("Received event {0} while waiting for {1} to stop.",
                                    args, exp_thread);
                    }
                    else if ((args.Type != TargetEventType.TargetStopped) &&
                             (args.Type != TargetEventType.TargetHitBreakpoint) &&
                             (args.Type != TargetEventType.Exception) &&
                             (args.Type != TargetEventType.UnhandledException))
                    {
                        Assert.Fail("Received event {0} while waiting for {1} to stop.",
                                    args, exp_thread);
                    }

                    seen_stopped = true;
                }
                else
                {
                    Assert.Fail("Received event {0} while waiting for nested break state.", e);
                }
            }

            if (exp_func != null)
            {
                AssertFrame(exp_thread, exp_func, exp_line);
            }
        }
コード例 #8
0
        public void AssertProcessExited(Process exp_process)
        {
            DebuggerEvent e       = AssertEvent(DebuggerEventType.ProcessExited);
            Process       process = (Process)e.Data;

            if (process != exp_process)
            {
                Assert.Fail("Process {0} exited, but expected process {1} to exit.",
                            process.ID, exp_process.ID);
            }
        }
コード例 #9
0
        public DebuggerEvent AssertEvent(DebuggerEventType type)
        {
            DebuggerEvent e = AssertEvent();

            if (e.Type != type)
            {
                Assert.Fail("Received event {0}, but expected {1}.", e, type);
            }

            return(e);
        }
コード例 #10
0
        public DebuggerEvent AssertEvent()
        {
            DebuggerEvent e = Interpreter.Wait();

            if (e == null)
            {
                Assert.Fail("Time-out while waiting for debugger event.");
            }

            return(e);
        }
コード例 #11
0
 internal void AddEvent(DebuggerEvent e)
 {
     Report.Debug (DebugFlags.NUnit, "ADD EVENT: {0}", e);
     lock (queue.SyncRoot) {
         queue.Enqueue (e);
         wait_event.Set ();
     }
 }
コード例 #12
0
        public Thread AssertThreadCreated()
        {
            DebuggerEvent te = AssertEvent(DebuggerEventType.ThreadCreated);

            return((Thread)te.Data);
        }
コード例 #13
0
        public Process AssertMainProcessCreated()
        {
            DebuggerEvent e = AssertEvent(DebuggerEventType.MainProcessCreated);

            return((Process)e.Data);
        }
コード例 #14
0
        public void AssertTargetExited(Process process)
        {
            bool process_exited = false;
            bool target_exited  = false;
            bool target_event   = Interpreter.IgnoreThreadCreation;
            bool thread_exited  = Interpreter.IgnoreThreadCreation;

            while (true)
            {
                DebuggerEvent e = Interpreter.Wait();
                if (e == null)
                {
                    Assert.Fail("Time-out while waiting for target to exit.");
                }

                if (e.Type == DebuggerEventType.TargetExited)
                {
                    target_exited = true;
                    break;
                }
                else if (e.Type == DebuggerEventType.ThreadExited)
                {
                    if (e.Data == process.MainThread)
                    {
                        thread_exited = true;
                    }
                    continue;
                }
                else if (e.Type == DebuggerEventType.ProcessExited)
                {
                    if (e.Data == process)
                    {
                        process_exited = true;
                    }
                    continue;
                }
                else if (e.Type == DebuggerEventType.TargetEvent)
                {
                    TargetEventArgs args = (TargetEventArgs)e.Data2;
                    if ((args.Type == TargetEventType.TargetExited) ||
                        (args.Type == TargetEventType.TargetSignaled))
                    {
                        if (e.Data == process.MainThread)
                        {
                            target_event = true;
                        }
                        continue;
                    }
                }

                Assert.Fail("Received event {0} while waiting for target to exit.", e);
            }

            if (!target_event)
            {
                Assert.Fail("Did not receive `TargetEventType.TargetExited' event " +
                            "while waiting for target to exit.");
            }
            if (!process_exited)
            {
                Assert.Fail("Did not receive `ProcessExitedEvent' while waiting for " +
                            "target to exit.");
            }
            if (!thread_exited)
            {
                Assert.Fail("Did not receive `ThreadExitedEvent' while waiting for " +
                            "target to exit.");
            }
            if (!target_exited)
            {
                Assert.Fail("Did not receive `TargetExitedEvent' while waiting for " +
                            "target to exit.");
            }

            AssertNoTargetOutput();
        }