diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-25 20:02:09 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-25 20:02:09 +0000 |
commit | 79e13260cf94427e6ccbfff8242bf85ed4c8187b (patch) | |
tree | decbb335453684fcbe0c9dff854c2b1968226d8a /tests | |
parent | 6bd250a2a340348434b7b16bd4e4b5da0f598e3e (diff) |
Revert of Let DM run unit tests. (https://codereview.chromium.org/178273002/)
Reason for revert:
broke tests
Original issue's description:
> Let DM run unit tests.
> - refactor GYPs and a few flags
> - make GPU tests grab a thread-local GrContextFactory when needed as we do in DM for GMs
> - add a few more UI features to make DM more like tests
>
> I believe this makes the program 'tests' obsolete.
>
> It should be somewhat faster to run the two sets together than running the old binaries serially:
> - serial: tests 20s (3m18s CPU), dm 21s (3m01s CPU)
> - together: 27s (6m21s CPU)
>
> Next up is to incorporate benches. I'm only planning there on a single-pass sanity check, so that won't obsolete the program 'bench' just yet.
>
> Tested: out/Debug/tests && out/Debug/dm && echo ok
> BUG=skia:
>
> Committed: http://code.google.com/p/skia/source/detail?r=13586
R=bsalomon@google.com, mtklein@google.com, tfarina@chromium.org, mtklein@chromium.org
TBR=bsalomon@google.com, mtklein@chromium.org, mtklein@google.com, tfarina@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Author: reed@google.com
Review URL: https://codereview.chromium.org/179403010
git-svn-id: http://skia.googlecode.com/svn/trunk@13587 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Test.cpp | 27 | ||||
-rw-r--r-- | tests/Test.h | 14 | ||||
-rw-r--r-- | tests/skia_test.cpp | 30 |
3 files changed, 38 insertions, 33 deletions
diff --git a/tests/Test.cpp b/tests/Test.cpp index 95b2f91c0c..daa23b132c 100644 --- a/tests/Test.cpp +++ b/tests/Test.cpp @@ -7,7 +7,6 @@ */ #include "Test.h" -#include "SkCommandLineFlags.h" #include "SkError.h" #include "SkString.h" #include "SkTArray.h" @@ -20,8 +19,6 @@ class GrContext; #endif -DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); - using namespace skiatest; Reporter::Reporter() : fTestCount(0) { @@ -117,15 +114,23 @@ void Test::run() { } -SkString Test::GetTmpDir() { - const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; - return SkString(tmpDir); -} +/////////////////////////////////////////////////////////////////////////////// -static const char* gResourcePath = NULL; -void Test::SetResourcePath(const char* resourcePath) { gResourcePath = resourcePath; } +#if SK_SUPPORT_GPU +#include "GrContextFactory.h" +GrContextFactory gGrContextFactory; +#endif -SkString Test::GetResourcePath() { - return SkString(gResourcePath); +GrContextFactory* GpuTest::GetGrContextFactory() { +#if SK_SUPPORT_GPU + return &gGrContextFactory; +#else + return NULL; +#endif } +void GpuTest::DestroyContexts() { +#if SK_SUPPORT_GPU + gGrContextFactory.destroyContexts(); +#endif +} diff --git a/tests/Test.h b/tests/Test.h index a175e374a8..0a9c306b15 100644 --- a/tests/Test.h +++ b/tests/Test.h @@ -62,11 +62,9 @@ namespace skiatest { static SkString GetTmpDir(); - static void SetResourcePath(const char*); static SkString GetResourcePath(); virtual bool isGPUTest() const { return false; } - virtual void setGrContextFactory(GrContextFactory* factory) {} protected: virtual void onGetName(SkString*) = 0; @@ -82,14 +80,10 @@ namespace skiatest { class GpuTest : public Test{ public: GpuTest() : Test() {} - + static GrContextFactory* GetGrContextFactory(); + static void DestroyContexts(); virtual bool isGPUTest() const { return true; } - virtual void setGrContextFactory(GrContextFactory* factory) { - fGrContextFactory = factory; - } - - protected: - GrContextFactory* fGrContextFactory; // Unowned. + private: }; typedef SkTRegistry<Test*(*)(void*)> TestRegistry; @@ -168,7 +162,7 @@ namespace skiatest { name->set(#name); \ } \ virtual void onRun(Reporter* r) SK_OVERRIDE { \ - name(r, fGrContextFactory); \ + name(r, GetGrContextFactory()); \ } \ }; \ static TestRegistry gReg_##name##Class(name##Class::Factory); \ diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp index 050a241ccd..48d87719d5 100644 --- a/tests/skia_test.cpp +++ b/tests/skia_test.cpp @@ -17,7 +17,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrContextFactory.h" #endif using namespace skiatest; @@ -30,6 +29,8 @@ DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n" "^ and $ requires an exact match\n" \ "If a test does not match any list entry,\n" \ "it is skipped unless some list entry starts with ~"); +DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); +DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); DEFINE_bool2(single, z, false, "run tests on a single thread internally."); @@ -39,7 +40,6 @@ DEFINE_bool(cpu, true, "whether or not to run CPU tests."); DEFINE_bool(gpu, true, "whether or not to run GPU tests."); DEFINE_int32(threads, SkThreadPool::kThreadPerCore, "Run threadsafe tests on a threadpool with this many threads."); -DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); // need to explicitly declare this, or we get some weird infinite loop llist template TestRegistry* TestRegistry::gHead; @@ -98,6 +98,16 @@ private: const int fTotal; }; +SkString Test::GetTmpDir() { + const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; + return SkString(tmpDir); +} + +SkString Test::GetResourcePath() { + const char* resourcePath = FLAGS_resourcePath.isEmpty() ? NULL : FLAGS_resourcePath[0]; + return SkString(resourcePath); +} + // Deletes self when run. class SkTestRunnable : public SkRunnable { public: @@ -134,7 +144,6 @@ int tool_main(int argc, char** argv); int tool_main(int argc, char** argv) { SkCommandLineFlags::SetUsage(""); SkCommandLineFlags::Parse(argc, argv); - Test::SetResourcePath(FLAGS_resourcePath[0]); #if SK_ENABLE_INST_COUNT if (FLAGS_leaks) { @@ -190,7 +199,7 @@ int tool_main(int argc, char** argv) { int skipCount = 0; SkThreadPool threadpool(FLAGS_threads); - SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable + SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnable DebugfReporter reporter(toRun); for (int i = 0; i < total; i++) { @@ -198,20 +207,16 @@ int tool_main(int argc, char** argv) { if (!should_run(test->getName(), test->isGPUTest())) { ++skipCount; } else if (test->isGPUTest()) { - gpuTests.push_back() = test.detach(); + unsafeTests.push_back() = test.detach(); } else { threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount))); } } -#if SK_SUPPORT_GPU - GrContextFactory grContextFactory; - // Run GPU tests on this thread. - for (int i = 0; i < gpuTests.count(); i++) { - gpuTests[i]->setGrContextFactory(&grContextFactory); - SkNEW_ARGS(SkTestRunnable, (gpuTests[i], &failCount))->run(); + // Run the tests that aren't threadsafe. + for (int i = 0; i < unsafeTests.count(); i++) { + SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); } -#endif // Block until threaded tests finish. threadpool.wait(); @@ -221,6 +226,7 @@ int tool_main(int argc, char** argv) { toRun, failCount, skipCount, reporter.countTests()); } SkGraphics::Term(); + GpuTest::DestroyContexts(); SkDebugf("\n"); return (failCount == 0) ? 0 : 1; |