Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 /* | 8 /* |
| 9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
| 10 * | 10 * |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 291 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 292 ErrorType type = static_cast<ErrorType>(typeInt); | 292 ErrorType type = static_cast<ErrorType>(typeInt); |
| 293 if (!fIgnorableErrorCombination.includes(type)) { | 293 if (!fIgnorableErrorCombination.includes(type)) { |
| 294 significantErrors += fFailedTests[type].count(); | 294 significantErrors += fFailedTests[type].count(); |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 return significantErrors; | 297 return significantErrors; |
| 298 } | 298 } |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * Display the summary of results with this ErrorType. | |
| 302 * | |
| 303 * @param type which ErrorType | |
| 304 * @param verbose whether to be all verbose about it | |
| 305 */ | |
| 306 void DisplayResultTypeSummary(ErrorType type, bool verbose) { | |
| 307 bool isIgnorableType = fIgnorableErrorCombination.includes(type); | |
| 308 | |
| 309 SkString line; | |
| 310 if (isIgnorableType) { | |
| 311 line.append("[ ] "); | |
| 312 } else { | |
| 313 line.append("[*] "); | |
| 314 } | |
| 315 | |
| 316 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | |
| 317 int count = failedTestsOfThisType->count(); | |
| 318 line.appendf("%d %s", count, getErrorTypeName(type)); | |
| 319 if (!isIgnorableType || verbose) { | |
|
epoger
2013/04/09 20:19:50
Patchset 2 changes gm's behavior: only write out t
| |
| 320 line.append(":"); | |
| 321 for (int i = 0; i < count; ++i) { | |
| 322 line.append(" "); | |
| 323 line.append((*failedTestsOfThisType)[i]); | |
| 324 } | |
| 325 } | |
| 326 gm_fprintf(stdout, "%s\n", line.c_str()); | |
| 327 } | |
| 328 | |
| 329 /** | |
| 301 * List contents of fFailedTests to stdout. | 330 * List contents of fFailedTests to stdout. |
| 331 * | |
| 332 * @param verbose whether to be all verbose about it | |
| 302 */ | 333 */ |
| 303 void ListErrors() { | 334 void ListErrors(bool verbose) { |
| 304 // First, print a single summary line. | 335 // First, print a single summary line. |
| 305 SkString summary; | 336 SkString summary; |
| 306 summary.appendf("Ran %d tests:", fTestsRun); | 337 summary.appendf("Ran %d tests:", fTestsRun); |
| 307 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 338 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 308 ErrorType type = static_cast<ErrorType>(typeInt); | 339 ErrorType type = static_cast<ErrorType>(typeInt); |
| 309 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type] .count()); | 340 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type] .count()); |
| 310 } | 341 } |
| 311 gm_fprintf(stdout, "%s\n", summary.c_str()); | 342 gm_fprintf(stdout, "%s\n", summary.c_str()); |
| 312 | 343 |
| 313 // Now, for each failure type, list the tests that failed that way. | 344 // Now, for each failure type, list the tests that failed that way. |
| 314 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 345 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 315 SkString line; | 346 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb ose); |
| 316 ErrorType type = static_cast<ErrorType>(typeInt); | |
| 317 if (fIgnorableErrorCombination.includes(type)) { | |
| 318 line.append("[ ] "); | |
| 319 } else { | |
| 320 line.append("[*] "); | |
| 321 } | |
| 322 | |
| 323 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | |
| 324 int count = failedTestsOfThisType->count(); | |
| 325 line.appendf("%d %s:", count, getErrorTypeName(type)); | |
| 326 for (int i = 0; i < count; ++i) { | |
| 327 line.append(" "); | |
| 328 line.append((*failedTestsOfThisType)[i]); | |
| 329 } | |
| 330 gm_fprintf(stdout, "%s\n", line.c_str()); | |
| 331 } | 347 } |
| 332 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); | 348 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); |
| 333 } | 349 } |
| 334 | 350 |
| 335 static bool write_document(const SkString& path, | 351 static bool write_document(const SkString& path, |
| 336 const SkDynamicMemoryWStream& document) { | 352 const SkDynamicMemoryWStream& document) { |
| 337 SkFILEWStream stream(path.c_str()); | 353 SkFILEWStream stream(path.c_str()); |
| 338 SkAutoDataUnref data(document.copyToData()); | 354 SkAutoDataUnref data(document.copyToData()); |
| 339 return stream.writeData(data.get()); | 355 return stream.writeData(data.get()); |
| 340 } | 356 } |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1638 gRec[index].fSampleCnt, gRec[index].fName); | 1654 gRec[index].fSampleCnt, gRec[index].fName); |
| 1639 configs.remove(i); | 1655 configs.remove(i); |
| 1640 --i; | 1656 --i; |
| 1641 } | 1657 } |
| 1642 } | 1658 } |
| 1643 } | 1659 } |
| 1644 #else | 1660 #else |
| 1645 GrContextFactory* grFactory = NULL; | 1661 GrContextFactory* grFactory = NULL; |
| 1646 #endif | 1662 #endif |
| 1647 | 1663 |
| 1648 if (FLAGS_verbose) { | |
| 1649 SkString str; | |
| 1650 str.printf("%d configs:", configs.count()); | |
| 1651 for (int i = 0; i < configs.count(); ++i) { | |
| 1652 str.appendf(" %s", gRec[configs[i]].fName); | |
| 1653 } | |
| 1654 gm_fprintf(stderr, "%s\n", str.c_str()); | |
| 1655 } | |
| 1656 | |
| 1657 if (FLAGS_resourcePath.count() == 1) { | 1664 if (FLAGS_resourcePath.count() == 1) { |
| 1658 GM::SetResourcePath(FLAGS_resourcePath[0]); | 1665 GM::SetResourcePath(FLAGS_resourcePath[0]); |
| 1659 } | 1666 } |
| 1660 | 1667 |
| 1661 if (FLAGS_readPath.count() == 1) { | 1668 if (FLAGS_readPath.count() == 1) { |
| 1662 const char* readPath = FLAGS_readPath[0]; | 1669 const char* readPath = FLAGS_readPath[0]; |
| 1663 if (!sk_exists(readPath)) { | 1670 if (!sk_exists(readPath)) { |
| 1664 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1671 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
| 1665 return -1; | 1672 return -1; |
| 1666 } | 1673 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1748 // Otherwise, what are we comparing against? | 1755 // Otherwise, what are we comparing against? |
| 1749 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid ReplayScales); | 1756 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid ReplayScales); |
| 1750 | 1757 |
| 1751 SkDELETE(gm); | 1758 SkDELETE(gm); |
| 1752 } | 1759 } |
| 1753 | 1760 |
| 1754 SkTArray<SkString> modes; | 1761 SkTArray<SkString> modes; |
| 1755 gmmain.GetRenderModesEncountered(modes); | 1762 gmmain.GetRenderModesEncountered(modes); |
| 1756 | 1763 |
| 1757 // Output summary to stdout. | 1764 // Output summary to stdout. |
| 1758 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); | 1765 if (FLAGS_verbose) { |
| 1759 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), | 1766 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); |
| 1760 list_all_config_names(configs).c_str()); | 1767 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), |
| 1761 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_all(mo des).c_str()); | 1768 list_all_config_names(configs).c_str()); |
| 1762 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", | 1769 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al l(modes).c_str()); |
| 1763 gmsRun * (configs.count() + modes.count())); | 1770 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", |
| 1771 gmsRun * (configs.count() + modes.count())); | |
| 1772 } | |
| 1764 | 1773 |
| 1765 // TODO(epoger): Ultimately, we should signal an error if the | 1774 // TODO(epoger): Ultimately, we should signal an error if the |
| 1766 // expected total number of tests (displayed above) does not match | 1775 // expected total number of tests (displayed above) does not match |
| 1767 // gmmain.fTestsRun. But for now, there are cases where those | 1776 // gmmain.fTestsRun. But for now, there are cases where those |
| 1768 // numbers won't match: specifically, if some configs/modes are | 1777 // numbers won't match: specifically, if some configs/modes are |
| 1769 // skipped on a per-GM basis (due to gm->getFlags() for a specific | 1778 // skipped on a per-GM basis (due to gm->getFlags() for a specific |
| 1770 // GM). Later on, we should record tests like that using some new | 1779 // GM). Later on, we should record tests like that using some new |
| 1771 // ErrorType, like kIntentionallySkipped_ErrorType. Then we could | 1780 // ErrorType, like kIntentionallySkipped_ErrorType. Then we could |
| 1772 // signal an error if the totals didn't match up. | 1781 // signal an error if the totals didn't match up. |
| 1773 gmmain.ListErrors(); | 1782 gmmain.ListErrors(FLAGS_verbose); |
| 1774 | 1783 |
| 1775 if (FLAGS_writeJsonSummaryPath.count() == 1) { | 1784 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
| 1776 Json::Value actualResults; | 1785 Json::Value actualResults; |
| 1777 actualResults[kJsonKey_ActualResults_Failed] = | 1786 actualResults[kJsonKey_ActualResults_Failed] = |
| 1778 gmmain.fJsonActualResults_Failed; | 1787 gmmain.fJsonActualResults_Failed; |
| 1779 actualResults[kJsonKey_ActualResults_FailureIgnored] = | 1788 actualResults[kJsonKey_ActualResults_FailureIgnored] = |
| 1780 gmmain.fJsonActualResults_FailureIgnored; | 1789 gmmain.fJsonActualResults_FailureIgnored; |
| 1781 actualResults[kJsonKey_ActualResults_NoComparison] = | 1790 actualResults[kJsonKey_ActualResults_NoComparison] = |
| 1782 gmmain.fJsonActualResults_NoComparison; | 1791 gmmain.fJsonActualResults_NoComparison; |
| 1783 actualResults[kJsonKey_ActualResults_Succeeded] = | 1792 actualResults[kJsonKey_ActualResults_Succeeded] = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1816 if (FLAGS_forceBWtext) { | 1825 if (FLAGS_forceBWtext) { |
| 1817 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1826 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1818 } | 1827 } |
| 1819 } | 1828 } |
| 1820 | 1829 |
| 1821 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1830 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1822 int main(int argc, char * const argv[]) { | 1831 int main(int argc, char * const argv[]) { |
| 1823 return tool_main(argc, (char**) argv); | 1832 return tool_main(argc, (char**) argv); |
| 1824 } | 1833 } |
| 1825 #endif | 1834 #endif |
| OLD | NEW |