aboutsummaryrefslogtreecommitdiff
path: root/tests/skia_test.cpp
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-26 16:31:22 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-02-26 16:31:22 +0000
commit0dc5bd149a8b69e8dc6d3b4713b827659c9b0a6b (patch)
tree53fdc1e7747c8ed33c275deb6f24802bc41d365a /tests/skia_test.cpp
parent1e762d39bb6383d33d8e1f04a296f164aa2a6beb (diff)
downloadskia-0dc5bd149a8b69e8dc6d3b4713b827659c9b0a6b.tar.gz
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=reed@google.com, bsalomon@google.com, mtklein@google.com, tfarina@chromium.org Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/178273002 git-svn-id: http://skia.googlecode.com/svn/trunk@13592 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/skia_test.cpp')
-rw-r--r--tests/skia_test.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 48d87719d..3ecb67673 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -17,6 +17,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
+#include "GrContextFactory.h"
#endif
using namespace skiatest;
@@ -29,8 +30,6 @@ 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.");
@@ -40,6 +39,7 @@ 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,16 +98,6 @@ 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:
@@ -144,6 +134,7 @@ 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) {
@@ -199,7 +190,7 @@ int tool_main(int argc, char** argv) {
int skipCount = 0;
SkThreadPool threadpool(FLAGS_threads);
- SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnable
+ SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable
DebugfReporter reporter(toRun);
for (int i = 0; i < total; i++) {
@@ -207,15 +198,23 @@ int tool_main(int argc, char** argv) {
if (!should_run(test->getName(), test->isGPUTest())) {
++skipCount;
} else if (test->isGPUTest()) {
- unsafeTests.push_back() = test.detach();
+ gpuTests.push_back() = test.detach();
} else {
threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount)));
}
}
- // Run the tests that aren't threadsafe.
- for (int i = 0; i < unsafeTests.count(); i++) {
- SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run();
+#if SK_SUPPORT_GPU
+ // Give GPU tests a context factory if that makes sense on this machine.
+ GrContextFactory grContextFactory;
+ for (int i = 0; i < gpuTests.count(); i++) {
+ gpuTests[i]->setGrContextFactory(&grContextFactory);
+ }
+#endif
+
+ // Run GPU tests on this thread.
+ for (int i = 0; i < gpuTests.count(); i++) {
+ SkNEW_ARGS(SkTestRunnable, (gpuTests[i], &failCount))->run();
}
// Block until threaded tests finish.
@@ -226,7 +225,6 @@ int tool_main(int argc, char** argv) {
toRun, failCount, skipCount, reporter.countTests());
}
SkGraphics::Term();
- GpuTest::DestroyContexts();
SkDebugf("\n");
return (failCount == 0) ? 0 : 1;