зеркало из https://github.com/mozilla/moz-skia.git
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
This commit is contained in:
Родитель
9d1cff124c
Коммит
16cfe40276
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче