summaryrefslogtreecommitdiff
path: root/libutils/Mutex_test.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2019-03-29 11:13:11 -0700
committerMikhail Naganov <mnaganov@google.com>2019-03-29 12:21:57 -0700
commite1a285ddc1c728d95222aeddbe82b94ac5eb3304 (patch)
treebe48320b09d3bb9864e3beae5251ce1e516745da /libutils/Mutex_test.cpp
parent0a887aa14c5bd187859c7558259df3901fee2342 (diff)
libutils: Fix thread safety annotations in Mutex
The annotations for Mutex::tryLock and timedLock were incorrectly specifying the return value for the successful acquisition. Test: make libutils_test Change-Id: I9729b6555ede5cb1d6db046e33c35bf5926c7755
Diffstat (limited to 'libutils/Mutex_test.cpp')
-rw-r--r--libutils/Mutex_test.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/libutils/Mutex_test.cpp b/libutils/Mutex_test.cpp
index 8a1805f51..79f4302d0 100644
--- a/libutils/Mutex_test.cpp
+++ b/libutils/Mutex_test.cpp
@@ -29,4 +29,20 @@ TEST(Mutex, compile) {
android::Mutex::Autolock _l(mLock);
i = 0;
modifyLockedVariable();
-} \ No newline at end of file
+}
+
+TEST(Mutex, tryLock) {
+ if (mLock.tryLock() != 0) {
+ return;
+ }
+ mLock.unlock();
+}
+
+#if defined(__ANDROID__)
+TEST(Mutex, timedLock) {
+ if (mLock.timedLock(1) != 0) {
+ return;
+ }
+ mLock.unlock();
+}
+#endif