private int ByCpuTimeDecreasing(VerificationResult va, VerificationResult vb)
 {
     return -(va.cpuTime.CompareTo(vb.cpuTime));
 }
        public override IVerbWorker getWorker(WorkingDirectory workingDirectory)
        {
            // Read and aggregate all the input results.
            int parseFailures = 0;
            int verificationFailures = 0;
            int timeouts = 0;
            int filesWithParseFailures = 0;
            int filesWithVerificationFailures = 0;
            int filesWithTimeouts = 0;
            int passCount = 0;
            int failCount = 0;
            double cpuTime = 0;
            List<VerificationMessage> failMessages = new List<VerificationMessage>();
            List<VerificationResult> results = new List<VerificationResult>();

            // REVIEW: Why pull out the enumerator this way?
            IEnumerable<BuildObject> verificationResultsEnumerator = this.verificationResults;
            foreach (BuildObject verificationResult in verificationResultsEnumerator)
            {
                VerificationResult vr = VerificationResult.fromXmlFile(verificationResult);
                results.Add(vr);
                if (vr == null)
                {
                    return new VerbSyncWorker(
                        workingDirectory,
                        new Failed("Build system broke: missing VerificationResult for " + verificationResult));
                }

                if (vr.pass)
                {
                    passCount += 1;
                }
                else
                {
                    failCount += 1;
                    failMessages.AddRange(vr.getMessages());
                }

                parseFailures += vr.parseFailures;
                verificationFailures += vr.verificationFailures;
                timeouts += vr.timeouts;
                filesWithParseFailures += vr.parseFailures > 0 ? 1 : 0;
                filesWithVerificationFailures += vr.verificationFailures > 0 ? 1 : 0;
                filesWithTimeouts += vr.timeouts > 0 ? 1 : 0;
                ////Logger.WriteLine("Synthesizing cpuTime from " + verificationResult);
                cpuTime += vr.cpuTime;
            }

            bool allPass = failCount == 0;

            PresentationBuilder pr = new PresentationBuilder();

            int any_failures = parseFailures + verificationFailures + timeouts;
            string overall_status = any_failures > 0 ? "Fail" : "Success";

            pr.pre(VerificationResult._VERIFICATION_RESULT_PLACEHOLDER+"\n");
            pr.spacer();
            pr.startHeader();
            pr.color(this.colorByFailureCount(any_failures), "Overall status: " + overall_status);
            pr.endHeader();
            pr.line("Count of files with failures: " + failCount);
            pr.startBullet();
            pr.color(this.colorByFailureCount(filesWithParseFailures), "Files with parse failures: " + filesWithParseFailures.ToString());
            pr.endBullet();
            pr.startBullet();
            pr.color(this.colorByFailureCount(filesWithVerificationFailures), "Files with verification failures: " + filesWithVerificationFailures.ToString());
            pr.endBullet();
            pr.startBullet();
            pr.color(this.colorByFailureCount(filesWithTimeouts), "Files with timeouts: " + filesWithTimeouts.ToString());
            pr.endBullet();

            pr.spacer();
            pr.header(string.Format("Total processing time: {0:0.0}s {1}", cpuTime, new TimeSpan((long)(cpuTime * 10000000L))));
            int top_n = 10;
            pr.header(string.Format("Slowest {0} verifications:", top_n));

            results.Sort(this.ByCpuTimeDecreasing);
            foreach (VerificationResult slowResult in results.Take(top_n))
            {
                pr.startBullet();
                pr.color(
                    this.colorByFailureCount(slowResult.pass ? 0 : 1),
                    string.Format("{0,6:##0.0}s {1}", slowResult.cpuTime, slowResult.sourceLabel));
                pr.endBullet();
            }

            foreach (VerificationMessage message in failMessages)
            {
                pr.spacer();
                pr.header("Failure with " + message.SourceLabel);
                pr.pre(message.Message);
            }

            Presentation pres = pr.fix();

            VerificationResult outvr = new VerificationResult("summary", allPass, cpuTime, parseFailures, verificationFailures, timeouts, failMessages);
            outvr.addXmlFiller(pres);
            outvr.toXmlFile(workingDirectory.PathTo(this.outputObject));
            this.setWasRejectableFailure(!outvr.pass);
            return new VerbSyncWorker(workingDirectory, new Fresh());
        }
Exemplo n.º 3
0
        public static VerificationResult readXml(XmlReader xr)
        {
            Util.Assert(xr.Name.Equals(_xml_tag));
            VerificationResult rc = new VerificationResult();
            rc._sourceLabel = xr.GetAttribute(_xml_sourcePath_attr);
            string outcome = xr.GetAttribute(_xml_outcome_attr);
            if (outcome.Equals(PASS))
            {
                rc._pass = true;
            }
            else if (outcome.Equals(FAIL))
            {
                rc._pass = false;
            }
            else
            {
                throw new Exception("Invalid outcome value " + outcome);
            }

            rc._cpuTime = Double.Parse(xr.GetAttribute(_xml_cputime_attr));
            rc._parseFailures = Int32.Parse(xr.GetAttribute(_xml_parseFailures_attr));
            rc._verificationFailures = Int32.Parse(xr.GetAttribute(_xml_verificationFailures_attr));
            rc._timeouts = Int32.Parse(xr.GetAttribute(_xml_timeouts_attr));
            rc.messages = new List<VerificationMessage>();

            while (xr.Read())
            {
                if (xr.NodeType == XmlNodeType.EndElement)
                {
                    Util.Assert(xr.Name.Equals(_xml_tag));
                    break;
                }
                else if (xr.NodeType == XmlNodeType.Element)
                {
                    if (xr.Name.Equals(VerificationMessage._xml_tag))
                    {
                        rc.messages.Add(VerificationMessage.ReadXml(xr));
                    }
                    else if (xr.Name.Equals(Presentation._xml_tag))
                    {
                        rc._presentation = Presentation.fromXml(xr.ReadSubtree());
                    }
                    else
                    {
                        throw new Exception("Unknown xml tag " + xr.Name);
                    }
                }
            }

            return rc;
        }
Exemplo n.º 4
0
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     VerificationResult vr = new VerificationResult(
         bplInput.getRelativePath(),
         cpuTimeSeconds,
         stdout,
         stderr,
         new VerificationResultBoogieParser());
     vr.addBasicPresentation();
     vr.toXmlFile(workingDirectory.PathTo(getOutputFile()));
     setWasRejectableFailure(vr.wasOnlyTimeouts());
     return disposition;
 }
Exemplo n.º 5
0
 public Disposition Complete(WorkingDirectory workingDirectory, double cpuTimeSeconds, string stdout, string stderr, Disposition disposition)
 {
     VerificationResult vr = new VerificationResult(
         this.dfysource.getRelativePath(),
         cpuTimeSeconds,
         stdout,
         stderr,
         new VerificationResultDafnyParser());
     vr.addBasicPresentation();
     vr.toXmlFile(workingDirectory.PathTo(this.getOutputFile()));
     this.setWasRejectableFailure(!vr.pass);
     return disposition;
 }