Chromium Code Reviews| Index: tests/skia_test.cpp |
| diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp |
| index a93b30797281ae7b40ad408fbd3fff420b53f708..d6fde8e0d996d28886cd0cc7445432a6c55547e1 100644 |
| --- a/tests/skia_test.cpp |
| +++ b/tests/skia_test.cpp |
| @@ -84,20 +84,23 @@ public: |
| protected: |
| virtual void onStart(Test* test) { |
| - const int index = sk_atomic_inc(&fNextIndex)+1; |
| - const int pending = sk_atomic_inc(&fPending)+1; |
| - SkDebugf("[%3d/%3d] (%d) %s\n", index, fTotal, pending, test->getName()); |
| + SkAutoMutexAcquire lock(fMutex); |
| + fNextIndex++; |
| + fPending++; |
| + SkDebugf("[%3d/%3d] (%d) %s\n", fNextIndex, fTotal, fPending, test->getName()); |
| } |
| + |
| virtual void onReportFailed(const SkString& desc) { |
| SkDebugf("\tFAILED: %s\n", desc.c_str()); |
| } |
| virtual void onEnd(Test* test) { |
| + SkAutoMutexAcquire lock(fMutex); |
| if (!test->passed()) { |
| SkDebugf("---- %s FAILED\n", test->getName()); |
| } |
| - sk_atomic_dec(&fPending); |
| + fPending--; |
| if (fNextIndex == fTotal) { |
| // Just waiting on straggler tests. Shame them by printing their name and runtime. |
| SkDebugf(" (%d) %5.1fs %s\n", |
| @@ -106,8 +109,11 @@ protected: |
| } |
| private: |
| + SkMutex fMutex; // Guards fNextIndex and fPending. |
|
bungeman-skia
2013/10/01 17:13:09
Can we avoid the name fMutex? Maybe fStartEndMutex
mtklein
2013/10/01 17:16:25
Done.
|
| int32_t fNextIndex; |
| int32_t fPending; |
| + |
| + // Once the tests get going, these are logically const. |
| int fTotal; |
| bool fAllowExtendedTest; |
| bool fAllowThreaded; |