| 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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
| 9 #include "SkGraphics.h" | 9 #include "SkGraphics.h" |
| 10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
| 11 #include "SkRunnable.h" | |
| 12 #include "SkTArray.h" | 11 #include "SkTArray.h" |
| 13 #include "SkTemplates.h" | 12 #include "SkTemplates.h" |
| 14 #include "SkThreadPool.h" | 13 #include "SkThreadPool.h" |
| 15 #include "SkTime.h" | 14 #include "SkTime.h" |
| 16 #include "Test.h" | 15 #include "Test.h" |
| 17 | 16 |
| 18 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 19 #include "GrContext.h" | 18 #include "GrContext.h" |
| 20 #endif | 19 #endif |
| 21 | 20 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 221 } |
| 223 total++; | 222 total++; |
| 224 } | 223 } |
| 225 reporter.setTotal(toRun); | 224 reporter.setTotal(toRun); |
| 226 | 225 |
| 227 // Now run them. | 226 // Now run them. |
| 228 iter.reset(); | 227 iter.reset(); |
| 229 int32_t failCount = 0; | 228 int32_t failCount = 0; |
| 230 int skipCount = 0; | 229 int skipCount = 0; |
| 231 | 230 |
| 232 SkAutoTDelete<SkThreadPool> threadpool(SkNEW_ARGS(SkThreadPool, (FLAGS_threa
ds))); | 231 SkThreadPool threadpool(FLAGS_threads); |
| 233 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl
e | 232 SkTArray<Test*> unsafeTests; // Always passes ownership to an SkTestRunnabl
e |
| 234 for (int i = 0; i < total; i++) { | 233 for (int i = 0; i < total; i++) { |
| 235 SkAutoTDelete<Test> test(iter.next()); | 234 SkAutoTDelete<Test> test(iter.next()); |
| 236 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { | 235 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, test->getName())) { |
| 237 ++skipCount; | 236 ++skipCount; |
| 238 } else if (!test->isThreadsafe()) { | 237 } else if (!test->isThreadsafe()) { |
| 239 unsafeTests.push_back() = test.detach(); | 238 unsafeTests.push_back() = test.detach(); |
| 240 } else { | 239 } else { |
| 241 threadpool->add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCoun
t))); | 240 threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount
))); |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 | 243 |
| 245 // Run the tests that aren't threadsafe. | 244 // Run the tests that aren't threadsafe. |
| 246 for (int i = 0; i < unsafeTests.count(); i++) { | 245 for (int i = 0; i < unsafeTests.count(); i++) { |
| 247 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); | 246 SkNEW_ARGS(SkTestRunnable, (unsafeTests[i], &failCount))->run(); |
| 248 } | 247 } |
| 249 | 248 |
| 250 // Blocks until threaded tests finish. | 249 // Block until threaded tests finish. |
| 251 threadpool.free(); | 250 threadpool.wait(); |
| 252 | 251 |
| 253 SkDebugf("Finished %d tests, %d failures, %d skipped.\n", | 252 SkDebugf("Finished %d tests, %d failures, %d skipped.\n", |
| 254 toRun, failCount, skipCount); | 253 toRun, failCount, skipCount); |
| 255 const int testCount = reporter.countTests(); | 254 const int testCount = reporter.countTests(); |
| 256 if (FLAGS_verbose && testCount > 0) { | 255 if (FLAGS_verbose && testCount > 0) { |
| 257 SkDebugf("Ran %d Internal tests.\n", testCount); | 256 SkDebugf("Ran %d Internal tests.\n", testCount); |
| 258 } | 257 } |
| 259 #if SK_SUPPORT_GPU | 258 #if SK_SUPPORT_GPU |
| 260 | 259 |
| 261 #if GR_CACHE_STATS | 260 #if GR_CACHE_STATS |
| 262 GrContext *gr = GpuTest::GetContext(); | 261 GrContext *gr = GpuTest::GetContext(); |
| 263 | 262 |
| 264 gr->printCacheStats(); | 263 gr->printCacheStats(); |
| 265 #endif | 264 #endif |
| 266 | 265 |
| 267 #endif | 266 #endif |
| 268 | 267 |
| 269 SkGraphics::Term(); | 268 SkGraphics::Term(); |
| 270 GpuTest::DestroyContexts(); | 269 GpuTest::DestroyContexts(); |
| 271 | 270 |
| 272 return (failCount == 0) ? 0 : 1; | 271 return (failCount == 0) ? 0 : 1; |
| 273 } | 272 } |
| 274 | 273 |
| 275 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 274 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 276 int main(int argc, char * const argv[]) { | 275 int main(int argc, char * const argv[]) { |
| 277 return tool_main(argc, (char**) argv); | 276 return tool_main(argc, (char**) argv); |
| 278 } | 277 } |
| 279 #endif | 278 #endif |
| OLD | NEW |