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" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 virtual bool allowThreaded() const SK_OVERRIDE { | 77 virtual bool allowThreaded() const SK_OVERRIDE { |
78 return fAllowThreaded; | 78 return fAllowThreaded; |
79 } | 79 } |
80 | 80 |
81 virtual bool verbose() const SK_OVERRIDE { | 81 virtual bool verbose() const SK_OVERRIDE { |
82 return fVerbose; | 82 return fVerbose; |
83 } | 83 } |
84 | 84 |
85 protected: | 85 protected: |
86 virtual void onStart(Test* test) { | 86 virtual void onStart(Test* test) { |
87 const int index = sk_atomic_inc(&fNextIndex)+1; | 87 SkAutoMutexAcquire lock(fStartEndMutex); |
88 const int pending = sk_atomic_inc(&fPending)+1; | 88 fNextIndex++; |
89 SkDebugf("[%3d/%3d] (%d) %s\n", index, fTotal, pending, test->getName())
; | 89 fPending++; |
| 90 SkDebugf("[%3d/%3d] (%d) %s\n", fNextIndex, fTotal, fPending, test->getN
ame()); |
90 } | 91 } |
| 92 |
91 virtual void onReportFailed(const SkString& desc) { | 93 virtual void onReportFailed(const SkString& desc) { |
92 SkDebugf("\tFAILED: %s\n", desc.c_str()); | 94 SkDebugf("\tFAILED: %s\n", desc.c_str()); |
93 } | 95 } |
94 | 96 |
95 virtual void onEnd(Test* test) { | 97 virtual void onEnd(Test* test) { |
| 98 SkAutoMutexAcquire lock(fStartEndMutex); |
96 if (!test->passed()) { | 99 if (!test->passed()) { |
97 SkDebugf("---- %s FAILED\n", test->getName()); | 100 SkDebugf("---- %s FAILED\n", test->getName()); |
98 } | 101 } |
99 | 102 |
100 sk_atomic_dec(&fPending); | 103 fPending--; |
101 if (fNextIndex == fTotal) { | 104 if (fNextIndex == fTotal) { |
102 // Just waiting on straggler tests. Shame them by printing their na
me and runtime. | 105 // Just waiting on straggler tests. Shame them by printing their na
me and runtime. |
103 SkDebugf(" (%d) %5.1fs %s\n", | 106 SkDebugf(" (%d) %5.1fs %s\n", |
104 fPending, test->elapsedMs() / 1e3, test->getName()); | 107 fPending, test->elapsedMs() / 1e3, test->getName()); |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 private: | 111 private: |
| 112 SkMutex fStartEndMutex; // Guards fNextIndex and fPending. |
109 int32_t fNextIndex; | 113 int32_t fNextIndex; |
110 int32_t fPending; | 114 int32_t fPending; |
| 115 |
| 116 // Once the tests get going, these are logically const. |
111 int fTotal; | 117 int fTotal; |
112 bool fAllowExtendedTest; | 118 bool fAllowExtendedTest; |
113 bool fAllowThreaded; | 119 bool fAllowThreaded; |
114 bool fVerbose; | 120 bool fVerbose; |
115 }; | 121 }; |
116 | 122 |
117 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ | 123 DEFINE_string2(match, m, NULL, "[~][^]substring[$] [...] of test name to run.\n"
\ |
118 "Multiple matches may be separated by spaces.\n"
\ | 124 "Multiple matches may be separated by spaces.\n"
\ |
119 "~ causes a matching test to always be skipped\n"
\ | 125 "~ causes a matching test to always be skipped\n"
\ |
120 "^ requires the start of the test to match\n" \ | 126 "^ requires the start of the test to match\n" \ |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 GpuTest::DestroyContexts(); | 270 GpuTest::DestroyContexts(); |
265 | 271 |
266 return (failCount == 0) ? 0 : 1; | 272 return (failCount == 0) ? 0 : 1; |
267 } | 273 } |
268 | 274 |
269 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 275 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
270 int main(int argc, char * const argv[]) { | 276 int main(int argc, char * const argv[]) { |
271 return tool_main(argc, (char**) argv); | 277 return tool_main(argc, (char**) argv); |
272 } | 278 } |
273 #endif | 279 #endif |
OLD | NEW |