Make the test code compatible with -Wthread-safety

Make it clear to the compiler that gMutex is held while reading or
writing gReady.

Bug: 260725458
Change-Id: I197aca02c0e309c2c53b4e1995e9175b72109cb5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
diff --git a/tests/stresstest/MultithreadTest.cpp b/tests/stresstest/MultithreadTest.cpp
index 560b517..d32d0b4 100644
--- a/tests/stresstest/MultithreadTest.cpp
+++ b/tests/stresstest/MultithreadTest.cpp
@@ -21,17 +21,19 @@
 #include <random>
 #include <thread>
 
+#include <android-base/thread_annotations.h>
 #include <cutils/log.h>
 #include <gtest/gtest.h>
 
 #include "minikin/FontCollection.h"
 #include "minikin/Macros.h"
 #include "minikin/MinikinPaint.h"
-
 #include "FontTestUtils.h"
 #include "MinikinInternal.h"
 #include "PathUtils.h"
 
+using android::base::ScopedLockAssertion;
+
 namespace minikin {
 
 constexpr int LAYOUT_COUNT_PER_COLLECTION = 500;
@@ -63,7 +65,7 @@
     {
         // Wait until all threads are created.
         std::unique_lock<std::mutex> lock(gMutex);
-        gCv.wait(lock, [] { return gReady; });
+        gCv.wait(lock, []() EXCLUSIVE_LOCKS_REQUIRED(gMutex) { return gReady; });
     }
 
     std::mt19937 mt(tid);
@@ -90,7 +92,7 @@
     std::vector<std::thread> threads;
 
     {
-        std::unique_lock<std::mutex> lock(gMutex);
+        ScopedLockAssertion lock(gMutex);
         threads.reserve(NUM_THREADS);
         for (int i = 0; i < NUM_THREADS; ++i) {
             threads.emplace_back(&thread_main, i);