Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: gm/gmmain.cpp

Issue 14187007: GM: allow caller to specify which result types trigger an error (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: sync_to_r8651 Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 uint32_t flags; 167 uint32_t flags;
168 }; 168 };
169 169
170 static PipeFlagComboData gPipeWritingFlagCombos[] = { 170 static PipeFlagComboData gPipeWritingFlagCombos[] = {
171 { "", 0 }, 171 { "", 0 },
172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, 172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag },
173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag 173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag
174 | SkGPipeWriter::kSharedAddressSpace_Flag } 174 | SkGPipeWriter::kSharedAddressSpace_Flag }
175 }; 175 };
176 176
177 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination()
178 .plus(kMissingExpectations_ErrorType)
179 .plus(kIntentionallySkipped_ErrorType);
180
177 class GMMain { 181 class GMMain {
178 public: 182 public:
179 GMMain() : fUseFileHierarchy(false), fMismatchPath(NULL), fTestsRun(0), 183 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes),
180 fRenderModesEncountered(1) { 184 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {}
181 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType);
182 fIgnorableErrorCombination.add(kIntentionallySkipped_ErrorType);
183 }
184 185
185 SkString make_name(const char shortName[], const char configName[]) { 186 SkString make_name(const char shortName[], const char configName[]) {
186 SkString name; 187 SkString name;
187 if (0 == strlen(configName)) { 188 if (0 == strlen(configName)) {
188 name.append(shortName); 189 name.append(shortName);
189 } else if (fUseFileHierarchy) { 190 } else if (fUseFileHierarchy) {
190 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); 191 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName);
191 } else { 192 } else {
192 name.appendf("%s_%s", shortName, configName); 193 name.appendf("%s_%s", shortName, configName);
193 } 194 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 285 }
285 286
286 /** 287 /**
287 * Return the number of significant (non-ignorable) errors we have 288 * Return the number of significant (non-ignorable) errors we have
288 * encountered so far. 289 * encountered so far.
289 */ 290 */
290 int NumSignificantErrors() { 291 int NumSignificantErrors() {
291 int significantErrors = 0; 292 int significantErrors = 0;
292 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { 293 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
293 ErrorType type = static_cast<ErrorType>(typeInt); 294 ErrorType type = static_cast<ErrorType>(typeInt);
294 if (!fIgnorableErrorCombination.includes(type)) { 295 if (!fIgnorableErrorTypes.includes(type)) {
295 significantErrors += fFailedTests[type].count(); 296 significantErrors += fFailedTests[type].count();
296 } 297 }
297 } 298 }
298 return significantErrors; 299 return significantErrors;
299 } 300 }
300 301
301 /** 302 /**
302 * Display the summary of results with this ErrorType. 303 * Display the summary of results with this ErrorType.
303 * 304 *
304 * @param type which ErrorType 305 * @param type which ErrorType
305 * @param verbose whether to be all verbose about it 306 * @param verbose whether to be all verbose about it
306 */ 307 */
307 void DisplayResultTypeSummary(ErrorType type, bool verbose) { 308 void DisplayResultTypeSummary(ErrorType type, bool verbose) {
308 bool isIgnorableType = fIgnorableErrorCombination.includes(type); 309 bool isIgnorableType = fIgnorableErrorTypes.includes(type);
309 310
310 SkString line; 311 SkString line;
311 if (isIgnorableType) { 312 if (isIgnorableType) {
312 line.append("[ ] "); 313 line.append("[ ] ");
313 } else { 314 } else {
314 line.append("[*] "); 315 line.append("[*] ");
315 } 316 }
316 317
317 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; 318 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type];
318 int count = failedTestsOfThisType->count(); 319 int count = failedTestsOfThisType->count();
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1099 }
1099 return errors; 1100 return errors;
1100 } 1101 }
1101 1102
1102 // 1103 //
1103 // member variables. 1104 // member variables.
1104 // They are public for now, to allow easier setting by tool_main(). 1105 // They are public for now, to allow easier setting by tool_main().
1105 // 1106 //
1106 1107
1107 bool fUseFileHierarchy; 1108 bool fUseFileHierarchy;
1108 ErrorCombination fIgnorableErrorCombination; 1109 ErrorCombination fIgnorableErrorTypes;
1109 1110
1110 const char* fMismatchPath; 1111 const char* fMismatchPath;
1111 1112
1112 // collection of tests that have failed with each ErrorType 1113 // collection of tests that have failed with each ErrorType
1113 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; 1114 SkTArray<SkString> fFailedTests[kLast_ErrorType+1];
1114 int fTestsRun; 1115 int fTestsRun;
1115 SkTDict<int> fRenderModesEncountered; 1116 SkTDict<int> fRenderModesEncountered;
1116 1117
1117 // Where to read expectations (expected image hash digests, etc.) from. 1118 // Where to read expectations (expected image hash digests, etc.) from.
1118 // If unset, we don't do comparisons. 1119 // If unset, we don't do comparisons.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); 1203 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass.");
1203 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); 1204 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip.");
1204 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); 1205 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing.");
1205 #if SK_SUPPORT_GPU 1206 #if SK_SUPPORT_GPU
1206 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " 1207 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or "
1207 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " 1208 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means "
1208 "use the default. 0 for either disables the cache."); 1209 "use the default. 0 for either disables the cache.");
1209 #endif 1210 #endif
1210 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " 1211 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure "
1211 "when reading/writing files."); 1212 "when reading/writing files.");
1213 // TODO(epoger): Maybe should make SkCommandLineFlags handle default string
1214 // values differently, so that the first definition of ignoreErrorTypes worked?
1215 #if 0
1216 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str( ),
1217 "Space-separated list of ErrorTypes that should be ignored. If any *other* error "
1218 "types are encountered, the tool will exit with a nonzero return v alue.");
1219 #else
1220 DEFINE_string(ignoreErrorTypes, "", SkString(SkString(
1221 "Space-separated list of ErrorTypes that should be ignored. If any *other* error "
1222 "types are encountered, the tool will exit with a nonzero return v alue. "
1223 "Defaults to: ") += kDefaultIgnorableErrorTypes.asString(" ")).c_s tr());
1224 #endif
1212 DEFINE_string(match, "", "Only run tests whose name includes this substring/the se substrings " 1225 DEFINE_string(match, "", "Only run tests whose name includes this substring/the se substrings "
1213 "(more than one can be supplied, separated by spaces)."); 1226 "(more than one can be supplied, separated by spaces).");
1214 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " 1227 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to "
1215 "pixel mismatches into this directory."); 1228 "pixel mismatches into this directory.");
1216 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which " 1229 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which "
1217 "testIndex %% divisor == remainder."); 1230 "testIndex %% divisor == remainder.");
1218 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); 1231 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass.");
1219 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); 1232 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass.");
1220 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report " 1233 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report "
1221 "any differences between those and the newly generated ones."); 1234 "any differences between those and the newly generated ones.");
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1645
1633 if (FLAGS_modulo.count() == 2) { 1646 if (FLAGS_modulo.count() == 2) {
1634 moduloRemainder = atoi(FLAGS_modulo[0]); 1647 moduloRemainder = atoi(FLAGS_modulo[0]);
1635 moduloDivisor = atoi(FLAGS_modulo[1]); 1648 moduloDivisor = atoi(FLAGS_modulo[1]);
1636 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { 1649 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) {
1637 gm_fprintf(stderr, "invalid modulo values."); 1650 gm_fprintf(stderr, "invalid modulo values.");
1638 return -1; 1651 return -1;
1639 } 1652 }
1640 } 1653 }
1641 1654
1655 if (FLAGS_ignoreErrorTypes.count() > 0) {
1656 gmmain.fIgnorableErrorTypes = ErrorCombination();
1657 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) {
1658 ErrorType type;
1659 const char *name = FLAGS_ignoreErrorTypes[i];
1660 if (!getErrorTypeByName(name, &type)) {
1661 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e);
1662 return -1;
1663 } else {
1664 gmmain.fIgnorableErrorTypes.add(type);
1665 }
1666 }
1667 }
1668
1642 #if SK_SUPPORT_GPU 1669 #if SK_SUPPORT_GPU
1643 if (FLAGS_gpuCacheSize.count() > 0) { 1670 if (FLAGS_gpuCacheSize.count() > 0) {
1644 if (FLAGS_gpuCacheSize.count() != 2) { 1671 if (FLAGS_gpuCacheSize.count() != 2) {
1645 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); 1672 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n");
1646 return -1; 1673 return -1;
1647 } 1674 }
1648 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); 1675 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]);
1649 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); 1676 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]);
1650 } else { 1677 } else {
1651 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE; 1678 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 if (FLAGS_forceBWtext) { 1914 if (FLAGS_forceBWtext) {
1888 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 1915 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1889 } 1916 }
1890 } 1917 }
1891 1918
1892 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1919 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1893 int main(int argc, char * const argv[]) { 1920 int main(int argc, char * const argv[]) {
1894 return tool_main(argc, (char**) argv); 1921 return tool_main(argc, (char**) argv);
1895 } 1922 }
1896 #endif 1923 #endif
OLDNEW
« no previous file with comments | « gm/gm_error.h ('k') | gm/tests/outputs/ignore-expectations-mismatch/output-expected/command_line » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698