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 "Resources.h" |
9 #include "SkCommandLineFlags.h" | 10 #include "SkCommandLineFlags.h" |
10 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
11 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
12 #include "SkTArray.h" | 13 #include "SkTArray.h" |
13 #include "SkTemplates.h" | 14 #include "SkTemplates.h" |
14 #include "SkThreadPool.h" | 15 #include "SkThreadPool.h" |
15 #include "SkTime.h" | 16 #include "SkTime.h" |
16 #include "Test.h" | 17 #include "Test.h" |
17 | 18 |
18 #if SK_SUPPORT_GPU | 19 #if SK_SUPPORT_GPU |
(...skipping 13 matching lines...) Expand all Loading... |
32 "it is skipped unless some list entry starts with
~"); | 33 "it is skipped unless some list entry starts with
~"); |
33 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); | 34 DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps."); |
34 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); | 35 DEFINE_bool2(leaks, l, false, "show leaked ref cnt'd objects."); |
35 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); | 36 DEFINE_bool2(single, z, false, "run tests on a single thread internally."); |
36 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); | 37 DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver."); |
37 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); | 38 DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose."); |
38 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); | 39 DEFINE_bool(cpu, true, "whether or not to run CPU tests."); |
39 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); | 40 DEFINE_bool(gpu, true, "whether or not to run GPU tests."); |
40 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, | 41 DEFINE_int32(threads, SkThreadPool::kThreadPerCore, |
41 "Run threadsafe tests on a threadpool with this many threads."); | 42 "Run threadsafe tests on a threadpool with this many threads."); |
42 DEFINE_string2(resourcePath, i, "resources", "directory for test resources."); | |
43 | 43 |
44 // need to explicitly declare this, or we get some weird infinite loop llist | 44 // need to explicitly declare this, or we get some weird infinite loop llist |
45 template TestRegistry* TestRegistry::gHead; | 45 template TestRegistry* TestRegistry::gHead; |
46 | 46 |
47 class Iter { | 47 class Iter { |
48 public: | 48 public: |
49 Iter() { this->reset(); } | 49 Iter() { this->reset(); } |
50 void reset() { fReg = TestRegistry::Head(); } | 50 void reset() { fReg = TestRegistry::Head(); } |
51 | 51 |
52 Test* next(Reporter* r) { | 52 Test* next(Reporter* r) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (!FLAGS_gpu && isGPUTest) { | 127 if (!FLAGS_gpu && isGPUTest) { |
128 return false; | 128 return false; |
129 } | 129 } |
130 return true; | 130 return true; |
131 } | 131 } |
132 | 132 |
133 int tool_main(int argc, char** argv); | 133 int tool_main(int argc, char** argv); |
134 int tool_main(int argc, char** argv) { | 134 int tool_main(int argc, char** argv) { |
135 SkCommandLineFlags::SetUsage(""); | 135 SkCommandLineFlags::SetUsage(""); |
136 SkCommandLineFlags::Parse(argc, argv); | 136 SkCommandLineFlags::Parse(argc, argv); |
137 Test::SetResourcePath(FLAGS_resourcePath[0]); | |
138 | 137 |
139 #if SK_ENABLE_INST_COUNT | 138 #if SK_ENABLE_INST_COUNT |
140 if (FLAGS_leaks) { | 139 if (FLAGS_leaks) { |
141 gPrintInstCount = true; | 140 gPrintInstCount = true; |
142 } | 141 } |
143 #endif | 142 #endif |
144 | 143 |
145 SkGraphics::Init(); | 144 SkGraphics::Init(); |
146 | 145 |
147 { | 146 { |
148 SkString header("Skia UnitTests:"); | 147 SkString header("Skia UnitTests:"); |
149 if (!FLAGS_match.isEmpty()) { | 148 if (!FLAGS_match.isEmpty()) { |
150 header.appendf(" --match"); | 149 header.appendf(" --match"); |
151 for (int index = 0; index < FLAGS_match.count(); ++index) { | 150 for (int index = 0; index < FLAGS_match.count(); ++index) { |
152 header.appendf(" %s", FLAGS_match[index]); | 151 header.appendf(" %s", FLAGS_match[index]); |
153 } | 152 } |
154 } | 153 } |
155 SkString tmpDir = Test::GetTmpDir(); | 154 SkString tmpDir = Test::GetTmpDir(); |
156 if (!tmpDir.isEmpty()) { | 155 if (!tmpDir.isEmpty()) { |
157 header.appendf(" --tmpDir %s", tmpDir.c_str()); | 156 header.appendf(" --tmpDir %s", tmpDir.c_str()); |
158 } | 157 } |
159 SkString resourcePath = Test::GetResourcePath(); | 158 SkString resourcePath = GetResourcePath(); |
160 if (!resourcePath.isEmpty()) { | 159 if (!resourcePath.isEmpty()) { |
161 header.appendf(" --resourcePath %s", resourcePath.c_str()); | 160 header.appendf(" --resourcePath %s", resourcePath.c_str()); |
162 } | 161 } |
163 #ifdef SK_DEBUG | 162 #ifdef SK_DEBUG |
164 header.append(" SK_DEBUG"); | 163 header.append(" SK_DEBUG"); |
165 #else | 164 #else |
166 header.append(" SK_RELEASE"); | 165 header.append(" SK_RELEASE"); |
167 #endif | 166 #endif |
168 header.appendf(" skia_arch_width=%d", (int)sizeof(void*) * 8); | 167 header.appendf(" skia_arch_width=%d", (int)sizeof(void*) * 8); |
169 if (FLAGS_veryVerbose) { | 168 if (FLAGS_veryVerbose) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 230 |
232 SkDebugf("\n"); | 231 SkDebugf("\n"); |
233 return (failCount == 0) ? 0 : 1; | 232 return (failCount == 0) ? 0 : 1; |
234 } | 233 } |
235 | 234 |
236 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 235 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
237 int main(int argc, char * const argv[]) { | 236 int main(int argc, char * const argv[]) { |
238 return tool_main(argc, (char**) argv); | 237 return tool_main(argc, (char**) argv); |
239 } | 238 } |
240 #endif | 239 #endif |
OLD | NEW |