コード例 #1
0
        private ConstructedVendorSampleDirectory BuildOrLoadSampleDirectoryAndUpdateReportForFailedSamples(string sampleListFile, string SDKdir, RunMode mode, string specificSampleName)
        {
            Console.WriteLine($"Creating sample list...");
            ConstructedVendorSampleDirectory sampleDir = null;
            bool directoryMatches = false;

            if (File.Exists(sampleListFile) || File.Exists(sampleListFile + ".gz"))
            {
                sampleDir = XmlTools.LoadObject <ConstructedVendorSampleDirectory>(sampleListFile);
                if (sampleDir.SourceDirectory == SDKdir)
                {
                    directoryMatches = true;
                }
            }

            if (directoryMatches && (mode == RunMode.Release || mode == RunMode.SingleSample))
            {
                Console.WriteLine($"Loaded {sampleDir.Samples.Length} samples from cache");
                return(sampleDir);
            }

            VendorSampleFilter filter;

            if (!directoryMatches || mode != RunMode.Incremental)
            {
                filter = new VendorSampleFilter(null);
            }
            else
            {
                filter = new VendorSampleFilter(_Report);
            }

            if (!filter.IsEmpty)
            {
                var samples = ParseVendorSamples(SDKdir, filter);

                if (directoryMatches && mode == RunMode.Incremental)
                {
                    //We don't update the report yet, even if the samples were previously marked as 'parse failed'.
                    //This status will get overridden once the samples are tested.

                    Dictionary <VendorSampleID, VendorSample> newSampleDict = new Dictionary <VendorSampleID, VendorSample>();
                    foreach (var vs in samples.VendorSamples)
                    {
                        newSampleDict[new VendorSampleID(vs)] = vs;
                    }

                    for (int i = 0; i < sampleDir.Samples.Length; i++)
                    {
                        if (newSampleDict.TryGetValue(new VendorSampleID(sampleDir.Samples[i]), out var newSampleDefinition))
                        {
                            sampleDir.Samples[i] = newSampleDefinition;
                        }
                    }
                }
                else
                {
                    sampleDir = new ConstructedVendorSampleDirectory
                    {
                        SourceDirectory = SDKdir,
                        Samples         = samples.VendorSamples,
                    };
                }

                if (samples.FailedSamples != null)
                {
                    foreach (var fs in samples.FailedSamples)
                    {
                        StoreError(_Report.ProvideEntryForSample(fs.ID), fs.BuildLogFile, VendorSamplePass.InitialParse);
                    }
                }

                XmlTools.SaveObject(sampleDir, sampleListFile);
            }
            else if (sampleDir == null)
            {
                throw new Exception("Unexpected null sample directory");
            }

            return(sampleDir);
        }
コード例 #2
0
        private ConstructedVendorSampleDirectory BuildOrLoadSampleDirectoryAndUpdateReportForFailedSamples(string sampleListFile, string SDKdir, RunMode mode, string specificSampleName)
        {
            Console.WriteLine($"Creating sample list...");
            ConstructedVendorSampleDirectory sampleDir = null;
            bool directoryMatches = false;

            if (File.Exists(sampleListFile) || File.Exists(sampleListFile + ".gz"))
            {
                sampleDir = XmlTools.LoadObject <ConstructedVendorSampleDirectory>(sampleListFile);
                if (sampleDir.SourceDirectory == SDKdir)
                {
                    directoryMatches = true;
                }
            }

            if (directoryMatches && mode == RunMode.Release)
            {
                Console.WriteLine($"Loaded {sampleDir.Samples.Length} samples from cache");
                HashSet <string> blacklist = ParseBlacklistFile();
                sampleDir.Samples = sampleDir.Samples.Where(s => !blacklist.Contains(s.InternalUniqueID)).ToArray();
                return(sampleDir);
            }

            IVendorSampleFilter filter;

            if (mode == RunMode.SingleSample && sampleDir != null)
            {
                var existingSample = sampleDir.Samples.FirstOrDefault(s => s.InternalUniqueID == specificSampleName) ?? throw new Exception("Unknown sample specified via command line: " + specificSampleName);
                filter = new SingleSampleFilter(existingSample);
            }
            else if (!directoryMatches || mode != RunMode.Incremental || sampleDir == null)
            {
                filter = new VendorSampleFilter();
            }
            else
            {
                filter = new VendorSampleFilter(_Report, sampleDir.Samples);
            }

            if ((filter as VendorSampleFilter)?.IsEmpty != true)
            {
                var samples = ParseVendorSamples(SDKdir, filter);

                HashSet <string> blacklist = ParseBlacklistFile();
                samples.VendorSamples = samples.VendorSamples.Where(s => !blacklist.Contains(s.InternalUniqueID)).ToArray();

                if (directoryMatches && (mode == RunMode.Incremental || mode == RunMode.SingleSample))
                {
                    //We don't update the report yet, even if the samples were previously marked as 'parse failed'.
                    //This status will get overridden once the samples are tested.

                    Dictionary <string, VendorSample> newSampleDict = new Dictionary <string, VendorSample>();
                    foreach (var vs in samples.VendorSamples)
                    {
                        newSampleDict[vs.InternalUniqueID] = vs;
                    }

                    for (int i = 0; i < sampleDir.Samples.Length; i++)
                    {
                        if (newSampleDict.TryGetValue(sampleDir.Samples[i].InternalUniqueID, out var newSampleDefinition))
                        {
                            sampleDir.Samples[i] = newSampleDefinition;
                        }
                    }
                }
                else
                {
                    sampleDir = new ConstructedVendorSampleDirectory
                    {
                        SourceDirectory = SDKdir,
                        Samples         = samples.VendorSamples,
                    };
                }

                if (samples.FailedSamples != null)
                {
                    foreach (var fs in samples.FailedSamples)
                    {
                        StoreError(_Report.ProvideEntryForSample(fs.UniqueID), fs.BuildLogFile, VendorSamplePass.InitialParse);
                    }
                }

                XmlTools.SaveObject(sampleDir, sampleListFile);
            }
            else if (sampleDir == null)
            {
                throw new Exception("Unexpected null sample directory");
            }

            return(sampleDir);
        }