Improve error reporting in ProcessorCloneTest.
Previously, when REPORTER_ASSERT reported a failure, there was no
additional information describing the FP that could not be cloned in the
error log. Now, we print out a very simple tree of the FP and its
children.
Change-Id: I141cfb17ca431864a6f555d56f0335293f259c4e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/296452
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index dfd9b51..e4fa193 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -725,6 +725,23 @@
}
}
+static void describe_fp_children(const GrFragmentProcessor& fp,
+ std::string indent,
+ SkString* text) {
+ for (int index = 0; index < fp.numChildProcessors(); ++index) {
+ const GrFragmentProcessor& childFP = fp.childProcessor(index);
+ text->appendf("\n%s(#%d) -> %s", indent.c_str(), index, childFP.name());
+ describe_fp_children(childFP, indent + "\t", text);
+ }
+}
+
+static SkString describe_fp(const GrFragmentProcessor& fp) {
+ SkString text;
+ text.printf("\n%s", fp.name());
+ describe_fp_children(fp, "\t", &text);
+ return text;
+}
+
// Tests that fragment processors returned by GrFragmentProcessor::clone() are equivalent to their
// progenitors.
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) {
@@ -767,22 +784,30 @@
for (int i = 0; i < GrFragmentProcessorTestFactory::Count(); ++i) {
static constexpr int kTimesToInvokeFactory = 10;
for (int j = 0; j < kTimesToInvokeFactory; ++j) {
- auto fp = GrFragmentProcessorTestFactory::MakeIdx(i, &testData);
- auto clone = fp->clone();
+ std::unique_ptr<GrFragmentProcessor> fp =
+ GrFragmentProcessorTestFactory::MakeIdx(i, &testData);
+ std::unique_ptr<GrFragmentProcessor> clone = fp->clone();
if (!clone) {
ERRORF(reporter, "Clone of processor %s failed.", fp->name());
continue;
}
const char* name = fp->name();
- REPORTER_ASSERT(reporter, !strcmp(fp->name(), clone->name()));
+ REPORTER_ASSERT(reporter, !strcmp(fp->name(), clone->name()),
+ "%s\n", describe_fp(*fp).c_str());
REPORTER_ASSERT(reporter, fp->compatibleWithCoverageAsAlpha() ==
- clone->compatibleWithCoverageAsAlpha());
- REPORTER_ASSERT(reporter, fp->isEqual(*clone));
- REPORTER_ASSERT(reporter, fp->preservesOpaqueInput() == clone->preservesOpaqueInput());
+ clone->compatibleWithCoverageAsAlpha(),
+ "%s\n", describe_fp(*fp).c_str());
+ REPORTER_ASSERT(reporter, fp->isEqual(*clone),
+ "%s\n", describe_fp(*fp).c_str());
+ REPORTER_ASSERT(reporter, fp->preservesOpaqueInput() == clone->preservesOpaqueInput(),
+ "%s\n", describe_fp(*fp).c_str());
REPORTER_ASSERT(reporter, fp->hasConstantOutputForConstantInput() ==
- clone->hasConstantOutputForConstantInput());
- REPORTER_ASSERT(reporter, fp->numChildProcessors() == clone->numChildProcessors());
- REPORTER_ASSERT(reporter, fp->usesLocalCoords() == clone->usesLocalCoords());
+ clone->hasConstantOutputForConstantInput(),
+ "%s\n", describe_fp(*fp).c_str());
+ REPORTER_ASSERT(reporter, fp->numChildProcessors() == clone->numChildProcessors(),
+ "%s\n", describe_fp(*fp).c_str());
+ REPORTER_ASSERT(reporter, fp->usesLocalCoords() == clone->usesLocalCoords(),
+ "%s\n", describe_fp(*fp).c_str());
// Draw with original and read back the results.
render_fp(context, rtc.get(), fp.get(), inputTexture, kPremul_SkAlphaType,
readData1.get());