示例#1
0
        public void ReadRaceEventLoggedOnViolationDistributed()
        {
            BuildXLContext context  = BuildXLContext.CreateInstanceForTesting();
            var            graph    = new QueryablePipDependencyGraph(context);
            var            analyzer = new FileMonitoringViolationAnalyzer(LoggingContext, context, graph, new QueryableEmptyFileContentManager(), validateDistribution: true, ignoreDynamicWritesOnAbsentProbes: false, unexpectedFileAccessesAsErrors: true);

            AbsolutePath violatorOutput = CreateAbsolutePath(context, JunkPath);
            AbsolutePath producerOutput = CreateAbsolutePath(context, ProducedPath);

            Process producer = graph.AddProcess(producerOutput);
            Process violator = graph.AddProcess(violatorOutput);

            graph.SetConcurrentRange(producer, violator);

            AnalyzePipViolationsResult analyzePipViolationsResult =
                analyzer.AnalyzePipViolations(
                    violator,
                    new[] { CreateViolation(RequestedAccess.Read, producerOutput) },
                    null, // whitelisted accesses
                    exclusiveOpaqueDirectoryContent: null,
                    sharedOpaqueDirectoryWriteAccesses: null,
                    allowedUndeclaredReads: null,
                    absentPathProbesUnderOutputDirectories: null);

            AssertTrue(!analyzePipViolationsResult.IsViolationClean);
            AssertErrorEventLogged(EventId.FileMonitoringError);
            AssertVerboseEventLogged(LogEventId.DependencyViolationReadRace);
        }
示例#2
0
        public void DoubleWriteEventLoggedOnViolationError()
        {
            BuildXLContext context  = BuildXLContext.CreateInstanceForTesting();
            var            graph    = new QueryablePipDependencyGraph(context);
            var            analyzer = new FileMonitoringViolationAnalyzer(LoggingContext, context, graph, new QueryableEmptyFileContentManager(), validateDistribution: false, ignoreDynamicWritesOnAbsentProbes: false, unexpectedFileAccessesAsErrors: true);

            AbsolutePath violatorOutput = CreateAbsolutePath(context, JunkPath);
            AbsolutePath producerOutput = CreateAbsolutePath(context, DoubleWritePath);

            Process producer = graph.AddProcess(producerOutput);
            Process violator = graph.AddProcess(violatorOutput);

            analyzer.AnalyzePipViolations(
                violator,
                new[] { CreateViolation(RequestedAccess.ReadWrite, producerOutput) },
                new ReportedFileAccess[0],
                exclusiveOpaqueDirectoryContent: null,
                sharedOpaqueDirectoryWriteAccesses: null,
                allowedUndeclaredReads: null,
                absentPathProbesUnderOutputDirectories: null,
                ReadOnlyArray <(FileArtifact, FileMaterializationInfo, PipOutputOrigin)> .Empty,
                out _);

            AssertVerboseEventLogged(LogEventId.DependencyViolationDoubleWrite);
            AssertErrorEventLogged(EventId.FileMonitoringError);
        }