OLD | NEW |
---|---|
1 #include "CrashHandler.h" | 1 #include "CrashHandler.h" |
2 #include "DMJsonWriter.h" | 2 #include "DMJsonWriter.h" |
3 #include "DMSrcSink.h" | 3 #include "DMSrcSink.h" |
4 #include "OverwriteLine.h" | 4 #include "OverwriteLine.h" |
5 #include "ProcStats.h" | 5 #include "ProcStats.h" |
6 #include "SkBBHFactory.h" | 6 #include "SkBBHFactory.h" |
7 #include "SkCommonFlags.h" | 7 #include "SkCommonFlags.h" |
8 #include "SkForceLinking.h" | 8 #include "SkForceLinking.h" |
9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
10 #include "SkMD5.h" | 10 #include "SkMD5.h" |
11 #include "SkOSFile.h" | 11 #include "SkOSFile.h" |
12 #include "SkTaskGroup.h" | 12 #include "SkTaskGroup.h" |
13 #include "Test.h" | 13 #include "Test.h" |
14 #include "Timer.h" | 14 #include "Timer.h" |
15 #include "TempDir.h" | |
15 | 16 |
16 DEFINE_bool(tests, true, "Run tests?"); | 17 DEFINE_bool(tests, true, "Run tests?"); |
17 DEFINE_string(images, "resources", "Images to decode."); | 18 DEFINE_string(images, "resources", "Images to decode."); |
18 DEFINE_string(src, "gm skp image subset", "Source types to test."); | 19 DEFINE_string(src, "gm skp image subset", "Source types to test."); |
19 DEFINE_bool(nameByHash, false, | 20 DEFINE_bool(nameByHash, false, |
20 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " | 21 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " |
21 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); | 22 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); |
22 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); | 23 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); |
23 DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1", | 24 DEFINE_string(matrix, "1 0 0 0 1 0 0 0 1", |
24 "Matrix to apply when using 'matrix' in config."); | 25 "Matrix to apply when using 'matrix' in config."); |
25 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); | 26 DEFINE_bool(gpu_threading, false, "Allow GPU work to run on multiple threads?"); |
26 | 27 |
27 DEFINE_string(blacklist, "", | 28 DEFINE_string(blacklist, "", |
28 "Space-separated config/src/name triples to blacklist. '_' matches anyt hing. E.g. \n" | 29 "Space-separated config/src/name triples to blacklist. '_' matches anyt hing. E.g. \n" |
29 "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu conf ig.\n" | 30 "'--blacklist gpu skp _' will blacklist all SKPs drawn into the gpu conf ig.\n" |
30 "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects GM on 8888."); | 31 "'--blacklist gpu skp _ 8888 gm aarects' will also blacklist the aarects GM on 8888."); |
31 | 32 |
32 | |
33 __SK_FORCE_IMAGE_DECODER_LINKING; | 33 __SK_FORCE_IMAGE_DECODER_LINKING; |
34 using namespace DM; | 34 using namespace DM; |
35 | 35 |
36 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 36 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
37 | 37 |
38 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); | 38 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); |
39 static SkTArray<SkString> gFailures; | 39 static SkTArray<SkString> gFailures; |
40 | 40 |
41 static void fail(ImplicitString err) { | 41 static void fail(ImplicitString err) { |
42 SkAutoMutexAcquire lock(gFailuresMutex); | 42 SkAutoMutexAcquire lock(gFailuresMutex); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 static void run_enclave(SkTArray<Task>* tasks) { | 355 static void run_enclave(SkTArray<Task>* tasks) { |
356 for (int i = 0; i < tasks->count(); i++) { | 356 for (int i = 0; i < tasks->count(); i++) { |
357 Task::Run(tasks->begin() + i); | 357 Task::Run(tasks->begin() + i); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 361 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
362 | 362 |
363 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. | 363 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. |
364 | 364 |
365 static struct : public skiatest::Reporter { | 365 class DMTestReporter : public skiatest::Reporter { |
366 void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE { | 366 public: |
367 SkString s; | 367 DMTestReporter() : fErrorCount(0) {} |
368 failure.getFailureString(&s); | 368 int errorCount() const { return fErrorCount; } |
369 fail(s); | 369 void reportFailed(const skiatest::Failure& failure) SK_OVERRIDE { |
370 ++fErrorCount; | |
371 fail(failure.toString()); | |
370 JsonWriter::AddTestFailure(failure); | 372 JsonWriter::AddTestFailure(failure); |
371 } | 373 } |
372 bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_pathOpsExtended; } | 374 bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_pathOpsExtended; } |
373 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } | 375 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } |
374 } gTestReporter; | 376 SkString getTmpDir() const SK_OVERRIDE { return sk_tools::GetTmpDir(); } |
mtklein
2015/01/18 22:57:55
Why don't we get this out of reporter and have the
hal.canary
2015/01/20 16:01:51
Done.
No longer virtual on reporter.
| |
375 | 377 |
376 static SkTArray<SkAutoTDelete<skiatest::Test>, kMemcpyOK> gCPUTests, gGPUTests; | 378 private: |
379 int fErrorCount; | |
mtklein
2015/01/18 22:57:55
Seems like this wants to be bool fPassed / fFailed
hal.canary
2015/01/20 16:01:51
Acknowledged.
| |
380 }; | |
381 | |
382 static SkTArray<skiatest::Test, kMemcpyOK> gCPUTests; | |
mtklein
2015/01/18 22:57:55
Go back to one line? Having these as separate dec
hal.canary
2015/01/20 16:01:51
Done.
| |
383 static SkTArray<skiatest::Test, kMemcpyOK> gGPUTests; | |
377 | 384 |
378 static void gather_tests() { | 385 static void gather_tests() { |
379 if (!FLAGS_tests) { | 386 if (!FLAGS_tests) { |
380 return; | 387 return; |
381 } | 388 } |
382 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) { | 389 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; |
383 SkAutoTDelete<skiatest::Test> test(r->factory()(NULL)); | 390 r = r->next()) { |
384 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { | 391 // Badly named function in SkTRegistry. |
mtklein
2015/01/18 22:57:55
Might mention you're talking about factory()?
//
hal.canary
2015/01/20 16:01:51
Done.
| |
392 const skiatest::Test& test = r->factory(); | |
393 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) { | |
385 continue; | 394 continue; |
386 } | 395 } |
387 | 396 if (test.needsGpu && gpu_supported()) { |
388 test->setReporter(&gTestReporter); | 397 gGPUTests.push_back(test); |
389 if (test->isGPUTest() && gpu_supported()) { | 398 } else if (!test.needsGpu && FLAGS_cpu) { |
390 gGPUTests.push_back().reset(test.detach()); | 399 gCPUTests.push_back(test); |
391 } else if (!test->isGPUTest() && FLAGS_cpu) { | |
392 gCPUTests.push_back().reset(test.detach()); | |
393 } | 400 } |
394 } | 401 } |
395 } | 402 } |
396 | 403 |
397 static void run_test(SkAutoTDelete<skiatest::Test>* t) { | 404 static void run_test(skiatest::Test* test) { |
398 WallTimer timer; | 405 WallTimer timer; |
399 timer.start(); | 406 timer.start(); |
400 skiatest::Test* test = t->get(); | |
401 if (!FLAGS_dryRun) { | 407 if (!FLAGS_dryRun) { |
402 test->setGrContextFactory(GetThreadLocalGrContextFactory()); | 408 DMTestReporter reporter; |
mtklein
2015/01/18 22:57:55
I'd prefer
struct : public skiatest::Reporter {
.
hal.canary
2015/01/20 16:01:52
Done.
| |
403 test->run(); | 409 test->proc(&reporter, GetThreadLocalGrContextFactory()); |
404 if (!test->passed()) { | 410 if (0 != reporter.errorCount()) { |
mtklein
2015/01/18 22:57:55
Why don't we drop this instead of having to track
hal.canary
2015/01/20 16:01:52
Done.
| |
405 fail(SkStringPrintf("test %s failed", test->getName())); | 411 fail(SkStringPrintf("test %s failed", test->name)); |
406 } | 412 } |
407 } | 413 } |
408 timer.end(); | 414 timer.end(); |
409 done(timer.fWall, "unit", "test", test->getName()); | 415 done(timer.fWall, "unit", "test", test->name); |
410 } | 416 } |
411 | 417 |
412 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ | 418 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ |
413 | 419 |
414 int dm_main(); | 420 int dm_main(); |
415 int dm_main() { | 421 int dm_main() { |
416 SetupCrashHandler(); | 422 SetupCrashHandler(); |
417 SkAutoGraphics ag; | 423 SkAutoGraphics ag; |
418 SkTaskGroup::Enabler enabled(FLAGS_threads); | 424 SkTaskGroup::Enabler enabled(FLAGS_threads); |
419 | 425 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 } | 484 } |
479 return 0; | 485 return 0; |
480 } | 486 } |
481 | 487 |
482 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 488 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
483 int main(int argc, char** argv) { | 489 int main(int argc, char** argv) { |
484 SkCommandLineFlags::Parse(argc, argv); | 490 SkCommandLineFlags::Parse(argc, argv); |
485 return dm_main(); | 491 return dm_main(); |
486 } | 492 } |
487 #endif | 493 #endif |
OLD | NEW |