OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "OverwriteLine.h" | 9 #include "OverwriteLine.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
11 #include "SkCommandLineFlags.h" | 11 #include "SkCommandLineFlags.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 #include "SkOSFile.h" | 13 #include "SkOSFile.h" |
14 #include "SkTArray.h" | 14 #include "SkTArray.h" |
15 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
16 #include "SkThreadPool.h" | 16 #include "ThreadPool.h" |
17 #include "SkTime.h" | 17 #include "SkTime.h" |
18 #include "Test.h" | 18 #include "Test.h" |
19 | 19 |
20 #if SK_SUPPORT_GPU | 20 #if SK_SUPPORT_GPU |
21 #include "GrContext.h" | 21 #include "GrContext.h" |
22 #include "GrContextFactory.h" | 22 #include "GrContextFactory.h" |
23 #endif | 23 #endif |
24 | 24 |
25 using namespace skiatest; | 25 using namespace skiatest; |
26 | 26 |
27 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ | 27 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ |
28 "Multiple matches may be separated by spaces.\n"
\ | 28 "Multiple matches may be separated by spaces.\n"
\ |
29 "~ causes a matching test to always be skipped\n"
\ | 29 "~ causes a matching test to always be skipped\n"
\ |
30 "^ requires the start of the test to match\n" \ | 30 "^ requires the start of the test to match\n" \ |
31 "$ requires the end of the test to match\n" \ | 31 "$ requires the end of the test to match\n" \ |
32 "^ and $ requires an exact match\n" \ | 32 "^ and $ requires an exact match\n" \ |
33 "If a test does not match any list entry,\n" \ | 33 "If a test does not match any list entry,\n" \ |
34 "it is skipped unless some list entry starts with
~"); | 34 "it is skipped unless some list entry starts with
~"); |
35 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); | 35 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); |
36 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); | 36 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); |
37 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); | 37 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); |
38 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); | 38 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
39 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); | 39 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
40 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); | 40 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); |
41 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); | 41 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); |
42 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, | 42 DEFINE_int32(threads, ThreadPool::kThreadPerCore, |
43 "Run threadsafe tests on a threadpool with this many threads."); | 43 "Run threadsafe tests on a threadpool with this many threads."); |
44 | 44 |
45 // need to explicitly declare this, or we get some weird infinite loop llist | 45 // need to explicitly declare this, or we get some weird infinite loop llist |
46 template TestRegistry* TestRegistry::gHead; | 46 template TestRegistry* TestRegistry::gHead; |
47 | 47 |
48 class Iter { | 48 class Iter { |
49 public: | 49 public: |
50 Iter() { this->reset(); } | 50 Iter() { this->reset(); } |
51 void reset() { fReg = TestRegistry::Head(); } | 51 void reset() { fReg = TestRegistry::Head(); } |
52 | 52 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 SkDebugf("%s[%3d/%3d] %s%s", prefix.c_str(), done, fTotal, time.c_str(),
test->getName()); | 94 SkDebugf("%s[%3d/%3d] %s%s", prefix.c_str(), done, fTotal, time.c_str(),
test->getName()); |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 int32_t fDone; // atomic | 98 int32_t fDone; // atomic |
99 const int fTotal; | 99 const int fTotal; |
100 }; | 100 }; |
101 | 101 |
102 // Deletes self when run. | 102 // Deletes self when run. |
103 class SkTestRunnable : public SkRunnable { | 103 class SkTestRunnable : public Runnable { |
104 public: | 104 public: |
105 // Takes ownership of test. | 105 // Takes ownership of test. |
106 SkTestRunnable(Test* test, int32_t* failCount) : fTest(test), fFailCount(failC
ount) {} | 106 SkTestRunnable(Test* test, int32_t* failCount) : fTest(test), fFailCount(failC
ount) {} |
107 | 107 |
108 virtual void run() { | 108 virtual void run() { |
109 fTest->run(); | 109 fTest->run(); |
110 if(!fTest->passed()) { | 110 if(!fTest->passed()) { |
111 sk_atomic_inc(fFailCount); | 111 sk_atomic_inc(fFailCount); |
112 } | 112 } |
113 SkDELETE(this); | 113 SkDELETE(this); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 toRun++; | 186 toRun++; |
187 } | 187 } |
188 total++; | 188 total++; |
189 } | 189 } |
190 | 190 |
191 // Now run them. | 191 // Now run them. |
192 iter.reset(); | 192 iter.reset(); |
193 int32_t failCount = 0; | 193 int32_t failCount = 0; |
194 int skipCount = 0; | 194 int skipCount = 0; |
195 | 195 |
196 SkThreadPool threadpool(FLAGS_threads); | 196 ThreadPool threadpool(FLAGS_threads); |
197 SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable | 197 SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable |
198 | 198 |
199 DebugfReporter reporter(toRun); | 199 DebugfReporter reporter(toRun); |
200 for (int i = 0; i < total; i++) { | 200 for (int i = 0; i < total; i++) { |
201 SkAutoTDelete<Test> test(iter.next(&reporter)); | 201 SkAutoTDelete<Test> test(iter.next(&reporter)); |
202 if (!should_run(test->getName(), test->isGPUTest())) { | 202 if (!should_run(test->getName(), test->isGPUTest())) { |
203 ++skipCount; | 203 ++skipCount; |
204 } else if (test->isGPUTest()) { | 204 } else if (test->isGPUTest()) { |
205 gpuTests.push_back() = test.detach(); | 205 gpuTests.push_back() = test.detach(); |
206 } else { | 206 } else { |
(...skipping 25 matching lines...) Expand all Loading... |
232 | 232 |
233 SkDebugf("\n"); | 233 SkDebugf("\n"); |
234 return (failCount == 0) ? 0 : 1; | 234 return (failCount == 0) ? 0 : 1; |
235 } | 235 } |
236 | 236 |
237 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 237 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
238 int main(int argc, char * const argv[]) { | 238 int main(int argc, char * const argv[]) { |
239 return tool_main(argc, (char**) argv); | 239 return tool_main(argc, (char**) argv); |
240 } | 240 } |
241 #endif | 241 #endif |
OLD | NEW |