Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org>
---
 test/validation/lock/lock.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/test/validation/lock/lock.c b/test/validation/lock/lock.c
index f1f6d69..071d5b6 100644
--- a/test/validation/lock/lock.c
+++ b/test/validation/lock/lock.c
@@ -254,17 +254,33 @@ static void *ticketlock_api_tests(void *arg UNUSED)
 
 static void rwlock_api_test(odp_rwlock_t *rw_lock)
 {
+       int rc;
+
        odp_rwlock_init(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
 
        odp_rwlock_read_lock(rw_lock);
+
+       rc = odp_rwlock_read_trylock(rw_lock);
+       CU_ASSERT(rc == 0);
+       rc = odp_rwlock_write_trylock(rw_lock);
+       CU_ASSERT(rc == 0);
+
        odp_rwlock_read_unlock(rw_lock);
 
+       rc = odp_rwlock_read_trylock(rw_lock);
+       if (rc == 1)
+               odp_rwlock_read_unlock(rw_lock);
+
        odp_rwlock_write_lock(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 1); */
 
        odp_rwlock_write_unlock(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
+
+       rc = odp_rwlock_write_trylock(rw_lock);
+       if (rc == 1)
+               odp_rwlock_write_unlock(rw_lock);
 }
 
 static void *rwlock_api_tests(void *arg UNUSED)
@@ -288,21 +304,33 @@ static void *rwlock_api_tests(void *arg UNUSED)
 
 static void rwlock_recursive_api_test(odp_rwlock_recursive_t *rw_lock)
 {
+       int rc;
+
        odp_rwlock_recursive_init(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
 
        odp_rwlock_recursive_read_lock(rw_lock);
        odp_rwlock_recursive_read_lock(rw_lock);
+       rc = odp_rwlock_recursive_read_trylock(rw_lock);
+       CU_ASSERT(rc == 1);
+       rc = odp_rwlock_recursive_write_trylock(rw_lock);
+       CU_ASSERT(rc == 0);
 
        odp_rwlock_recursive_read_unlock(rw_lock);
        odp_rwlock_recursive_read_unlock(rw_lock);
+       odp_rwlock_recursive_read_unlock(rw_lock);
 
        odp_rwlock_recursive_write_lock(rw_lock);
        odp_rwlock_recursive_write_lock(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 1); */
+       rc = odp_rwlock_recursive_read_trylock(rw_lock);
+       CU_ASSERT(rc == 0);
+       rc = odp_rwlock_recursive_write_trylock(rw_lock);
+       CU_ASSERT(rc == 1);
 
        odp_rwlock_recursive_write_unlock(rw_lock);
        odp_rwlock_recursive_write_unlock(rw_lock);
+       odp_rwlock_recursive_write_unlock(rw_lock);
        /* CU_ASSERT(odp_rwlock_is_locked(rw_lock) == 0); */
 }
 
-- 
2.5.0

_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to