예제 #1
0
        protected PipTestBase(ITestOutputHelper output) : base(output)
        {
            Context = BuildXLContext.CreateInstanceForTesting();
            PathTable.DebugPathTable = Context.PathTable;

            TestBinRoot     = Path.GetDirectoryName(AssemblyHelper.GetAssemblyLocation(System.Reflection.Assembly.GetExecutingAssembly()));
            TestBinRootPath = AbsolutePath.Create(Context.PathTable, TestBinRoot);
            SourceRoot      = Path.Combine(TemporaryDirectory, SourceRootPrefix);
            SourceRootPath  = AbsolutePath.Create(Context.PathTable, SourceRoot);

            CmdExecutable = FileArtifact.CreateSourceFile(AbsolutePath.Create(Context.PathTable, CmdHelper.OsShellExe));

            string testProcessFolder = Path.Combine(TestBinRoot, "TestProcess");
            string platformDir       = Dispatch.CurrentOS().ToString();
            string exe = Path.Combine(testProcessFolder, platformDir, TestProcessToolName);

            TestProcessExecutable = FileArtifact.CreateSourceFile(AbsolutePath.Create(Context.PathTable, exe));

            // Test process depends on C://Windows (when running on Windows)
            TestProcessDependencies = OperatingSystemHelper.IsUnixOS
                ? new AbsolutePath[0]
                : new AbsolutePath[] { AbsolutePath.Create(Context.PathTable, Environment.GetFolderPath(Environment.SpecialFolder.Windows)) };

            ObjectRoot     = Path.Combine(TemporaryDirectory, ObjectRootPrefix);
            ObjectRootPath = AbsolutePath.Create(Context.PathTable, ObjectRoot);

            CacheRoot = Path.Combine(TemporaryDirectory, CacheRootPrefix);

            BaseSetup();
        }
예제 #2
0
        public void CoreDumpTest()
        {
            string dumpPath = Path.Combine(TemporaryDirectory, "core_dumps");

            Directory.CreateDirectory(dumpPath);

            var    testBinRoot       = Path.GetDirectoryName(AssemblyHelper.GetAssemblyLocation(System.Reflection.Assembly.GetExecutingAssembly()));
            string testProcessFolder = Path.Combine(testBinRoot, "TestProcess");
            string platformDir       = Dispatch.CurrentOS().ToString();
            string exe = Path.Combine(testProcessFolder, platformDir, "CoreDumpTester");

            var info = new ProcessStartInfo(exe)
            {
                WorkingDirectory       = Path.GetDirectoryName(exe),
                RedirectStandardOutput = true,
                Arguments       = dumpPath,
                UseShellExecute = false,
                CreateNoWindow  = true,
            };

            using (var process = Process.Start(info))
            {
                process.OutputDataReceived += new DataReceivedEventHandler((object sendingProcess, DataReceivedEventArgs outLine) =>
                {
                    var p = (Process)sendingProcess;
                    p.CancelOutputRead();

                    SendSignal(process.Id, SIG_ABRT);
                });

                process.BeginOutputReadLine();
                process.WaitForExit();

                XAssert.IsTrue(process.HasExited);

                var  pathToTidMappings = Path.Combine(dumpPath, "thread_tids");
                bool tidMappingsExist  = File.Exists(pathToTidMappings);
                XAssert.IsTrue(tidMappingsExist);

                var tidMappingsNotEmpty = new FileInfo(pathToTidMappings).Length > 0;
                XAssert.IsTrue(tidMappingsNotEmpty);
            }
        }