diff options
author | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-18 18:47:37 +0000 |
---|---|---|
committer | caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-18 18:47:37 +0000 |
commit | 16cfe40276bfb0a4d98c9ad995b8e5b134a49b19 (patch) | |
tree | 5cd7dcd8e011fcda54c746ac313c4d89db134f75 /tests | |
parent | 9d1cff124c14e550889a5755ffa5e6537af7c8c8 (diff) |
allow tests to optionally use multiple threads
modify threaded path ops tests to check
Background: this CL came out of a conversation with Eric where I learned that 10s of machines host 100s of bots. Since the bot hosting tests may be shared with many other tasks, it seems unwise for path ops to launch multiple test threads.
The change here is to make launching multiple threads "opt-in" and by default, bots can run path ops in a single thread.
Review URL: https://codereview.chromium.org/14002007
git-svn-id: http://skia.googlecode.com/svn/trunk@8750 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PathOpsExtendedTest.cpp | 10 | ||||
-rw-r--r-- | tests/PathOpsExtendedTest.h | 2 | ||||
-rw-r--r-- | tests/PathOpsOpCubicThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsOpRectThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsQuadLineIntersectionThreadedTest.cpp | 2 | ||||
-rwxr-xr-x | tests/PathOpsSimplifyDegenerateThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsSimplifyQuadThreadedTest.cpp | 2 | ||||
-rwxr-xr-x | tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/PathOpsSimplifyRectThreadedTest.cpp | 2 | ||||
-rwxr-xr-x | tests/PathOpsSimplifyTrianglesThreadedTest.cpp | 2 | ||||
-rw-r--r-- | tests/Test.h | 2 | ||||
-rw-r--r-- | tests/skia_test.cpp | 13 |
12 files changed, 22 insertions, 21 deletions
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp index 9b27fce3e2..675918ffdf 100644 --- a/tests/PathOpsExtendedTest.cpp +++ b/tests/PathOpsExtendedTest.cpp @@ -43,12 +43,6 @@ static bool gComparePaths = true; static bool gComparePathsAssert = true; static bool gPathStrAssert = true; -#if FORCE_RELEASE -static bool gRunTestsInOneThread = true; -#else -static bool gRunTestsInOneThread = true; -#endif - static void showPathContour(SkPath::Iter& iter) { uint8_t verb; SkPoint pts[4]; @@ -522,14 +516,14 @@ bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, const int maxThreadsAllocated = 64; static int maxThreads = 1; -int initializeTests(const char* test) { +int initializeTests(skiatest::Reporter* reporter, const char* test) { #ifdef SK_DEBUG gDebugMaxWindSum = 4; gDebugMaxWindValue = 4; #endif testName = test; size_t testNameSize = strlen(test); - if (!gRunTestsInOneThread) { + if (reporter->allowThreaded()) { int threads = -1; #ifdef SK_BUILD_FOR_MAC size_t size = sizeof(threads); diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h index ece1c86bd7..5644c9415e 100644 --- a/tests/PathOpsExtendedTest.h +++ b/tests/PathOpsExtendedTest.h @@ -35,7 +35,7 @@ extern bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadSt const char* pathStr); extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path); -int initializeTests(const char* testName); +int initializeTests(skiatest::Reporter* reporter, const char* testName); void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType ); void outputProgress(char* ramStr, const char* pathStr, SkPathOp op); diff --git a/tests/PathOpsOpCubicThreadedTest.cpp b/tests/PathOpsOpCubicThreadedTest.cpp index 4197d76624..3448ee94cb 100644 --- a/tests/PathOpsOpCubicThreadedTest.cpp +++ b/tests/PathOpsOpCubicThreadedTest.cpp @@ -59,7 +59,7 @@ static void testOpCubicsMain(PathOpsThreadState* data) static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("cubicOp"); + int threadCount = initializeTests(reporter, "cubicOp"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 6; ++a) { // outermost for (int b = a + 1; b < 7; ++b) { diff --git a/tests/PathOpsOpRectThreadedTest.cpp b/tests/PathOpsOpRectThreadedTest.cpp index e7aec8a432..58e4707020 100644 --- a/tests/PathOpsOpRectThreadedTest.cpp +++ b/tests/PathOpsOpRectThreadedTest.cpp @@ -67,7 +67,7 @@ static void testPathOpsRectsMain(PathOpsThreadState* data) } static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testOp"); + int threadCount = initializeTests(reporter, "testOp"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 6; ++a) { // outermost for (int b = a + 1; b < 7; ++b) { diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp index 23adaf95e1..7d1b133fac 100644 --- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp +++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp @@ -113,7 +113,7 @@ static void testQuadLineIntersectMain(PathOpsThreadState* data) static void PathOpsQuadLineIntersectionThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testQuadLineIntersect"); + int threadCount = initializeTests(reporter, "testQuadLineIntersect"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 16; ++a) { for (int b = 0 ; b < 16; ++b) { diff --git a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp index 1c1f9cad62..22997e7a9c 100755 --- a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp +++ b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp @@ -61,7 +61,7 @@ static void testSimplifyDegeneratesMain(PathOpsThreadState* data) { } static void PathOpsSimplifyDegeneratesThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testDegenerates"); + int threadCount = initializeTests(reporter, "testDegenerates"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 16; ++a) { int ax = a & 0x03; diff --git a/tests/PathOpsSimplifyQuadThreadedTest.cpp b/tests/PathOpsSimplifyQuadThreadedTest.cpp index 0290602eee..8dea049a6e 100644 --- a/tests/PathOpsSimplifyQuadThreadedTest.cpp +++ b/tests/PathOpsSimplifyQuadThreadedTest.cpp @@ -68,7 +68,7 @@ static void testSimplifyQuadsMain(PathOpsThreadState* data) static void PathOpsSimplifyQuadsThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testQuads"); + int threadCount = initializeTests(reporter, "testQuads"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); int a = 0; for (; a < 16; ++a) { diff --git a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp index 99cd79e556..5afadbe88e 100755 --- a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp +++ b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp @@ -69,7 +69,7 @@ static void testSimplifyQuadralateralsMain(PathOpsThreadState* data) } static void PathOpsSimplifyQuadralateralsThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testQuadralaterals"); + int threadCount = initializeTests(reporter, "testQuadralaterals"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 16; ++a) { for (int b = a ; b < 16; ++b) { diff --git a/tests/PathOpsSimplifyRectThreadedTest.cpp b/tests/PathOpsSimplifyRectThreadedTest.cpp index 33863cfe57..66b70d3142 100644 --- a/tests/PathOpsSimplifyRectThreadedTest.cpp +++ b/tests/PathOpsSimplifyRectThreadedTest.cpp @@ -173,7 +173,7 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data) static void PathOpsSimplifyRectsThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testLine"); + int threadCount = initializeTests(reporter, "testLine"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 8; ++a) { // outermost for (int b = a ; b < 8; ++b) { diff --git a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp index 42aad38a48..8d1e8db596 100755 --- a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp +++ b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp @@ -66,7 +66,7 @@ static void testSimplifyTrianglesMain(PathOpsThreadState* data) { } static void PathOpsSimplifyTrianglesThreadedTest(skiatest::Reporter* reporter) { - int threadCount = initializeTests("testTriangles"); + int threadCount = initializeTests(reporter, "testTriangles"); PathOpsThreadedTestRunner testRunner(reporter, threadCount); for (int a = 0; a < 15; ++a) { int ax = a & 0x03; diff --git a/tests/Test.h b/tests/Test.h index bfb4d60761..6b0b90101e 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -43,7 +43,7 @@ namespace skiatest { void report(const char testDesc[], Result); void endTest(Test*); virtual bool allowExtendedTest() const { return false; } - + virtual bool allowThreaded() const { return false; } // helpers for tests void assertTrue(bool cond, const char desc[]) { if (!cond) { diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index 0851f8e661..fd56cc71fb 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -62,10 +62,11 @@ static const char* result2string(Reporter::Result result) { class DebugfReporter : public Reporter { public: - DebugfReporter(bool allowExtendedTest) + DebugfReporter(bool allowExtendedTest, bool allowThreaded) : fIndex(0) , fTotal(0) - , fAllowExtendedTest(allowExtendedTest) { + , fAllowExtendedTest(allowExtendedTest) + , fAllowThreaded(allowThreaded) { } void setIndexOfTotal(int index, int total) { @@ -77,6 +78,10 @@ public: return fAllowExtendedTest; } + virtual bool allowThreaded() const { + return fAllowThreaded; + } + protected: virtual void onStart(Test* test) { SkDebugf("[%d/%d] %s...\n", fIndex+1, fTotal, test->getName()); @@ -92,6 +97,7 @@ protected: private: int fIndex, fTotal; bool fAllowExtendedTest; + bool fAllowThreaded; }; static const char* make_canonical_dir_path(const char* path, SkString* storage) { @@ -126,6 +132,7 @@ DEFINE_string2(match, m, NULL, "substring of test name to run."); DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); DEFINE_string2(resourcePath, i, NULL, "directory for test resources."); DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); +DEFINE_bool2(threaded, z, false, "allow tests to use multiple threads."); DEFINE_bool2(verbose, v, false, "enable verbose output."); int tool_main(int argc, char** argv); @@ -170,7 +177,7 @@ int tool_main(int argc, char** argv) { SkDebugf("%s\n", header.c_str()); } - DebugfReporter reporter(FLAGS_extendedTest); + DebugfReporter reporter(FLAGS_extendedTest, FLAGS_threaded); Iter iter(&reporter); Test* test; |