diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-27 18:45:26 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-27 18:45:26 +0000 |
commit | 2b3a204bf68c9e41e62e0f2db5dfe263ea811424 (patch) | |
tree | e719ab910d8d3c955780d3083322572e5cecc43a | |
parent | 8dab8ecc93c018fbda2f7f6fdcfdf9982563f9a9 (diff) |
replace gm_fprintf() calls with SkDebugf()
BUG=skia:1221
R=bsalomon@google.com
Author: epoger@google.com
Review URL: https://codereview.chromium.org/181933002
git-svn-id: http://skia.googlecode.com/svn/trunk@13613 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | gm/gm_expectations.cpp | 45 | ||||
-rw-r--r-- | gm/gm_expectations.h | 2 | ||||
-rw-r--r-- | gm/gmmain.cpp | 109 |
3 files changed, 69 insertions, 87 deletions
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp index c7bab92044..f46a572458 100644 --- a/gm/gm_expectations.cpp +++ b/gm/gm_expectations.cpp @@ -27,18 +27,6 @@ const static char kJsonKey_Hashtype_Bitmap_64bitMD5[] = "bitmap-64bitMD5"; namespace skiagm { - void gm_fprintf(FILE *stream, const char format[], ...) { - va_list args; - va_start(args, format); - fprintf(stream, "GM: "); - vfprintf(stream, format, args); -#ifdef SK_BUILD_FOR_WIN - if (stderr == stream || stdout == stream) { - fflush(stream); - } -#endif - va_end(args); - } Json::Value CreateJsonTree(Json::Value expectedResults, Json::Value actualResultsFailed, @@ -66,21 +54,20 @@ namespace skiagm { GmResultDigest::GmResultDigest(const Json::Value &jsonTypeValuePair) { fIsValid = false; if (!jsonTypeValuePair.isArray()) { - gm_fprintf(stderr, "found non-array json value when parsing GmResultDigest: %s\n", - jsonTypeValuePair.toStyledString().c_str()); + SkDebugf("found non-array json value when parsing GmResultDigest: %s\n", + jsonTypeValuePair.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; } else if (2 != jsonTypeValuePair.size()) { - gm_fprintf(stderr, "found json array with wrong size when parsing GmResultDigest: %s\n", - jsonTypeValuePair.toStyledString().c_str()); + SkDebugf("found json array with wrong size when parsing GmResultDigest: %s\n", + jsonTypeValuePair.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; } else { // TODO(epoger): The current implementation assumes that the // result digest is always of type kJsonKey_Hashtype_Bitmap_64bitMD5 Json::Value jsonHashValue = jsonTypeValuePair[1]; if (!jsonHashValue.isIntegral()) { - gm_fprintf(stderr, - "found non-integer jsonHashValue when parsing GmResultDigest: %s\n", - jsonTypeValuePair.toStyledString().c_str()); + SkDebugf("found non-integer jsonHashValue when parsing GmResultDigest: %s\n", + jsonTypeValuePair.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; } else { fHashDigest = jsonHashValue.asUInt64(); @@ -153,10 +140,9 @@ namespace skiagm { if (ignoreFailure.isNull()) { fIgnoreFailure = kDefaultIgnoreFailure; } else if (!ignoreFailure.isBool()) { - gm_fprintf(stderr, "found non-boolean json value" - " for key '%s' in element '%s'\n", - kJsonKey_ExpectedResults_IgnoreFailure, - jsonElement.toStyledString().c_str()); + SkDebugf("found non-boolean json value for key '%s' in element '%s'\n", + kJsonKey_ExpectedResults_IgnoreFailure, + jsonElement.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; fIgnoreFailure = kDefaultIgnoreFailure; } else { @@ -167,10 +153,9 @@ namespace skiagm { if (allowedDigests.isNull()) { // ok, we'll just assume there aren't any AllowedDigests to compare against } else if (!allowedDigests.isArray()) { - gm_fprintf(stderr, "found non-array json value" - " for key '%s' in element '%s'\n", - kJsonKey_ExpectedResults_AllowedDigests, - jsonElement.toStyledString().c_str()); + SkDebugf("found non-array json value for key '%s' in element '%s'\n", + kJsonKey_ExpectedResults_AllowedDigests, + jsonElement.toStyledString().c_str()); DEBUGFAIL_SEE_STDERR; } else { for (Json::ArrayIndex i=0; i<allowedDigests.size(); i++) { @@ -255,14 +240,14 @@ namespace skiagm { /*static*/ bool JsonExpectationsSource::Parse(const char *jsonPath, Json::Value *jsonRoot) { SkFILEStream inFile(jsonPath); if (!inFile.isValid()) { - gm_fprintf(stderr, "unable to read JSON file %s\n", jsonPath); + SkDebugf("unable to read JSON file %s\n", jsonPath); DEBUGFAIL_SEE_STDERR; return false; } SkAutoDataUnref dataRef(ReadFileIntoSkData(inFile)); if (NULL == dataRef.get()) { - gm_fprintf(stderr, "error reading JSON file %s\n", jsonPath); + SkDebugf("error reading JSON file %s\n", jsonPath); DEBUGFAIL_SEE_STDERR; return false; } @@ -271,7 +256,7 @@ namespace skiagm { size_t size = dataRef.get()->size(); Json::Reader reader; if (!reader.parse(bytes, bytes+size, *jsonRoot)) { - gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); + SkDebugf("error parsing JSON file %s\n", jsonPath); DEBUGFAIL_SEE_STDERR; return false; } diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h index c6a2693b17..d454732dad 100644 --- a/gm/gm_expectations.h +++ b/gm/gm_expectations.h @@ -20,8 +20,6 @@ namespace skiagm { - void gm_fprintf(FILE *stream, const char format[], ...); - Json::Value CreateJsonTree(Json::Value expectedResults, Json::Value actualResultsFailed, Json::Value actualResultsFailureIgnored, diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index acdc598d8c..165c5affb7 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -274,7 +274,7 @@ public: // nothing to do here; 565 bitmaps are inherently opaque break; default: - gm_fprintf(stderr, "unsupported bitmap colorType %d\n", colorType); + SkDebugf("unsupported bitmap colorType %d\n", colorType); DEBUGFAIL_SEE_STDERR; } } @@ -297,7 +297,7 @@ public: if (!SkImageEncoder::EncodeFile(path.c_str(), copy, SkImageEncoder::kPNG_Type, 100)) { - gm_fprintf(stderr, "FAILED to write bitmap: %s\n", path.c_str()); + SkDebugf("FAILED to write bitmap: %s\n", path.c_str()); return ErrorCombination(kWritingReferenceImage_ErrorType); } return kEmpty_ErrorCombination; @@ -429,7 +429,7 @@ public: line.append((*failedTestsOfThisType)[i]); } } - gm_fprintf(stdout, "%s\n", line.c_str()); + SkDebugf("%s\n", line.c_str()); } /** @@ -445,19 +445,19 @@ public: ErrorType type = static_cast<ErrorType>(typeInt); summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type].count()); } - gm_fprintf(stdout, "%s\n", summary.c_str()); + SkDebugf("%s\n", summary.c_str()); // Now, for each failure type, list the tests that failed that way. for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verbose); } - gm_fprintf(stdout, "(results marked with [*] will cause nonzero return value)\n"); + SkDebugf("(results marked with [*] will cause nonzero return value)\n"); } static ErrorCombination write_document(const SkString& path, SkStreamAsset* asset) { SkFILEWStream stream(path.c_str()); if (!stream.writeStream(asset, asset->getLength())) { - gm_fprintf(stderr, "FAILED to write document: %s\n", path.c_str()); + SkDebugf("FAILED to write document: %s\n", path.c_str()); return ErrorCombination(kWritingReferenceImage_ErrorType); } return kEmpty_ErrorCombination; @@ -734,16 +734,15 @@ public: const int width = actualBitmap.width(); const int height = actualBitmap.height(); if ((expectedWidth != width) || (expectedHeight != height)) { - gm_fprintf(stderr, "---- %s: dimension mismatch --" - " expected [%d %d], actual [%d %d]\n", - testName, expectedWidth, expectedHeight, width, height); + SkDebugf("---- %s: dimension mismatch -- expected [%d %d], actual [%d %d]\n", + testName, expectedWidth, expectedHeight, width, height); return; } if ((kPMColor_SkColorType != expectedBitmap.colorType()) || (kPMColor_SkColorType != actualBitmap.colorType())) { - gm_fprintf(stderr, "---- %s: not computing max per-channel" - " pixel mismatch because non-8888\n", testName); + SkDebugf("---- %s: not computing max per-channel pixel mismatch because non-8888\n", + testName); return; } @@ -774,9 +773,9 @@ public: } } } - gm_fprintf(stderr, "---- %s: %d (of %d) differing pixels," - " max per-channel mismatch R=%d G=%d B=%d A=%d\n", - testName, differingPixels, width*height, errR, errG, errB, errA); + SkDebugf("---- %s: %d (of %d) differing pixels, " + "max per-channel mismatch R=%d G=%d B=%d A=%d\n", + testName, differingPixels, width*height, errR, errG, errB, errA); } /** @@ -1090,9 +1089,9 @@ public: bool success = (*pdfRasterizers[i]->fRasterizerFunction)( documentStream.get(), &pdfBitmap); if (!success) { - gm_fprintf(stderr, "FAILED to render PDF for %s using renderer %s\n", - gm->getName(), - pdfRasterizers[i]->fName); + SkDebugf("FAILED to render PDF for %s using renderer %s\n", + gm->getName(), + pdfRasterizers[i]->fName); continue; } @@ -1819,7 +1818,7 @@ static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); SkStream *stream = streamWrapper.get(); if (!stream) { - gm_fprintf(stderr, "unable to read file '%s'\n", filename); + SkDebugf("unable to read file '%s'\n", filename); return false; } @@ -1932,8 +1931,8 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, } } else if (0 == strcmp(kDefaultsConfigStr, config)) { if (exclude) { - gm_fprintf(stderr, "%c%s is not allowed.\n", - kExcludeConfigChar, kDefaultsConfigStr); + SkDebugf("%c%s is not allowed.\n", + kExcludeConfigChar, kDefaultsConfigStr); return false; } for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) { @@ -1942,7 +1941,7 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, } } } else { - gm_fprintf(stderr, "unrecognized config %s\n", config); + SkDebugf("unrecognized config %s\n", config); return false; } } @@ -1952,7 +1951,7 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, if (index >= 0) { *excludeConfigs.append() = index; } else { - gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeConfig[i]); + SkDebugf("unrecognized excludeConfig %s\n", FLAGS_excludeConfig[i]); return false; } } @@ -1982,16 +1981,16 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, if (kGPU_Backend == gRec[index].fBackend) { GrContext* ctx = grFactory->get(gRec[index].fGLContextType); if (NULL == ctx) { - gm_fprintf(stderr, "GrContext could not be created for config %s." - " Config will be skipped.\n", gRec[index].fName); + SkDebugf("GrContext could not be created for config %s. Config will be skipped.\n", + gRec[index].fName); outConfigs->remove(i); --i; continue; } if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { - gm_fprintf(stderr, "Sample count (%d) of config %s is not supported." - " Config will be skipped.\n", - gRec[index].fSampleCnt, gRec[index].fName); + SkDebugf("Sample count (%d) of config %s is not supported." + " Config will be skipped.\n", + gRec[index].fSampleCnt, gRec[index].fName); outConfigs->remove(i); --i; } @@ -2000,7 +1999,7 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, #endif if (outConfigs->isEmpty()) { - gm_fprintf(stderr, "No configs to run."); + SkDebugf("No configs to run."); return false; } @@ -2010,7 +2009,7 @@ static bool parse_flags_configs(SkTDArray<size_t>* outConfigs, for (int i = 0; i < outConfigs->count(); ++i) { configStr.appendf(" %s", gRec[(*outConfigs)[i]].fName); } - gm_fprintf(stdout, "%s\n", configStr.c_str()); + SkDebugf("%s\n", configStr.c_str()); return true; } @@ -2043,7 +2042,7 @@ static bool parse_flags_pdf_rasterizers(const SkTDArray<size_t>& configs, const PDFRasterizerData* rasterizerPtr = findPDFRasterizer(rasterizer); if (rasterizerPtr == NULL) { - gm_fprintf(stderr, "unrecognized rasterizer %s\n", rasterizer); + SkDebugf("unrecognized rasterizer %s\n", rasterizer); return false; } appendUnique<const PDFRasterizerData*>(outRasterizers, @@ -2057,7 +2056,7 @@ static bool parse_flags_pdf_rasterizers(const SkTDArray<size_t>& configs, for (int i = 0; i < outRasterizers->count(); ++i) { configStr.appendf(" %s", (*outRasterizers)[i]->fName); } - gm_fprintf(stdout, "%s\n", configStr.c_str()); + SkDebugf("%s\n", configStr.c_str()); return true; } @@ -2069,7 +2068,7 @@ static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { ErrorType type; const char *name = FLAGS_ignoreErrorTypes[i]; if (!getErrorTypeByName(name, &type)) { - gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", name); + SkDebugf("cannot find ErrorType with name '%s'\n", name); return false; } else { outErrorTypes->add(type); @@ -2112,7 +2111,7 @@ static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { *moduloDivisor = atoi(FLAGS_modulo[1]); if (*moduloRemainder < 0 || *moduloDivisor <= 0 || *moduloRemainder >= *moduloDivisor) { - gm_fprintf(stderr, "invalid modulo values."); + SkDebugf("invalid modulo values."); return false; } } @@ -2123,7 +2122,7 @@ static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { static bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) { if (FLAGS_gpuCacheSize.count() > 0) { if (FLAGS_gpuCacheSize.count() != 2) { - gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); + SkDebugf("--gpuCacheSize requires two arguments\n"); return false; } *sizeBytes = atoi(FLAGS_gpuCacheSize[0]); @@ -2148,7 +2147,7 @@ static bool parse_flags_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales) } if (0 == outScales->count()) { // Should have at least one scale - gm_fprintf(stderr, "--tileGridReplayScales requires at least one scale.\n"); + SkDebugf("--tileGridReplayScales requires at least one scale.\n"); return false; } } @@ -2170,18 +2169,18 @@ static bool parse_flags_gmmain_paths(GMMain* gmmain) { if (FLAGS_readPath.count() == 1) { const char* readPath = FLAGS_readPath[0]; if (!sk_exists(readPath)) { - gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); + SkDebugf("readPath %s does not exist!\n", readPath); return false; } if (sk_isdir(readPath)) { if (FLAGS_verbose) { - gm_fprintf(stdout, "reading from %s\n", readPath); + SkDebugf("reading from %s\n", readPath); } gmmain->fExpectationsSource.reset(SkNEW_ARGS( IndividualImageExpectationsSource, (readPath))); } else { if (FLAGS_verbose) { - gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); + SkDebugf("reading expectations from JSON summary file %s\n", readPath); } gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource, (readPath))); } @@ -2198,7 +2197,7 @@ static bool parse_flags_resource_path() { static bool parse_flags_jpeg_quality() { if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { - gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); + SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); return false; } return true; @@ -2254,20 +2253,20 @@ int tool_main(int argc, char** argv) { if (FLAGS_verbose) { if (FLAGS_writePath.count() == 1) { - gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); + SkDebugf("writing to %s\n", FLAGS_writePath[0]); } if (NULL != gmmain.fMismatchPath) { - gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPath); + SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath); } if (NULL != gmmain.fMissingExpectationsPath) { - gm_fprintf(stdout, "writing images without expectations to %s\n", - gmmain.fMissingExpectationsPath); + SkDebugf("writing images without expectations to %s\n", + gmmain.fMissingExpectationsPath); } if (FLAGS_writePicturePath.count() == 1) { - gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePath[0]); + SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]); } if (FLAGS_resourcePath.count() == 1) { - gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath[0]); + SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); } } @@ -2324,8 +2323,8 @@ int tool_main(int argc, char** argv) { gmsRun++; SkISize size = gm->getISize(); - gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, - size.width(), size.height()); + SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, + size.width(), size.height()); run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplayScales, grFactory); } @@ -2365,11 +2364,11 @@ int tool_main(int argc, char** argv) { // Output summary to stdout. if (FLAGS_verbose) { - gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); - gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), - list_all_config_names(configs).c_str()); - gm_fprintf(stdout, "... and %2d modes [%s]\n", modeCount, list_all(modes).c_str()); - gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expectedNumberOfTests); + SkDebugf("Ran %d GMs\n", gmsRun); + SkDebugf("... over %2d configs [%s]\n", configs.count(), + list_all_config_names(configs).c_str()); + SkDebugf("... and %2d modes [%s]\n", modeCount, list_all(modes).c_str()); + SkDebugf("... so there should be a total of %d tests.\n", expectedNumberOfTests); } gmmain.ListErrors(FLAGS_verbose); @@ -2378,8 +2377,8 @@ int tool_main(int argc, char** argv) { // ('GM is unexpectedly skipping tests on Android') #ifndef SK_BUILD_FOR_ANDROID if (expectedNumberOfTests != gmmain.fTestsRun) { - gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", - expectedNumberOfTests, gmmain.fTestsRun); + SkDebugf("expected %d tests, but ran or skipped %d tests\n", + expectedNumberOfTests, gmmain.fTestsRun); reportError = true; } #endif @@ -2403,7 +2402,7 @@ int tool_main(int argc, char** argv) { if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { GrContext* gr = grFactory->get(config.fGLContextType); - gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); + SkDebugf("config: %s %x\n", config.fName, gr); gr->printCacheStats(); } } |