예제 #1
0
        public static void WasExit()
        {
            bool wasExited     = false;
            int? exitCode      = null;
            bool wasTerminated = false;

            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited"))
                {
                    wasExited = true;
                    ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON);
                    exitCode = exitedEvent.body.exitCode;
                }
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated"))
                {
                    wasTerminated = true;
                }
                if (wasExited && exitCode == 0 && wasTerminated)
                {
                    return(true);
                }

                return(false);
            };

            if (!VSCodeDebugger.IsEventReceived(filter))
            {
                throw new NetcoreDbgTestCore.ResultNotSuccessException();
            }
        }
예제 #2
0
        public void WasExit(string caller_trace)
        {
            bool wasExited     = false;
            int? exitCode      = null;
            bool wasTerminated = false;

            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited"))
                {
                    wasExited = true;
                    ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON);
                    exitCode = exitedEvent.body.exitCode;
                }
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated"))
                {
                    wasTerminated = true;
                }
                if (wasExited && exitCode == 0 && wasTerminated)
                {
                    return(true);
                }

                return(false);
            };

            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #3
0
        public void WasExit(string caller_trace)
        {
            bool wasExited     = false;
            bool wasTerminated = false;

            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited"))
                {
                    wasExited = true;
                    ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON);
                }
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated"))
                {
                    wasTerminated = true;
                }
                // we don't check exit code here, since Windows and Linux provide different exit code in case of unhandled exception
                if (wasExited && wasTerminated)
                {
                    return(true);
                }

                return(false);
            };

            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #4
0
        public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excMode, string excName, string extFrame)
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "exception"))
                {
                    threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));
                    return(true);
                }
                return(false);
            };

            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);

            StackTraceRequest stackTraceRequest = new StackTraceRequest();

            stackTraceRequest.arguments.threadId   = threadId;
            stackTraceRequest.arguments.startFrame = 0;
            stackTraceRequest.arguments.levels     = 20;
            var ret = VSCodeDebugger.Request(stackTraceRequest);

            Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace);

            StackTraceResponse stackTraceResponse =
                JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr);

            if (stackTraceResponse.body.stackFrames[0].name == extFrame)
            {
                TestExceptionInfo(@"__FILE__:__LINE__" + "\n" + caller_trace, excCategory, excMode, excName);
                return;
            }

            throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #5
0
        public static void WasExit()
        {
            bool wasExited     = false;
            int? exitCode      = null;
            bool wasTerminated = false;

            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited"))
                {
                    wasExited = true;
                    ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON);
                    exitCode = exitedEvent.body.exitCode;
                }
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated"))
                {
                    wasTerminated = true;
                }
                // we don't check exit code here, since Windows and Linux provide different exit code in case of "disconnectRequest" usage
                if (wasExited && wasTerminated)
                {
                    return(true);
                }

                return(false);
            };

            if (!VSCodeDebugger.IsEventReceived(filter))
            {
                throw new NetcoreDbgTestCore.ResultNotSuccessException();
            }
        }
예제 #6
0
        public void WasPaused(string caller_trace)
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause"))
                {
                    return(true);
                }
                return(false);
            };

            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #7
0
        public void WasEntryPointHit(string caller_trace)
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry"))
                {
                    threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));
                    return(true);
                }
                return(false);
            };

            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #8
0
        public static void WasStopped(string Reason, Breakpoint breakpoint)
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", Reason))
                {
                    if (Reason == "breakpoint")
                    {
                        threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));
                    }

                    return(true);
                }
                return(false);
            };

            if (!VSCodeDebugger.IsEventReceived(filter))
            {
                throw new NetcoreDbgTestCore.ResultNotSuccessException();
            }

            StackTraceRequest stackTraceRequest = new StackTraceRequest();

            stackTraceRequest.arguments.threadId   = threadId;
            stackTraceRequest.arguments.startFrame = 0;
            stackTraceRequest.arguments.levels     = 20;
            var ret = VSCodeDebugger.Request(stackTraceRequest);

            Assert.True(ret.Success);

            Assert.Equal(BreakpointType.Line, breakpoint.Type);
            var lbp = (LineBreakpoint)breakpoint;

            StackTraceResponse stackTraceResponse =
                JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr);

            foreach (var Frame in stackTraceResponse.body.stackFrames)
            {
                if (Frame.line == lbp.NumLine &&
                    Frame.source.name == lbp.FileName
                    // NOTE this code works only with one source file
                    && Frame.source.path == DebuggeeInfo.SourceFilesPath)
                {
                    return;
                }
            }

            throw new NetcoreDbgTestCore.ResultNotSuccessException();
        }
예제 #9
0
        public void WasBreakpointHitWithProperThreadID(string caller_trace, string bpName)
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "breakpoint"))
                {
                    threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));
                    return(true);
                }
                return(false);
            };

            threadId = -1;
            Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace);

            Assert.True(isThredInThreadsList(@"__FILE__:__LINE__" + "\n" + caller_trace, threadId),
                        @"__FILE__:__LINE__" + "\n" + caller_trace);

            StackTraceRequest stackTraceRequest = new StackTraceRequest();

            stackTraceRequest.arguments.threadId   = threadId;
            stackTraceRequest.arguments.startFrame = 0;
            stackTraceRequest.arguments.levels     = 20;
            var ret = VSCodeDebugger.Request(stackTraceRequest);

            Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace);

            Breakpoint breakpoint = ControlInfo.Breakpoints[bpName];

            Assert.Equal(BreakpointType.Line, breakpoint.Type, @"__FILE__:__LINE__" + "\n" + caller_trace);
            var lbp = (LineBreakpoint)breakpoint;

            StackTraceResponse stackTraceResponse =
                JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr);

            foreach (var Frame in stackTraceResponse.body.stackFrames)
            {
                if (Frame.line == lbp.NumLine &&
                    Frame.source.name == lbp.FileName
                    // NOTE this code works only with one source file
                    && Frame.source.path == ControlInfo.SourceFilesPath)
                {
                    return;
                }
            }

            throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace);
        }
예제 #10
0
        public static void WasPaused()
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause"))
                {
                    return(true);
                }
                return(false);
            };

            if (!VSCodeDebugger.IsEventReceived(filter))
            {
                throw new NetcoreDbgTestCore.ResultNotSuccessException();
            }
        }
예제 #11
0
        public static void WasEntryPointHit()
        {
            Func <string, bool> filter = (resJSON) => {
                if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") &&
                    VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry"))
                {
                    threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId"));
                    return(true);
                }
                return(false);
            };

            if (!VSCodeDebugger.IsEventReceived(filter))
            {
                throw new NetcoreDbgTestCore.ResultNotSuccessException();
            }
        }