Esempio n. 1
0
        public string CreateBuildDirectory(VendorSamplePass pass)
        {
            string passSubdir;

            switch (pass)
            {
            case VendorSamplePass.InitialParse:
                passSubdir = "Initial";
                break;

            case VendorSamplePass.InPlaceBuild:
                passSubdir = "Pass1";
                break;

            case VendorSamplePass.RelocatedBuild:
                passSubdir = "Pass2";
                break;

            default:
                throw new Exception("Invalid test pass: " + pass);
            }

            string dir = Path.Combine(TestDirectory, BSP.BSP.PackageID, passSubdir);

            Directory.CreateDirectory(dir);
            return(dir);
        }
Esempio n. 2
0
        StandaloneBSPValidator.Program.TestStatistics TestVendorSamplesAndUpdateReportAndDependencies(VendorSample[] samples, string sampleDirPath, VendorSamplePass pass, Predicate <VendorSample> keepDirectoryAfterSuccessfulBuild = null, double testProbability = 1, BSPValidationFlags validationFlags = BSPValidationFlags.None)
        {
            Console.WriteLine($"Building {samples.Length} samples...");
            if (pass != VendorSamplePass.RelocatedBuild && pass != VendorSamplePass.InPlaceBuild)
            {
                throw new Exception("Invalid build pass: "******"test.log")))
            {
                foreach (var vs in samples)
                {
                    LoadedBSP.LoadedMCU mcu;
                    try
                    {
                        var rgFilterID = new Regex(vs.DeviceID.Replace('x', '.').Replace("_DEBUG", "").Replace("_MBR", "").Replace("_S132", "").Replace("_S140", ""), RegexOptions.IgnoreCase);
                        //We need to find the shortest MCU name that matches the mask (e.g. for CC3220S and CC3220SF we should pick CC3220S).
                        mcu         = BSP.MCUs.OrderBy(m => m.ExpandedMCU.ID.Length).Where(f => rgFilterID.IsMatch(f.ExpandedMCU.ID)).ToArray()?.First();
                        vs.DeviceID = mcu.ExpandedMCU.ID;
                    }
                    catch
                    {
                        logger.HandleError($"Could not find {vs.DeviceID} MCU  , Project: {vs.UserFriendlyName} ");
                        continue;
                    }

                    if (testProbability < 1 && rng.NextDouble() > testProbability)
                    {
                        samplesProcessed++;
                        continue;
                    }

                    VendorSampleTestReport.Record record = _Report.ProvideEntryForSample(new VendorSampleID(vs));

                    string   mcuDir = Path.Combine(outputDir, record.ID.ToString());
                    DateTime start  = DateTime.Now;

                    var thisSampleFlags = validationFlags;
                    if (keepDirectoryAfterSuccessfulBuild?.Invoke(vs) == true)
                    {
                        thisSampleFlags |= BSPValidationFlags.KeepDirectoryAfterSuccessfulTest;
                    }

                    var result = StandaloneBSPValidator.Program.TestVendorSampleAndUpdateDependencies(mcu, vs, mcuDir, sampleDirPath, CodeRequiresDebugInfoFlag, thisSampleFlags);
                    record.BuildDuration   = (int)(DateTime.Now - start).TotalMilliseconds;
                    record.TimeOfLastBuild = DateTime.Now;

                    if (result.Result != StandaloneBSPValidator.Program.TestBuildResult.Succeeded)
                    {
                        StoreError(record, result.LogFile, pass);
                        samplesFailed++;
                    }
                    else
                    {
                        record.BuildFailedExplicitly = false;
                        record.LastSucceededPass     = pass;
                    }

                    logger.LogSampleResult(record);
                    samplesProcessed++;

                    var timePerSample = (DateTime.Now - passStartTime).TotalMilliseconds / samplesProcessed;

                    string displayedSampleName = record.ID.ToString();
                    int    maxNameLength       = 50;
                    if (displayedSampleName.Length > maxNameLength)
                    {
                        displayedSampleName = displayedSampleName.Substring(0, maxNameLength - 3) + "...";
                    }

                    List <KeyValuePair <string, string> > fields = new List <KeyValuePair <string, string> >();
                    fields.Add(new KeyValuePair <string, string>("Pass:"******"Current sample:", displayedSampleName));
                    fields.Add(new KeyValuePair <string, string>("Samples processed:", $"{samplesProcessed}/{sampleCount}"));
                    fields.Add(new KeyValuePair <string, string>("Average time per sample:", $"{timePerSample:f0} msec"));
                    fields.Add(new KeyValuePair <string, string>("Failed samples:", $"{samplesFailed}"));
                    var remainingTime = TimeSpan.FromMilliseconds(timePerSample * (sampleCount - samplesProcessed));

                    fields.Add(new KeyValuePair <string, string>("ETA:", $"{remainingTime.Hours:d}:{remainingTime.Minutes:d2}:{remainingTime.Seconds:d2}"));

                    Console.SetCursorPosition(0, line);
                    OutputKeyValueList(fields);

                    int maxWidth      = Console.WindowWidth - 2;
                    int progressWidth = (int)((double)maxWidth * samplesProcessed) / sampleCount;
                    Console.WriteLine("[" + new string('#', progressWidth).PadRight(maxWidth) + "]");
                }
            }

            return(new StandaloneBSPValidator.Program.TestStatistics {
                Passed = sampleCount - samplesFailed, Failed = samplesFailed
            });
        }
Esempio n. 3
0
        private void StoreError(VendorSampleTestReport.Record record, string buildLogFile, VendorSamplePass pass)
        {
            var prevPass = pass - 1;

            if (record.LastSucceededPass > prevPass)
            {
                record.LastSucceededPass = prevPass;
            }

            record.BuildFailedExplicitly = true;
            record.KnownProblemID        = _KnownProblems.TryClassifyError(buildLogFile)?.ID;
        }