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 "OverwriteLine.h" | 8 #include "OverwriteLine.h" |
9 #include "SkCommandLineFlags.h" | 9 #include "SkCommandLineFlags.h" |
10 #include "SkGraphics.h" | 10 #include "SkGraphics.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 using namespace skiatest; | 22 using namespace skiatest; |
23 | 23 |
24 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ | 24 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ |
25 "Multiple matches may be separated by spaces.\n"
\ | 25 "Multiple matches may be separated by spaces.\n"
\ |
26 "~ causes a matching test to always be skipped\n"
\ | 26 "~ causes a matching test to always be skipped\n"
\ |
27 "^ requires the start of the test to match\n" \ | 27 "^ requires the start of the test to match\n" \ |
28 "$ requires the end of the test to match\n" \ | 28 "$ requires the end of the test to match\n" \ |
29 "^ and $ requires an exact match\n" \ | 29 "^ and $ requires an exact match\n" \ |
30 "If a test does not match any list entry,\n" \ | 30 "If a test does not match any list entry,\n" \ |
31 "it is skipped unless some list entry starts with
~"); | 31 "it is skipped unless some list entry starts with
~"); |
32 DEFINE_string2(tmpDir, t, NULL, "tmp directory for tests to use."); | |
33 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | |
34 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); | 32 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); |
35 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); | 33 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); |
36 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); | 34 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); |
37 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); | 35 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
38 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); | 36 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
39 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); | 37 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); |
40 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); | 38 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); |
41 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, | 39 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, |
42 "Run threadsafe tests on a threadpool with this many threads."); | 40 "Run threadsafe tests on a threadpool with this many threads."); |
43 | 41 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 time.printf("%5dms ", test->elapsedMs()); | 89 time.printf("%5dms ", test->elapsedMs()); |
92 } | 90 } |
93 SkDebugf("%s[%3d/%3d] %s%s", prefix.c_str(), done, fTotal, time.c_str(),
test->getName()); | 91 SkDebugf("%s[%3d/%3d] %s%s", prefix.c_str(), done, fTotal, time.c_str(),
test->getName()); |
94 } | 92 } |
95 | 93 |
96 private: | 94 private: |
97 int32_t fDone; // atomic | 95 int32_t fDone; // atomic |
98 const int fTotal; | 96 const int fTotal; |
99 }; | 97 }; |
100 | 98 |
101 SkString Test::GetTmpDir() { | |
102 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? NULL : FLAGS_tmpDir[0]; | |
103 return SkString(tmpDir); | |
104 } | |
105 | |
106 SkString Test::GetResourcePath() { | |
107 const char* resourcePath = FLAGS_resourcePath.isEmpty() ? NULL : FLAGS_resou
rcePath[0]; | |
108 return SkString(resourcePath); | |
109 } | |
110 | |
111 // Deletes self when run. | 99 // Deletes self when run. |
112 class SkTestRunnable : public SkRunnable { | 100 class SkTestRunnable : public SkRunnable { |
113 public: | 101 public: |
114 // Takes ownership of test. | 102 // Takes ownership of test. |
115 SkTestRunnable(Test* test, int32_t* failCount) : fTest(test), fFailCount(failC
ount) {} | 103 SkTestRunnable(Test* test, int32_t* failCount) : fTest(test), fFailCount(failC
ount) {} |
116 | 104 |
117 virtual void run() { | 105 virtual void run() { |
118 fTest->run(); | 106 fTest->run(); |
119 if(!fTest->passed()) { | 107 if(!fTest->passed()) { |
120 sk_atomic_inc(fFailCount); | 108 sk_atomic_inc(fFailCount); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 207 } |
220 | 208 |
221 // Block until threaded tests finish. | 209 // Block until threaded tests finish. |
222 threadpool.wait(); | 210 threadpool.wait(); |
223 | 211 |
224 if (FLAGS_verbose) { | 212 if (FLAGS_verbose) { |
225 SkDebugf("\nFinished %d tests, %d failures, %d skipped. (%d internal tes
ts)", | 213 SkDebugf("\nFinished %d tests, %d failures, %d skipped. (%d internal tes
ts)", |
226 toRun, failCount, skipCount, reporter.countTests()); | 214 toRun, failCount, skipCount, reporter.countTests()); |
227 } | 215 } |
228 SkGraphics::Term(); | 216 SkGraphics::Term(); |
229 GpuTest::DestroyContexts(); | |
230 | 217 |
231 SkDebugf("\n"); | 218 SkDebugf("\n"); |
232 return (failCount == 0) ? 0 : 1; | 219 return (failCount == 0) ? 0 : 1; |
233 } | 220 } |
234 | 221 |
235 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 222 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
236 int main(int argc, char * const argv[]) { | 223 int main(int argc, char * const argv[]) { |
237 return tool_main(argc, (char**) argv); | 224 return tool_main(argc, (char**) argv); |
238 } | 225 } |
239 #endif | 226 #endif |
OLD | NEW |