diff options
-rw-r--r-- | dm/DM.cpp | 8 | ||||
-rw-r--r-- | tests/AAClipTest.cpp | 21 | ||||
-rw-r--r-- | tests/BitmapTest.cpp | 4 | ||||
-rw-r--r-- | tests/MathTest.cpp | 16 | ||||
-rw-r--r-- | tests/MemsetTest.cpp | 30 | ||||
-rw-r--r-- | tests/PDFJpegEmbedTest.cpp | 12 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 6 | ||||
-rw-r--r-- | tests/SrcOverTest.cpp | 8 | ||||
-rw-r--r-- | tests/StreamTest.cpp | 3 | ||||
-rw-r--r-- | tests/Test.h | 11 | ||||
-rw-r--r-- | tests/Time.cpp | 6 | ||||
-rw-r--r-- | tests/WArrayTest.cpp | 8 | ||||
-rw-r--r-- | tests/YUVTest.cpp | 2 |
13 files changed, 68 insertions, 67 deletions
@@ -10,6 +10,7 @@ #include "DMSrcSink.h" #include "DMSrcSinkAndroid.h" #include "ProcStats.h" +#include "Resources.h" #include "SkBBHFactory.h" #include "SkChecksum.h" #include "SkCodec.h" @@ -1145,6 +1146,13 @@ int dm_main() { SkTaskGroup::Enabler enabled(FLAGS_threads); gCreateTypefaceDelegate = &create_from_name; + { + SkString testResourcePath = GetResourcePath("color_wheel.png"); + SkFILEStream testResource(testResourcePath.c_str()); + if (!testResource.isValid()) { + SkDebugf("Some resources are missing. Do you need to set --resourcePath?\n"); + } + } gather_gold(); gather_uninteresting_hashes(); diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp index faf45ed70b..1ea850688d 100644 --- a/tests/AAClipTest.cpp +++ b/tests/AAClipTest.cpp @@ -262,17 +262,18 @@ static void test_irect(skiatest::Reporter* reporter) { bool nonEmptyAA = clip2.op(clip0, clip1, op); bool nonEmptyBW = rgn2.op(rgn0, rgn1, op); if (nonEmptyAA != nonEmptyBW || clip2.getBounds() != rgn2.getBounds()) { - SkDebugf("[%d %d %d %d] %s [%d %d %d %d] = BW:[%d %d %d %d] AA:[%d %d %d %d]\n", - r0.fLeft, r0.fTop, r0.right(), r0.bottom(), - gRgnOpNames[j], - r1.fLeft, r1.fTop, r1.right(), r1.bottom(), - rgn2.getBounds().fLeft, rgn2.getBounds().fTop, - rgn2.getBounds().right(), rgn2.getBounds().bottom(), - clip2.getBounds().fLeft, clip2.getBounds().fTop, - clip2.getBounds().right(), clip2.getBounds().bottom()); + ERRORF(reporter, "%s %s " + "[%d %d %d %d] %s [%d %d %d %d] = BW:[%d %d %d %d] AA:[%d %d %d %d]\n", + nonEmptyAA == nonEmptyBW ? "true" : "false", + clip2.getBounds() == rgn2.getBounds() ? "true" : "false", + r0.fLeft, r0.fTop, r0.right(), r0.bottom(), + gRgnOpNames[j], + r1.fLeft, r1.fTop, r1.right(), r1.bottom(), + rgn2.getBounds().fLeft, rgn2.getBounds().fTop, + rgn2.getBounds().right(), rgn2.getBounds().bottom(), + clip2.getBounds().fLeft, clip2.getBounds().fTop, + clip2.getBounds().right(), clip2.getBounds().bottom()); } - REPORTER_ASSERT(reporter, nonEmptyAA == nonEmptyBW); - REPORTER_ASSERT(reporter, clip2.getBounds() == rgn2.getBounds()); SkMask maskBW, maskAA; copyToMask(rgn2, &maskBW); diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index 015b917464..f939875cf2 100644 --- a/tests/BitmapTest.cpp +++ b/tests/BitmapTest.cpp @@ -151,9 +151,7 @@ static void test_erasecolor_premul(skiatest::Reporter* reporter, SkColorType ct, SkBitmap bm; bm.allocPixels(SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType)); bm.eraseColor(input); - if (reporter->verbose()) { - SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0)); - } + INFOF(reporter, "expected: %x actual: %x\n", expected, bm.getColor(0, 0)); REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected); } diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index de7ad1db78..5bc2d0ebf7 100644 --- a/tests/MathTest.cpp +++ b/tests/MathTest.cpp @@ -52,9 +52,10 @@ static float std_floor(float x) { static void test_floor_value(skiatest::Reporter* reporter, float value) { float fast = fast_floor(value); float std = std_floor(value); - REPORTER_ASSERT(reporter, std == fast); -// SkDebugf("value[%1.9f] std[%g] fast[%g] equal[%d]\n", -// value, std, fast, std == fast); + if (std != fast) { + ERRORF(reporter, "fast_floor(%.9g) == %.9g != %.9g == std_floor(%.9g)", + value, fast, std, value); + } } static void test_floor(skiatest::Reporter* reporter) { @@ -150,7 +151,7 @@ static void test_blend31() { if (r0 != r1 && r0 != r2) { SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", - src, dst, a, r0, f); + src, dst, a, r0, f); failed += 1; } if (r0 > 255) { @@ -176,11 +177,8 @@ static void test_blend(skiatest::Reporter* reporter) { float diff = sk_float_abs(f1 - r1); diff = sk_float_abs(diff - 0.5f); if (diff > (1 / 255.f)) { -#ifdef SK_DEBUG - SkDebugf("src:%d dst:%d a:%d result:%d float:%g\n", - src, dst, a, r0, f1); -#endif - REPORTER_ASSERT(reporter, false); + ERRORF(reporter, "src:%d dst:%d a:%d " + "result:%d float:%g\n", src, dst, a, r0, f1); } } } diff --git a/tests/MemsetTest.cpp b/tests/MemsetTest.cpp index 76412eec77..854b3c56eb 100644 --- a/tests/MemsetTest.cpp +++ b/tests/MemsetTest.cpp @@ -95,24 +95,24 @@ static void set_zero(void* dst, size_t bytes) { #define VALUE16 0x1234 #define VALUE32 0x12345678 -static bool compare16(const uint16_t base[], uint16_t value, int count) { +static void compare16(skiatest::Reporter* r, const uint16_t base[], + uint16_t value, int count) { for (int i = 0; i < count; ++i) { if (base[i] != value) { - SkDebugf("[%d] expected %x found %x\n", i, value, base[i]); - return false; + ERRORF(r, "[%d] expected %x found %x\n", i, value, base[i]); + return; } } - return true; } -static bool compare32(const uint32_t base[], uint32_t value, int count) { +static void compare32(skiatest::Reporter* r, const uint32_t base[], + uint32_t value, int count) { for (int i = 0; i < count; ++i) { if (base[i] != value) { - SkDebugf("[%d] expected %x found %x\n", i, value, base[i]); - return false; + ERRORF(r, "[%d] expected %x found %x\n", i, value, base[i]); + return; } } - return true; } static void test_16(skiatest::Reporter* reporter) { @@ -125,10 +125,9 @@ static void test_16(skiatest::Reporter* reporter) { uint16_t* base = &buffer[PAD + alignment]; sk_memset16(base, VALUE16, count); - REPORTER_ASSERT(reporter, - compare16(buffer, 0, PAD + alignment) && - compare16(base, VALUE16, count) && - compare16(base + count, 0, TOTAL - count - PAD - alignment)); + compare16(reporter, buffer, 0, PAD + alignment); + compare16(reporter, base, VALUE16, count); + compare16(reporter, base + count, 0, TOTAL - count - PAD - alignment); } } } @@ -143,10 +142,9 @@ static void test_32(skiatest::Reporter* reporter) { uint32_t* base = &buffer[PAD + alignment]; sk_memset32(base, VALUE32, count); - REPORTER_ASSERT(reporter, - compare32(buffer, 0, PAD + alignment) && - compare32(base, VALUE32, count) && - compare32(base + count, 0, TOTAL - count - PAD - alignment)); + compare32(reporter, buffer, 0, PAD + alignment); + compare32(reporter, base, VALUE32, count); + compare32(reporter, base + count, 0, TOTAL - count - PAD - alignment); } } } diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp index 5185eb7bd4..9d83fe6757 100644 --- a/tests/PDFJpegEmbedTest.cpp +++ b/tests/PDFJpegEmbedTest.cpp @@ -42,9 +42,9 @@ static SkData* load_resource( skiatest::Reporter* r, const char* test, const char* filename) { SkString path(GetResourcePath(filename)); SkData* data = SkData::NewFromFileName(path.c_str()); - if (!data && r->verbose()) { - SkDebugf("\n%s: Resource '%s' can not be found.\n", - test, filename); + if (!data) { + INFOF(r, "\n%s: Resource '%s' can not be found.\n", + test, filename); } return data; // May return nullptr. } @@ -143,9 +143,7 @@ DEF_TEST(JpegIdentification, r) { ERRORF(r, "%s failed jfif type test", kTests[i].path); continue; } - if (r->verbose()) { - SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, - info.fSize.width(), info.fSize.height()); - } + INFOF(r, "\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, + info.fSize.width(), info.fSize.height()); } } diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index ba95ddf8da..a4e40c54ee 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -357,7 +357,7 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { SkString filename = GetResourcePath("/fonts/test.ttc"); SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFile(filename.c_str(), 1)); if (!typeface) { - SkDebugf("Could not run fontstream test because test.ttc not found."); + INFOF(reporter, "Could not run fontstream test because test.ttc not found."); } else { serialize_and_compare_typeface(typeface, "A!", reporter); } @@ -367,13 +367,13 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { // Load typeface as stream to create with axis settings. SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); if (!distortable) { - SkDebugf("Could not run fontstream test because Distortable.ttf not found."); + INFOF(reporter, "Could not run fontstream test because Distortable.ttf not found."); } else { SkFixed axis = SK_FixedSqrt2; SkAutoTUnref<SkTypeface> typeface(SkTypeface::CreateFromFontData( new SkFontData(distortable.detach(), 0, &axis, 1))); if (!typeface) { - SkDebugf("Could not run fontstream test because Distortable.ttf not created."); + INFOF(reporter, "Could not run fontstream test because Distortable.ttf not created."); } else { serialize_and_compare_typeface(typeface, "abc", reporter); } diff --git a/tests/SrcOverTest.cpp b/tests/SrcOverTest.cpp index be64710404..7789fbdd50 100644 --- a/tests/SrcOverTest.cpp +++ b/tests/SrcOverTest.cpp @@ -42,8 +42,8 @@ DEF_TEST(SrcOver, reporter) { opaqueCounter2 += (result2 == 0xFF); } #if 0 - SkDebugf("---- opaque test: [%d %d %d]\n", - opaqueCounter0, opaqueCounter1, opaqueCounter2); + INFOF(reporter, "---- opaque test: [%d %d %d]\n", + opaqueCounter0, opaqueCounter1, opaqueCounter2); #endif // we acknowledge that technique0 does not always return opaque REPORTER_ASSERT(reporter, opaqueCounter0 == 256); @@ -67,8 +67,8 @@ DEF_TEST(SrcOver, reporter) { #if 0 // this shows where r1 (faster) differs from r2 (more exact) if (r1 != r2) { - SkDebugf("--- dst=%d i=%d r1=%d r2=%d exact=%g\n", - dst, i, r1, r2, i + dst - dst*i/255.0f); + INFOF(reporter, "--- dst=%d i=%d r1=%d r2=%d exact=%g\n", + dst, i, r1, r2, i + dst - dst*i/255.0f); } #endif } diff --git a/tests/StreamTest.cpp b/tests/StreamTest.cpp index 2a60a7b10f..a3df8d71bb 100644 --- a/tests/StreamTest.cpp +++ b/tests/StreamTest.cpp @@ -164,9 +164,8 @@ static void TestPackedUInt(skiatest::Reporter* reporter) { for (i = 0; i < SK_ARRAY_COUNT(sizes); ++i) { size_t n = rstream.readPackedUInt(); if (sizes[i] != n) { - SkDebugf("-- %d: sizes:%x n:%x\n", i, sizes[i], n); + ERRORF(reporter, "sizes:%x != n:%x\n", i, sizes[i], n); } - REPORTER_ASSERT(reporter, sizes[i] == n); } } diff --git a/tests/Test.h b/tests/Test.h index fb0fd1fec8..d643c8382a 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -106,6 +106,13 @@ void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* REPORT_FAILURE(r, "", SkStringPrintf(__VA_ARGS__)); \ } while (0) +#define INFOF(REPORTER, ...) \ + do { \ + if ((REPORTER)->verbose()) { \ + SkDebugf(__VA_ARGS__); \ + } \ + } while (0) + #define DEF_TEST(name, reporter) \ static void test_##name(skiatest::Reporter*, GrContextFactory*); \ skiatest::TestRegistry name##TestRegistry( \ @@ -152,9 +159,7 @@ void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* SkDynamicMemoryWStream testStream; \ SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ if (!testDoc) { \ - if ((REPORTER) && (REPORTER)->verbose()) { \ - SkDebugf("PDF disabled; %s test skipped.", #TEST_NAME); \ - } \ + INFOF(REPORTER, "PDF disabled; %s test skipped.", #TEST_NAME); \ return; \ } \ } while (false) diff --git a/tests/Time.cpp b/tests/Time.cpp index cf4f80f9da..f6bf9ff3f5 100644 --- a/tests/Time.cpp +++ b/tests/Time.cpp @@ -49,8 +49,6 @@ DEF_TEST(Time_GetDateTime, r) { SkString timeStamp; dateTime.toISO8601(&timeStamp); REPORTER_ASSERT(r, timeStamp.size() > 0); - if (r->verbose()) { // `dm --veryVerbose` - SkDebugf("\nCurrent Time (ISO-8601 format): \"%s\"\n", - timeStamp.c_str()); - } + INFOF(r, "\nCurrent Time (ISO-8601 format): \"%s\"\n", + timeStamp.c_str()); } diff --git a/tests/WArrayTest.cpp b/tests/WArrayTest.cpp index 48be952637..40128fa2b4 100644 --- a/tests/WArrayTest.cpp +++ b/tests/WArrayTest.cpp @@ -141,7 +141,7 @@ class TestWData { , fSubset(subset) , fSubsetLen(subsetLen) , fExpected(expected) { - REPORTER_ASSERT(reporter, RunTest()); + this->runTest(reporter); } private: @@ -160,16 +160,14 @@ class TestWData { return false; } - bool RunTest() { + void runTest(skiatest::Reporter* reporter) { SkAutoTDelete<SkAdvancedTypefaceMetrics::AdvanceMetric<int16_t> > result; result.reset(getAdvanceData((void*)this, fAdvancesLen, fSubset, fSubsetLen, getAdvance)); SkString stringResult = stringify_advance_data(result); if (!stringResult.equals(fExpected)) { - SkDebugf("Expected: %s\n Result: %s\n", fExpected, stringResult.c_str()); - return false; + ERRORF(reporter, "Expected: %s\n Result: %s\n", fExpected, stringResult.c_str()); } - return true; } }; diff --git a/tests/YUVTest.cpp b/tests/YUVTest.cpp index 09b6f2a7ef..b8c4e3598e 100644 --- a/tests/YUVTest.cpp +++ b/tests/YUVTest.cpp @@ -21,7 +21,7 @@ static void codec_yuv(skiatest::Reporter* reporter, SkISize expectedSizes[3]) { SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { - SkDebugf("Missing resource '%s'\n", path); + INFOF(reporter, "Missing resource '%s'\n", path); return; } SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach())); |