[libc-commits] [libc] [libc] fix rwlock test (PR #100962)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Sun Jul 28 19:45:26 PDT 2024


https://github.com/SchrodingerZhu created https://github.com/llvm/llvm-project/pull/100962

Previous uses wrong clock id and forget to release an additional rdlock. cc @Eric977 
Sorry for missing this in my initial review.

>From 15d76a76aded54306e043daaec472368658a606e Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Sun, 28 Jul 2024 19:43:26 -0700
Subject: [PATCH] [libc] fix rwlock test

---
 libc/test/integration/src/pthread/pthread_rwlock_test.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
index 8896f45d2c90a..9f5fba187713e 100644
--- a/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
+++ b/libc/test/integration/src/pthread/pthread_rwlock_test.cpp
@@ -217,13 +217,14 @@ static void timedlock_with_deadlock_test() {
             ETIMEDOUT);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_timedrdlock(&rwlock, &ts), 0);
   ASSERT_EQ(
-      LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, CLOCK_MONOTONIC, &ts),
+      LIBC_NAMESPACE::pthread_rwlock_clockwrlock(&rwlock, CLOCK_REALTIME, &ts),
       ETIMEDOUT);
   ASSERT_EQ(
-      LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, CLOCK_MONOTONIC, &ts),
+      LIBC_NAMESPACE::pthread_rwlock_clockrdlock(&rwlock, CLOCK_REALTIME, &ts),
       0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);
   // notice that ts is already expired, but the following should still succeed.
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_tryrdlock(&rwlock), 0);
   ASSERT_EQ(LIBC_NAMESPACE::pthread_rwlock_unlock(&rwlock), 0);



More information about the libc-commits mailing list