Revision: 521 http://cishell.svn.sourceforge.net/cishell/?rev=521&view=rev Author: mwlinnem Date: 2007-09-13 11:47:33 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Added error analysis to all errors report, which infers the most likely sources of each error. Modified Paths: -------------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSource.java trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSourceAnalyzer.java Modified: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java 2007-09-12 18:19:29 UTC (rev 520) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/AllErrorReportGenerator.java 2007-09-13 18:47:33 UTC (rev 521) @@ -14,6 +14,9 @@ import org.cishell.testing.convertertester.core.converter.graph.Converter; import org.cishell.testing.convertertester.core.tester2.reportgen.ReportGenerator; +import org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer.DefaultErrorSourceAnalyzer; +import org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer.ErrorSource; +import org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer.ErrorSourceAnalyzer; import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFault; import org.cishell.testing.convertertester.core.tester2.reportgen.reports.AllErrorReport; import org.cishell.testing.convertertester.core.tester2.reportgen.results.AllConvsResult; @@ -30,6 +33,8 @@ private LogService log; private AllErrorReport allErrorsReport; + private ErrorSourceAnalyzer errSourceAnalyzer = + new DefaultErrorSourceAnalyzer(); public AllErrorReportGenerator(LogService log) { this.log = log; @@ -69,6 +74,48 @@ List CafsWithSameExpln = (List) explnToCafs.get(expln); Map testToPassesToCafs = categorizeByTestAndPass(CafsWithSameExpln); + + ErrorSource[] errSources = + this.errSourceAnalyzer.analyze(testToPassesToCafs); + + report.println("--Error Source Analysis Summary--"); + + for (int jj = 0; jj < errSources.length; jj++) { + ErrorSource errSource = errSources[jj]; + + report.println(""); + + ChanceAtFault[] overallCafs = errSource.getCulprits(); + + if (overallCafs.length > 0) { + report.println(errSource.getComment()); + + Arrays.sort(overallCafs, + ChanceAtFault.COMPARE_BY_LIKELIHOOD); + + for (int kk = 0; kk < overallCafs.length; kk++) { + ChanceAtFault caf = overallCafs[kk]; + + report.println(caf.getConverter() + " (%" + + FormatUtil. + formatToPercent( + caf.getChanceAtFault()) + + " Chance At Fault)"); + } + + report.println(""); + + } else { + report.println("There is no converter common to all " + + "failed file passes with this error."); + report.println("This most likely means that there is " + + "more than one source that returns this error" + + " message."); + report.println(""); + } + } + report.println("--All Error Sources--"); + Set tests = testToPassesToCafs.keySet(); Iterator testIter = tests.iterator(); Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/DefaultErrorSourceAnalyzer.java 2007-09-13 18:47:33 UTC (rev 521) @@ -0,0 +1,121 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFault; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.FilePassResult; +import org.cishell.testing.convertertester.core.tester2.reportgen.results.TestResult; + +public class DefaultErrorSourceAnalyzer implements ErrorSourceAnalyzer { + + public ErrorSource[] analyze(Map testToPassesToCafs) { + + PotentialCulpritList potentialCulprits = new PotentialCulpritList(); + + Set tests = testToPassesToCafs.keySet(); + + Iterator testIter = tests.iterator(); + while (testIter.hasNext()) { + TestResult test = (TestResult) testIter.next(); + + Map passToCafs + = (Map) testToPassesToCafs.get(test); + + Set passes = passToCafs.keySet(); + Iterator passIter = passes.iterator(); + while (passIter.hasNext()) { + FilePassResult pass = (FilePassResult) passIter.next(); + + List cafList = (List) passToCafs.get(pass); + ChanceAtFault[] cafs = + (ChanceAtFault[]) cafList.toArray(new ChanceAtFault[0]); + + potentialCulprits.merge(cafs); + } + } + + ErrorSource onlyErrorSource = new ErrorSource( + "Assuming the error has only one source, the following " + + "converters are most likely to be that source.", + potentialCulprits.getCulprits()); + + return new ErrorSource[] {onlyErrorSource}; + } + + private class PotentialCulpritList { + private List pcs; + + public void merge(ChanceAtFault[] otherPCs) { + if (this.pcs != null) { + //set potential culprits to be intersection of + //new potential culprits and old. + List newPCs = new ArrayList(); + + for (int ii = 0; ii < this.pcs.size(); ii++) { + ChanceAtFault pc = (ChanceAtFault) this.pcs.get(ii); + + for (int jj = 0; jj < otherPCs.length; jj++) { + ChanceAtFault otherPC = otherPCs[jj]; + + if (pc.getConverter() == otherPC.getConverter() + && otherPC.getChanceAtFault() > 0.0f) { + + ChanceAtFault newPC = new ChanceAtFault(pc + .getFailedFilePass(), pc.getConverter(), pc + .getChanceAtFault() + + otherPC.getChanceAtFault()); + + newPCs.add(pc); + + break; + } + } + } + + this.pcs = newPCs; + + } else { + //add all chance at faults > 0.0f to potential culprit list + List newPCs = new ArrayList(); + for (int ii = 0; ii < otherPCs.length; ii++) { + ChanceAtFault pc = (ChanceAtFault) otherPCs[ii]; + + if (pc.getChanceAtFault() > 0.0f) { + newPCs.add(pc); + } + } + + this.pcs = newPCs; + } + } + + public ChanceAtFault[] getCulprits() { + //normalize chance at faults + float totalChanceAtFaults = 0.0f; + for (int ii = 0; ii < pcs.size(); ii++) { + ChanceAtFault pc = (ChanceAtFault) pcs.get(ii); + + totalChanceAtFaults += pc.getChanceAtFault(); + } + + List normalizedCafs = new ArrayList(); + for (int ii = 0; ii < pcs.size(); ii++) { + ChanceAtFault pc = (ChanceAtFault) pcs.get(ii); + + ChanceAtFault normPC = new ChanceAtFault( + pc.getFailedFilePass(), + pc.getConverter(), + pc.getChanceAtFault() / totalChanceAtFaults); + + normalizedCafs.add(normPC); + } + + return (ChanceAtFault[]) + normalizedCafs.toArray(new ChanceAtFault[0]); + } + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSource.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSource.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSource.java 2007-09-13 18:47:33 UTC (rev 521) @@ -0,0 +1,22 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer; + +import org.cishell.testing.convertertester.core.tester2.reportgen.faultanalysis.ChanceAtFault; + +public class ErrorSource { + + private String comment; + private ChanceAtFault[] cafs; + + public ErrorSource(String comment, ChanceAtFault[] cafs) { + this.comment = comment; + this.cafs = cafs; + } + + public String getComment() { + return this.comment; + } + + public ChanceAtFault[] getCulprits() { + return this.cafs; + } +} Added: trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSourceAnalyzer.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSourceAnalyzer.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.core.new/src/org/cishell/testing/convertertester/core/tester2/reportgen/allerrors/analyzer/ErrorSourceAnalyzer.java 2007-09-13 18:47:33 UTC (rev 521) @@ -0,0 +1,7 @@ +package org.cishell.testing.convertertester.core.tester2.reportgen.allerrors.analyzer; + +import java.util.Map; + +public interface ErrorSourceAnalyzer { + public ErrorSource[] analyze(Map testToPassesToCafs); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |