Exemplo n.º 1
0
        protected override void OnBeforeStarted(DebugeeProcess debugee)
        {
            string profilerDest = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(TestEngine).Assembly.Location), RTIASrcFolder));

            Trace.TraceInformation("profilerDest: {0}", profilerDest);

            var hostEnvironment = new Dictionary <string, string>
            {
                //{ "MicrosoftInstrumentationEngine_DebugWait", "true"},
                { "COR_ENABLE_PROFILING", "1" },
                { "COR_PROFILER", InstrumentationEngineProfilerId },
                { "COR_PROFILER_PATH", GetFullPath(InstrumentationEngineProfilerModuleName) },
                { "MicrosoftInstrumentationEngine_FileLog", "Dumps|Errors" },
                { "MicrosoftInstrumentationEngine_FileLogPath", traceFilePath }
#if ALLOWNOTSIGNED
                , { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "true" }
#endif
            };

            hostEnvironment.Add(
                "MicrosoftInstrumentationEngine_RawProfilerHook",
                RawProfilerHookComponentId);

            hostEnvironment.Add(
                "MicrosoftInstrumentationEngine_RawProfilerHookPath", GetFullPath(RawProfilerHookModuleName));

            foreach (var variable in hostEnvironment)
            {
                debugee.StartInfo.EnvironmentVariables.Add(variable.Key, variable.Value);
            }
        }
Exemplo n.º 2
0
        protected override void OnBeforeStarted(DebugeeProcess debugee)
        {
            var vars = debugee.StartInfo.EnvironmentVariables;

            vars.Add("COR_ENABLE_PROFILING", "1");
            vars.Add("COR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}");
            vars.Add("COR_PROFILER_PATH", GetFullPath(InstrumentationEngineProfilerModuleName));

            vars.Add("MicrosoftInstrumentationEngine_FileLog", "Dumps|Errors");
            //vars.Add("MicrosoftInstrumentationEngine_FileLogPath", ""); //can be overridden if needed

#if ALLOWNOTSIGNED
            vars.Add("MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "true");
#endif
        }
        protected override void OnBeforeStarted(DebugeeProcess debugee)
        {
            string profilerDest = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(typeof(TestEngine).Assembly.Location), ProfilerSrcFolder));

            Trace.TraceInformation("profilerDest: {0}", profilerDest);

            var hostEnvironment = new Dictionary <string, string>
            {
                // { "MicrosoftInstrumentationEngine_DebugWait", "1" }, // Attach native debugger to RemoteUnitTestExecutor.Host_x86|64.exe which spawns once this function finishes
                { "COR_ENABLE_PROFILING", "1" },
                { "COR_PROFILER", InstrumentationEngineProfilerId },
                { RawProfilerHookEnvVar, RawProfilerHookComponentId },
                { "MicrosoftInstrumentationEngine_FileLog", "Dumps|Errors" },
                { "MicrosoftInstrumentationEngine_FileLogPath", traceFilePath }
#if ALLOWNOTSIGNED
                , { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "true" }
#endif
            };

            if (IgnoreBitness)
            {
                hostEnvironment.Add(
                    InstrumentationEngineNoBitnessEnvVar,
                    GetFullPath(InstrumentationEngineProfilerModuleName));

                hostEnvironment.Add(
                    RawProfilerHookPathNoBitnessEnvVar,
                    GetFullPath(RawProfilerHookModuleName));
            }
            else
            {
                hostEnvironment.Add(
                    InstrumentationEngineEnvVar,
                    GetFullPath(InstrumentationEngineProfilerModuleName));

                hostEnvironment.Add(
                    RawProfilerHookPathEnvVar,
                    GetFullPath(RawProfilerHookModuleName));
            }

            foreach (var variable in hostEnvironment)
            {
                debugee.StartInfo.EnvironmentVariables.Add(variable.Key, variable.Value);
            }
        }
Exemplo n.º 4
0
        protected override void OnComplete(DebugeeProcess debugee, string[] expectedErrors = null)
        {
            string errors = string.Empty;

            try
            {
                if (File.Exists(traceFilePath))
                {
                    bool readOk        = false;
                    int  attemptsCount = 3;
                    while (attemptsCount > 0 && !readOk)
                    {
                        --attemptsCount;
                        try
                        {
                            using (var traceFile = new StreamReader(traceFilePath))
                            {
                                while (!traceFile.EndOfStream)
                                {
                                    string traceLine = traceFile.ReadLine();
                                    if (traceLine.StartsWith("LogError"))
                                    {
                                        errors += traceLine + "\r\n";
                                    }
                                    if (traceLine.Length != 0 &&
                                        !traceLine.StartsWith("[TestIgnore]"))
                                    {
                                        Trace.WriteLine(traceLine);
                                    }
                                }
                                readOk = true;
                            }
                        }
                        catch (Exception)
                        {
                            //retry
                            Thread.Sleep(1000);
                        }
                    }
                }
            }
            catch (Exception)
            {
                //Do nothing
            }

            if (!string.IsNullOrEmpty(errors))
            {
                if (expectedErrors != null)
                {
                    var actualErrors = errors.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

                    var testFailureDescription = new StringBuilder();

                    Assert.AreEqual(expectedErrors.Length, actualErrors.Length, "unexpected errors: " + errors);
                    for (int i = 0; i < actualErrors.Length; i++)
                    {
                        if (!actualErrors[i].Contains(expectedErrors[i]))
                        {
                            testFailureDescription.AppendLine("Expected to contain :");
                            testFailureDescription.AppendLine(expectedErrors[i]);

                            testFailureDescription.AppendLine("Actual content:");
                            testFailureDescription.AppendLine(actualErrors[i]);
                        }
                    }

                    if (0 != testFailureDescription.Length)
                    {
                        Assert.Fail(
                            "Unexpected errors detected:" + Environment.NewLine + testFailureDescription);
                    }
                }
                else
                {
                    Assert.Fail("Unexpected errors detected: " + errors);
                }
            }
        }
Exemplo n.º 5
0
 protected override void OnComplete(DebugeeProcess debugee, string[] expectedErrors = null)
 {
 }
Exemplo n.º 6
0
 protected override void OnStarted(DebugeeProcess debugee)
 {
 }