Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: dm/DM.cpp

Issue 830513004: Simplify skiatest framework. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/DataRefTest.cpp » ('j') | tests/Test.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15
16 DEFINE_bool(tests, true, "Run tests?"); 16 DEFINE_bool(tests, true, "Run tests?");
17 DEFINE_string(images, "resources", "Images to decode."); 17 DEFINE_string(images, "resources", "Images to decode.");
18 //DEFINE_string(src, "gm skp image subset", "Source types to test."); 18 //DEFINE_string(src, "gm skp image subset", "Source types to test.");
19 DEFINE_string(src, "gm skp", "Source types to test. TEMPORARILY DISABLED"); 19 DEFINE_string(src, "gm skp", "Source types to test. TEMPORARILY DISABLED");
20 DEFINE_bool(nameByHash, false, 20 DEFINE_bool(nameByHash, false,
21 "If true, write to FLAGS_writePath[0]/<hash>.png instead of " 21 "If true, write to FLAGS_writePath[0]/<hash>.png instead of "
22 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png"); 22 "to FLAGS_writePath[0]/<config>/<sourceType>/<name>.png");
23 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests."); 23 DEFINE_bool2(pathOpsExtended, x, false, "Run extended pathOps tests.");
24 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",
25 "Matrix to apply when using 'matrix' in config."); 25 "Matrix to apply when using 'matrix' in config.");
26 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use.");
mtklein 2015/01/15 23:46:46 Let's just default this to "/tmp" so we don't have
hal.canary 2015/01/16 15:31:57 That's not cross-platform. I've added complete te
26 27
27 __SK_FORCE_IMAGE_DECODER_LINKING; 28 __SK_FORCE_IMAGE_DECODER_LINKING;
28 using namespace DM; 29 using namespace DM;
29 30
30 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 31 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
31 32
32 SK_DECLARE_STATIC_MUTEX(gFailuresMutex); 33 SK_DECLARE_STATIC_MUTEX(gFailuresMutex);
33 static SkTArray<SkString> gFailures; 34 static SkTArray<SkString> gFailures;
34 35
35 static void fail(ImplicitString err) { 36 static void fail(ImplicitString err) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 static void run_enclave(SkTArray<Task>* tasks) { 328 static void run_enclave(SkTArray<Task>* tasks) {
328 for (int i = 0; i < tasks->count(); i++) { 329 for (int i = 0; i < tasks->count(); i++) {
329 Task::Run(tasks->begin() + i); 330 Task::Run(tasks->begin() + i);
330 } 331 }
331 } 332 }
332 333
333 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 334 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
334 335
335 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment. 336 // Unit tests don't fit so well into the Src/Sink model, so we give them special treatment.
336 337
337 static struct : public skiatest::Reporter { 338 class DMTestReporter : public skiatest::Reporter {
338 void onReportFailed(const skiatest::Failure& failure) SK_OVERRIDE { 339 public:
339 SkString s; 340 DMTestReporter() : fErrorCount(0) {
mtklein 2015/01/15 23:46:46 One line for each of these?
hal.canary 2015/01/16 15:31:57 I just let clang-format do its magic. Changing Al
340 failure.getFailureString(&s); 341 }
341 fail(s); 342 int errorCount() {
mtklein 2015/01/15 23:46:46 Might as well const?
hal.canary 2015/01/16 15:31:57 Done.
343 return fErrorCount;
344 }
345 void reportFailed(const skiatest::Failure& failure) SK_OVERRIDE {
346 fail(skiatest::FailureToString(failure));
342 JsonWriter::AddTestFailure(failure); 347 JsonWriter::AddTestFailure(failure);
343 } 348 }
344 bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_pathOpsExtended; } 349 bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_pathOpsExtended; }
345 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; } 350 bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; }
346 } gTestReporter; 351 SkString getTmpDir() SK_OVERRIDE {
352 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0];
353 return SkString(tmpDir);
354 }
347 355
348 static SkTArray<SkAutoTDelete<skiatest::Test>, kMemcpyOK> gTests; 356 private:
357 int fErrorCount;
mtklein 2015/01/15 23:46:46 Where does this change?
hal.canary 2015/01/15 23:55:14 oops
358 };
359
360 static SkTArray<skiatest::Test, kMemcpyOK> gTests;
349 361
350 static void gather_tests() { 362 static void gather_tests() {
351 if (!FLAGS_tests) { 363 if (!FLAGS_tests) {
352 return; 364 return;
353 } 365 }
354 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r; r = r->next()) { 366 for (const skiatest::TestRegistry* r = skiatest::TestRegistry::Head(); r;
355 SkAutoTDelete<skiatest::Test> test(r->factory()(NULL)); 367 r = r->next()) {
356 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { 368 const skiatest::Test& test = r->factory();
mtklein 2015/01/15 23:46:46 factory returns a const&? That's at least weird n
hal.canary 2015/01/16 15:31:57 You can register anything with a SkTRegistry, but
369 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test.name)) {
357 continue; 370 continue;
358 } 371 }
359 if (test->isGPUTest() /*&& !gpu_supported()*/) { // TEMPORARILY DISABLE D 372 if (test.needsGpu /*&& !gpu_supported()*/) { // TEMPORARILY DISABLED
360 continue; 373 continue;
361 } 374 }
362 if (!test->isGPUTest() && !FLAGS_cpu) { 375 if (!test.needsGpu && !FLAGS_cpu) {
363 continue; 376 continue;
364 } 377 }
365 test->setReporter(&gTestReporter); 378 gTests.push_back(test);
366 gTests.push_back().reset(test.detach());
367 } 379 }
368 } 380 }
369 381
370 static void run_test(SkAutoTDelete<skiatest::Test>* t) { 382 static void run_test(skiatest::Test* testPtr) {
mtklein 2015/01/15 23:46:46 Let's just call this test and make test->foo() cal
hal.canary 2015/01/16 15:31:57 Done.
383 const skiatest::Test& test = *testPtr;
371 WallTimer timer; 384 WallTimer timer;
372 timer.start(); 385 timer.start();
373 skiatest::Test* test = t->get();
374 if (!FLAGS_dryRun) { 386 if (!FLAGS_dryRun) {
375 GrContextFactory grFactory; 387 GrContextFactory grFactory;
376 test->setGrContextFactory(&grFactory); 388 DMTestReporter reporter;
377 test->run(); 389 test.proc(&reporter, &grFactory);
378 if (!test->passed()) { 390 if (0 != reporter.errorCount()) {
379 fail(SkStringPrintf("test %s failed", test->getName())); 391 fail(SkStringPrintf("test %s failed", test.name));
380 } 392 }
381 } 393 }
382 timer.end(); 394 timer.end();
383 done(timer.fWall, "unit", "test", test->getName()); 395 done(timer.fWall, "unit", "test", test.name);
384 } 396 }
385 397
386 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/ 398 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~*/
387 399
388 int dm_main(); 400 int dm_main();
389 int dm_main() { 401 int dm_main() {
390 SetupCrashHandler(); 402 SetupCrashHandler();
391 SkAutoGraphics ag; 403 SkAutoGraphics ag;
392 SkTaskGroup::Enabler enabled(FLAGS_threads); 404 SkTaskGroup::Enabler enabled(FLAGS_threads);
393 405
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 451 }
440 return 0; 452 return 0;
441 } 453 }
442 454
443 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 455 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
444 int main(int argc, char** argv) { 456 int main(int argc, char** argv) {
445 SkCommandLineFlags::Parse(argc, argv); 457 SkCommandLineFlags::Parse(argc, argv);
446 return dm_main(); 458 return dm_main();
447 } 459 }
448 #endif 460 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/DataRefTest.cpp » ('j') | tests/Test.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698