114 workDir.getTestResultTable().waitUntilReady();
115
116 TestDescription td;
117 while ((td = tfq.next()) != null) {
118 try {
119 TestResult tr = new TestResult(workDir, TestResult.getWorkRelativePath(td));
120
121 testCount++;
122 statusCounts[tr.getStatus().getType()]++;
123 checksumCounts[tr.getChecksumState()]++;
124
125 if (tr.getChecksumState() == TestResult.BAD_CHECKSUM)
126 badChecksumTestsV.addElement(tr);
127
128 if (!equal(td, tr.getDescription()))
129 badTestDescriptionsV.addElement(tr);
130
131 if (!checkTestCases(tr, excludeList))
132 badTestCaseTestsV.addElement(tr);
133
134 Map trEnv = tr.getEnvironment();
135 for (Iterator i = trEnv.entrySet().iterator(); i.hasNext(); ) {
136 Map.Entry e = (Map.Entry) (i.next());
137 String key = (String) (e.getKey());
138 String value = (String) (e.getValue());
139 Vector<String> allValuesForKey = envTable.get(key);
140 if (allValuesForKey == null) {
141 allValuesForKey = new Vector<>();
142 envTable.put(key, allValuesForKey);
143 }
144 if (!allValuesForKey.contains(value))
145 allValuesForKey.addElement(value);
146 }
147
148 String start = tr.getProperty(TestResult.START);
149 if (start == null) {
150 badDates = true;
151 }
152 else {
153 Date d = parseDate(start);
154 if (d == null)
155 badDates = true;
156 else {
157 if (earliestStart == null || d.before(earliestStart))
158 earliestStart = d;
159 if (latestStart == null || d.after(latestStart))
160 latestStart = d;
161 }
162 }
163 }
164 catch (TestResult.Fault e) {
165 //System.err.println(td.getRootRelativeURL() + " " + TestResult.getWorkRelativePath(td) + " " + e);
166 badTestsV.addElement(td);
167 }
168 }
169
170 for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) {
171 String key = (String)(e.nextElement());
172 Vector allValuesForKey = envTable.get(key);
173 envCounts[allValuesForKey.size() == 1 ? 0 : 1]++;
174 }
175
176 if (badChecksumTestsV.size() > 0) {
177 badChecksumTests = new TestResult[badChecksumTestsV.size()];
178 badChecksumTestsV.copyInto(badChecksumTests);
179 }
180
181 if (badTestDescriptionsV.size() > 0) {
182 badTestDescriptions = new TestResult[badTestDescriptionsV.size()];
183 badTestDescriptionsV.copyInto(badTestDescriptions);
184 }
185
186 if (badTestCaseTestsV.size() > 0) {
187 badTestCaseTests = new TestResult[badTestCaseTestsV.size()];
188 badTestCaseTestsV.copyInto(badTestCaseTests);
189 }
190
191 if (badTestsV.size() > 0) {
192 badTests = new TestDescription[badTestsV.size()];
235 public int[] getChecksumCounts() {
236 return checksumCounts;
237 }
238
239 /**
240 * Get the statistics about the environment values used by the test results.
241 * @return An array of two integers; the first gives the number of env
242 * values that were uniquely defined across all test results, the second gives
243 * the number that were multiply defined across the results.
244 */
245 public int[] getEnvCounts() {
246 return envCounts;
247 }
248
249 /**
250 * Get the composite set of environment values used by the tests.
251 * @return A table of values.
252 * The keys to the table are strings; the values are vectors of strings
253 * containing the various values for that key.
254 */
255 public Hashtable getEnvTable() {
256 return envTable;
257 }
258
259 /**
260 * Get the statistics about the test results.
261 * @return An array of counts, indexed by Status.PASSED, Status.FAILED, etc
262 */
263 public int[] getStatusCounts() {
264 return statusCounts;
265 }
266
267 /**
268 * Get earliest recorded start time for a test.
269 * @return The earliest recorded valid start time for a test,
270 * or null, if none was found.
271 */
272 public Date getEarliestStartTime() {
273 return earliestStart;
274 }
275
476 out.println(i18n.getString("adt.env.count",
477 new Object[] {
478 new Integer(u),
479 new Integer((u > 0 && m > 0) ? 1 : 0),
480 new Integer(m)
481 } ));
482 }
483 }
484 }
485
486 /**
487 * Print out a listing of some or all of the env values used by the tests.
488 * @param showAll show all environment values (uniquely and multiply defined.)
489 * The default is to just show the multiple defined values.
490 */
491 private void showEnvValues(boolean showAll) {
492 out.println();
493 out.print(i18n.getString("adt.envList.title"));
494
495 SortedSet<String> ss = new TreeSet<>();
496 for (Enumeration e = envTable.keys(); e.hasMoreElements(); ) {
497 String key = (String)(e.nextElement());
498 ss.add(key);
499 }
500
501 for (Iterator iter = ss.iterator(); iter.hasNext(); ) {
502 String key = (String) (iter.next());
503 Vector allValuesForKey = envTable.get(key);
504 if (allValuesForKey.size() == 1) {
505 if (showAll)
506 out.println(i18n.getString("adt.envKeyValue",
507 new Object[] {key, allValuesForKey.elementAt(0)}));
508 }
509 else {
510 out.println(i18n.getString("adt.envKey", key));
511 for (int j = 0; j < allValuesForKey.size(); j++) {
512 out.println(i18n.getString("adt.envValue",
513 allValuesForKey.elementAt(j)));
514 }
515 }
516 }
517 }
518
519 /**
520 * Print out a short summary report of the checksum statistics.
521 */
522 private void showChecksumCounts() {
523 if (testCount > 0) {
616 if (etcTest[i].equals(etcTable[j]))
617 continue nextTestCase;
618 }
619 // etcTest[i] was not found in etcTable;
620 // that means we have a problem
621 return false;
622 }
623
624 // if we're here, we found all the test cases that were actually
625 // excluded were all validly excluded, according to excludedTestCases.
626 return true;
627 }
628
629 private static boolean equal(TestDescription a, TestDescription b) {
630 if (a == null || b == null)
631 return (a == b);
632
633 //if (!a.rootRelativeFile.equals(b.rootRelativeFile))
634 // return false;
635
636 Iterator eA = a.getParameterKeys();
637 Iterator eB = b.getParameterKeys();
638 while (eA.hasNext() && eB.hasNext()) {
639 String keyA = (String)eA.next();
640 String keyB = (String)eB.next();
641 if (!keyA.equals(keyB)) {
642 //System.err.println("mismatch " + a.getRootRelativePath() + " a:" + keyA + " b:" + keyB);
643 return false;
644 }
645
646 String valA = a.getParameter(keyA);
647 String valB = a.getParameter(keyB);
648 if (!(valA.equals(valB) || (keyA.equals("keywords") && keywordMatch(valA, valB)))) {
649 //System.err.println("mismatch " + a.getRootRelativePath() + " key:" + keyA + " a:" + valA + " b:" + valB);
650 return false;
651 }
652 }
653
654 return true;
655 }
656
657 private final static boolean keywordMatch(String a, String b) {
658 // eek, not very efficient!
659 String[] aa = StringArray.split(a);
660 Arrays.sort(aa);
|
114 workDir.getTestResultTable().waitUntilReady();
115
116 TestDescription td;
117 while ((td = tfq.next()) != null) {
118 try {
119 TestResult tr = new TestResult(workDir, TestResult.getWorkRelativePath(td));
120
121 testCount++;
122 statusCounts[tr.getStatus().getType()]++;
123 checksumCounts[tr.getChecksumState()]++;
124
125 if (tr.getChecksumState() == TestResult.BAD_CHECKSUM)
126 badChecksumTestsV.addElement(tr);
127
128 if (!equal(td, tr.getDescription()))
129 badTestDescriptionsV.addElement(tr);
130
131 if (!checkTestCases(tr, excludeList))
132 badTestCaseTestsV.addElement(tr);
133
134 Map<String, String> trEnv = tr.getEnvironment();
135 for (Map.Entry<String, String> e : trEnv.entrySet() ) {
136 String key = e.getKey();
137 String value = e.getValue();
138 Vector<String> allValuesForKey = envTable.get(key);
139 if (allValuesForKey == null) {
140 allValuesForKey = new Vector<>();
141 envTable.put(key, allValuesForKey);
142 }
143 if (!allValuesForKey.contains(value))
144 allValuesForKey.addElement(value);
145 }
146
147 String start = tr.getProperty(TestResult.START);
148 if (start == null) {
149 badDates = true;
150 }
151 else {
152 Date d = parseDate(start);
153 if (d == null)
154 badDates = true;
155 else {
156 if (earliestStart == null || d.before(earliestStart))
157 earliestStart = d;
158 if (latestStart == null || d.after(latestStart))
159 latestStart = d;
160 }
161 }
162 }
163 catch (TestResult.Fault e) {
164 //System.err.println(td.getRootRelativeURL() + " " + TestResult.getWorkRelativePath(td) + " " + e);
165 badTestsV.addElement(td);
166 }
167 }
168
169 for (Enumeration<String> e = envTable.keys(); e.hasMoreElements(); ) {
170 String key = e.nextElement();
171 Vector<String> allValuesForKey = envTable.get(key);
172 envCounts[allValuesForKey.size() == 1 ? 0 : 1]++;
173 }
174
175 if (badChecksumTestsV.size() > 0) {
176 badChecksumTests = new TestResult[badChecksumTestsV.size()];
177 badChecksumTestsV.copyInto(badChecksumTests);
178 }
179
180 if (badTestDescriptionsV.size() > 0) {
181 badTestDescriptions = new TestResult[badTestDescriptionsV.size()];
182 badTestDescriptionsV.copyInto(badTestDescriptions);
183 }
184
185 if (badTestCaseTestsV.size() > 0) {
186 badTestCaseTests = new TestResult[badTestCaseTestsV.size()];
187 badTestCaseTestsV.copyInto(badTestCaseTests);
188 }
189
190 if (badTestsV.size() > 0) {
191 badTests = new TestDescription[badTestsV.size()];
234 public int[] getChecksumCounts() {
235 return checksumCounts;
236 }
237
238 /**
239 * Get the statistics about the environment values used by the test results.
240 * @return An array of two integers; the first gives the number of env
241 * values that were uniquely defined across all test results, the second gives
242 * the number that were multiply defined across the results.
243 */
244 public int[] getEnvCounts() {
245 return envCounts;
246 }
247
248 /**
249 * Get the composite set of environment values used by the tests.
250 * @return A table of values.
251 * The keys to the table are strings; the values are vectors of strings
252 * containing the various values for that key.
253 */
254 public Hashtable<String, Vector<String>> getEnvTable() {
255 return envTable;
256 }
257
258 /**
259 * Get the statistics about the test results.
260 * @return An array of counts, indexed by Status.PASSED, Status.FAILED, etc
261 */
262 public int[] getStatusCounts() {
263 return statusCounts;
264 }
265
266 /**
267 * Get earliest recorded start time for a test.
268 * @return The earliest recorded valid start time for a test,
269 * or null, if none was found.
270 */
271 public Date getEarliestStartTime() {
272 return earliestStart;
273 }
274
475 out.println(i18n.getString("adt.env.count",
476 new Object[] {
477 new Integer(u),
478 new Integer((u > 0 && m > 0) ? 1 : 0),
479 new Integer(m)
480 } ));
481 }
482 }
483 }
484
485 /**
486 * Print out a listing of some or all of the env values used by the tests.
487 * @param showAll show all environment values (uniquely and multiply defined.)
488 * The default is to just show the multiple defined values.
489 */
490 private void showEnvValues(boolean showAll) {
491 out.println();
492 out.print(i18n.getString("adt.envList.title"));
493
494 SortedSet<String> ss = new TreeSet<>();
495 for (Enumeration<String> e = envTable.keys(); e.hasMoreElements(); ) {
496 String key = (e.nextElement());
497 ss.add(key);
498 }
499
500 for (Iterator<String> iter = ss.iterator(); iter.hasNext(); ) {
501 String key = (iter.next());
502 Vector<String> allValuesForKey = envTable.get(key);
503 if (allValuesForKey.size() == 1) {
504 if (showAll)
505 out.println(i18n.getString("adt.envKeyValue",
506 new Object[] {key, allValuesForKey.elementAt(0)}));
507 }
508 else {
509 out.println(i18n.getString("adt.envKey", key));
510 for (int j = 0; j < allValuesForKey.size(); j++) {
511 out.println(i18n.getString("adt.envValue",
512 allValuesForKey.elementAt(j)));
513 }
514 }
515 }
516 }
517
518 /**
519 * Print out a short summary report of the checksum statistics.
520 */
521 private void showChecksumCounts() {
522 if (testCount > 0) {
615 if (etcTest[i].equals(etcTable[j]))
616 continue nextTestCase;
617 }
618 // etcTest[i] was not found in etcTable;
619 // that means we have a problem
620 return false;
621 }
622
623 // if we're here, we found all the test cases that were actually
624 // excluded were all validly excluded, according to excludedTestCases.
625 return true;
626 }
627
628 private static boolean equal(TestDescription a, TestDescription b) {
629 if (a == null || b == null)
630 return (a == b);
631
632 //if (!a.rootRelativeFile.equals(b.rootRelativeFile))
633 // return false;
634
635 Iterator<String> eA = a.getParameterKeys();
636 Iterator<String> eB = b.getParameterKeys();
637 while (eA.hasNext() && eB.hasNext()) {
638 String keyA = eA.next();
639 String keyB = eB.next();
640 if (!keyA.equals(keyB)) {
641 //System.err.println("mismatch " + a.getRootRelativePath() + " a:" + keyA + " b:" + keyB);
642 return false;
643 }
644
645 String valA = a.getParameter(keyA);
646 String valB = a.getParameter(keyB);
647 if (!(valA.equals(valB) || (keyA.equals("keywords") && keywordMatch(valA, valB)))) {
648 //System.err.println("mismatch " + a.getRootRelativePath() + " key:" + keyA + " a:" + valA + " b:" + valB);
649 return false;
650 }
651 }
652
653 return true;
654 }
655
656 private final static boolean keywordMatch(String a, String b) {
657 // eek, not very efficient!
658 String[] aa = StringArray.split(a);
659 Arrays.sort(aa);
|