| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 292 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 293 ErrorType type = static_cast<ErrorType>(typeInt); | 293 ErrorType type = static_cast<ErrorType>(typeInt); |
| 294 if (!fIgnorableErrorCombination.includes(type)) { | 294 if (!fIgnorableErrorCombination.includes(type)) { |
| 295 significantErrors += fFailedTests[type].count(); | 295 significantErrors += fFailedTests[type].count(); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 return significantErrors; | 298 return significantErrors; |
| 299 } | 299 } |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * Display the summary of results with this ErrorType. |
| 303 * |
| 304 * @param type which ErrorType |
| 305 * @param verbose whether to be all verbose about it |
| 306 */ |
| 307 void DisplayResultTypeSummary(ErrorType type, bool verbose) { |
| 308 bool isIgnorableType = fIgnorableErrorCombination.includes(type); |
| 309 |
| 310 SkString line; |
| 311 if (isIgnorableType) { |
| 312 line.append("[ ] "); |
| 313 } else { |
| 314 line.append("[*] "); |
| 315 } |
| 316 |
| 317 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; |
| 318 int count = failedTestsOfThisType->count(); |
| 319 line.appendf("%d %s", count, getErrorTypeName(type)); |
| 320 if (!isIgnorableType || verbose) { |
| 321 line.append(":"); |
| 322 for (int i = 0; i < count; ++i) { |
| 323 line.append(" "); |
| 324 line.append((*failedTestsOfThisType)[i]); |
| 325 } |
| 326 } |
| 327 gm_fprintf(stdout, "%s\n", line.c_str()); |
| 328 } |
| 329 |
| 330 /** |
| 302 * List contents of fFailedTests to stdout. | 331 * List contents of fFailedTests to stdout. |
| 332 * |
| 333 * @param verbose whether to be all verbose about it |
| 303 */ | 334 */ |
| 304 void ListErrors() { | 335 void ListErrors(bool verbose) { |
| 305 // First, print a single summary line. | 336 // First, print a single summary line. |
| 306 SkString summary; | 337 SkString summary; |
| 307 summary.appendf("Ran %d tests:", fTestsRun); | 338 summary.appendf("Ran %d tests:", fTestsRun); |
| 308 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 339 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 309 ErrorType type = static_cast<ErrorType>(typeInt); | 340 ErrorType type = static_cast<ErrorType>(typeInt); |
| 310 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type]
.count()); | 341 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type]
.count()); |
| 311 } | 342 } |
| 312 gm_fprintf(stdout, "%s\n", summary.c_str()); | 343 gm_fprintf(stdout, "%s\n", summary.c_str()); |
| 313 | 344 |
| 314 // Now, for each failure type, list the tests that failed that way. | 345 // Now, for each failure type, list the tests that failed that way. |
| 315 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 346 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 316 SkString line; | 347 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb
ose); |
| 317 ErrorType type = static_cast<ErrorType>(typeInt); | |
| 318 if (fIgnorableErrorCombination.includes(type)) { | |
| 319 line.append("[ ] "); | |
| 320 } else { | |
| 321 line.append("[*] "); | |
| 322 } | |
| 323 | |
| 324 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | |
| 325 int count = failedTestsOfThisType->count(); | |
| 326 line.appendf("%d %s:", count, getErrorTypeName(type)); | |
| 327 for (int i = 0; i < count; ++i) { | |
| 328 line.append(" "); | |
| 329 line.append((*failedTestsOfThisType)[i]); | |
| 330 } | |
| 331 gm_fprintf(stdout, "%s\n", line.c_str()); | |
| 332 } | 348 } |
| 333 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v
alue)\n"); | 349 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v
alue)\n"); |
| 334 } | 350 } |
| 335 | 351 |
| 336 static bool write_document(const SkString& path, | 352 static bool write_document(const SkString& path, |
| 337 const SkDynamicMemoryWStream& document) { | 353 const SkDynamicMemoryWStream& document) { |
| 338 SkFILEWStream stream(path.c_str()); | 354 SkFILEWStream stream(path.c_str()); |
| 339 SkAutoDataUnref data(document.copyToData()); | 355 SkAutoDataUnref data(document.copyToData()); |
| 340 return stream.writeData(data.get()); | 356 return stream.writeData(data.get()); |
| 341 } | 357 } |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 gRec[index].fSampleCnt, gRec[index].fName); | 1695 gRec[index].fSampleCnt, gRec[index].fName); |
| 1680 configs.remove(i); | 1696 configs.remove(i); |
| 1681 --i; | 1697 --i; |
| 1682 } | 1698 } |
| 1683 } | 1699 } |
| 1684 } | 1700 } |
| 1685 #else | 1701 #else |
| 1686 GrContextFactory* grFactory = NULL; | 1702 GrContextFactory* grFactory = NULL; |
| 1687 #endif | 1703 #endif |
| 1688 | 1704 |
| 1689 if (FLAGS_verbose) { | |
| 1690 SkString str; | |
| 1691 str.printf("%d configs:", configs.count()); | |
| 1692 for (int i = 0; i < configs.count(); ++i) { | |
| 1693 str.appendf(" %s", gRec[configs[i]].fName); | |
| 1694 } | |
| 1695 gm_fprintf(stderr, "%s\n", str.c_str()); | |
| 1696 } | |
| 1697 | |
| 1698 if (FLAGS_resourcePath.count() == 1) { | 1705 if (FLAGS_resourcePath.count() == 1) { |
| 1699 GM::SetResourcePath(FLAGS_resourcePath[0]); | 1706 GM::SetResourcePath(FLAGS_resourcePath[0]); |
| 1700 } | 1707 } |
| 1701 | 1708 |
| 1702 if (FLAGS_readPath.count() == 1) { | 1709 if (FLAGS_readPath.count() == 1) { |
| 1703 const char* readPath = FLAGS_readPath[0]; | 1710 const char* readPath = FLAGS_readPath[0]; |
| 1704 if (!sk_exists(readPath)) { | 1711 if (!sk_exists(readPath)) { |
| 1705 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1712 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
| 1706 return -1; | 1713 return -1; |
| 1707 } | 1714 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 | 1798 |
| 1792 SkDELETE(gm); | 1799 SkDELETE(gm); |
| 1793 } | 1800 } |
| 1794 | 1801 |
| 1795 SkTArray<SkString> modes; | 1802 SkTArray<SkString> modes; |
| 1796 gmmain.GetRenderModesEncountered(modes); | 1803 gmmain.GetRenderModesEncountered(modes); |
| 1797 bool reportError = false; | 1804 bool reportError = false; |
| 1798 if (gmmain.NumSignificantErrors() > 0) { | 1805 if (gmmain.NumSignificantErrors() > 0) { |
| 1799 reportError = true; | 1806 reportError = true; |
| 1800 } | 1807 } |
| 1808 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count()); |
| 1801 | 1809 |
| 1802 // Output summary to stdout. | 1810 // Output summary to stdout. |
| 1803 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); | 1811 if (FLAGS_verbose) { |
| 1804 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), | 1812 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); |
| 1805 list_all_config_names(configs).c_str()); | 1813 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), |
| 1806 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_all(mo
des).c_str()); | 1814 list_all_config_names(configs).c_str()); |
| 1807 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count()); | 1815 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al
l(modes).c_str()); |
| 1808 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expected
NumberOfTests); | 1816 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe
ctedNumberOfTests); |
| 1809 gmmain.ListErrors(); | 1817 } |
| 1818 gmmain.ListErrors(FLAGS_verbose); |
| 1810 | 1819 |
| 1811 // TODO(epoger): in a standalone CL, enable this new check. | 1820 // TODO(epoger): in a standalone CL, enable this new check. |
| 1812 #if 0 | 1821 #if 0 |
| 1813 if (expectedNumberOfTests != gmmain.fTestsRun) { | 1822 if (expectedNumberOfTests != gmmain.fTestsRun) { |
| 1814 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", | 1823 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", |
| 1815 expectedNumberOfTests, gmmain.fTestsRun); | 1824 expectedNumberOfTests, gmmain.fTestsRun); |
| 1816 reportError = true; | 1825 reportError = true; |
| 1817 } | 1826 } |
| 1818 #endif | 1827 #endif |
| 1819 | 1828 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 if (FLAGS_forceBWtext) { | 1870 if (FLAGS_forceBWtext) { |
| 1862 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1871 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1863 } | 1872 } |
| 1864 } | 1873 } |
| 1865 | 1874 |
| 1866 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1875 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1867 int main(int argc, char * const argv[]) { | 1876 int main(int argc, char * const argv[]) { |
| 1868 return tool_main(argc, (char**) argv); | 1877 return tool_main(argc, (char**) argv); |
| 1869 } | 1878 } |
| 1870 #endif | 1879 #endif |
| OLD | NEW |