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