rename tests/main to testmain.cpp
add ANDROID specific work-around for double-cinit bug
git-svn-id: http://skia.googlecode.com/svn/trunk@142 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/Makefile b/Makefile
index 715f7e1..ddfecfc 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,8 @@
TESTS_SRCS := GeometryTest.cpp MathTest.cpp MatrixTest.cpp PackBitsTest.cpp \
Sk64Test.cpp StringTest.cpp Test.cpp UtilsTest.cpp PathTest.cpp \
ClipCubicTest.cpp SrcOverTest.cpp StreamTest.cpp SortTest.cpp \
- PathMeasureTest.cpp TriangulationTest.cpp main.cpp
+ PathMeasureTest.cpp TriangulationTest.cpp \
+ testmain.cpp
TESTS_SRCS := $(addprefix tests/, $(TESTS_SRCS))
diff --git a/include/core/SkTRegistry.h b/include/core/SkTRegistry.h
index f0f427c..78c5a07 100644
--- a/include/core/SkTRegistry.h
+++ b/include/core/SkTRegistry.h
@@ -28,6 +28,18 @@
typedef T (*Factory)(P);
SkTRegistry(Factory fact) {
+#ifdef ANDROID
+ // work-around for double-initialization bug
+ {
+ SkTRegistry* reg = gHead;
+ while (reg) {
+ if (reg == this) {
+ return;
+ }
+ reg = reg->fChain;
+ }
+ }
+#endif
fFact = fact;
fChain = gHead;
gHead = this;
diff --git a/tests/main.cpp b/tests/testmain.cpp
similarity index 74%
rename from tests/main.cpp
rename to tests/testmain.cpp
index 13f8817..57d7c04 100644
--- a/tests/main.cpp
+++ b/tests/testmain.cpp
@@ -28,6 +28,16 @@
return NULL;
}
+ static int Count() {
+ const TestRegistry* reg = TestRegistry::Head();
+ int count = 0;
+ while (reg) {
+ count += 1;
+ reg = reg->next();
+ }
+ return count;
+ }
+
private:
Reporter* fReporter;
const TestRegistry* fReg;
@@ -38,14 +48,21 @@
}
class DebugfReporter : public Reporter {
+public:
+ void setIndexOfTotal(int index, int total) {
+ fIndex = index;
+ fTotal = total;
+ }
protected:
virtual void onStart(Test* test) {
- SkDebugf("Running %s...\n", test->getName());
+ SkDebugf("Running [%d/%d] %s...\n", fIndex+1, fTotal, test->getName());
}
virtual void onReport(const char desc[], Reporter::Result result) {
SkDebugf("\t%s: %s\n", result2string(result), desc);
}
virtual void onEnd(Test* test) {}
+private:
+ int fIndex, fTotal;
};
class SkAutoGraphics {
@@ -65,17 +82,23 @@
Iter iter(&reporter);
Test* test;
+ const int count = Iter::Count();
+ int index = 0;
while ((test = iter.next()) != NULL) {
+ reporter.setIndexOfTotal(index, count);
test->run();
SkDELETE(test);
+ index += 1;
}
-
+ SkDebugf("Finished %d tests.\n", count);
+
+#if 0
int total = reporter.countTests();
int passed = reporter.countResults(Reporter::kPassed);
int failed = reporter.countResults(Reporter::kFailed);
SkDebugf("Tests=%d Passed=%d (%g%%) Failed=%d (%g%%)\n", total,
passed, passed * 100.f / total,
failed, failed * 100.f / total);
-
+#endif
return 0;
}