diff mbox

[API-NEXT,1/2] validation: synchronizers: add missing rwlock read lock functional test

Message ID 1446143663-3781-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 87c4c0545032fb998f22271bb1ad26f82ba7e108
Headers show

Commit Message

Bill Fischofer Oct. 29, 2015, 6:34 p.m. UTC
rwlock functional tests test for write locks, however they should also
test for read locks.

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

Comments

Maxim Uvarov Dec. 1, 2015, 2:55 p.m. UTC | #1
Merged both.

Maxim.

On 10/29/2015 21:34, Bill Fischofer wrote:
> rwlock functional tests test for write locks, however they should also
> test for read locks.
>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   test/validation/synchronizers/synchronizers.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
> index 2406c77..6a8d79f 100644
> --- a/test/validation/synchronizers/synchronizers.c
> +++ b/test/validation/synchronizers/synchronizers.c
> @@ -652,6 +652,19 @@ static void *rwlock_functional_test(void *arg UNUSED)
>   	lock_owner_delay = BASE_DELAY;
>   
>   	for (cnt = 1; cnt <= iterations; cnt++) {
> +		/* Verify that we can obtain a read lock */
> +		odp_rwlock_read_lock(&global_mem->global_rwlock);
> +
> +		/* Verify lock is unowned (no writer holds it) */
> +		thread_delay(per_thread_mem, lock_owner_delay);
> +		if (global_mem->global_lock_owner != 0) {
> +			current_errs++;
> +			sync_failures++;
> +		}
> +
> +		/* Release the read lock */
> +		odp_rwlock_read_unlock(&global_mem->global_rwlock);
> +
>   		/* Acquire the shared global lock */
>   		odp_rwlock_write_lock(&global_mem->global_rwlock);
>
diff mbox

Patch

diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c
index 2406c77..6a8d79f 100644
--- a/test/validation/synchronizers/synchronizers.c
+++ b/test/validation/synchronizers/synchronizers.c
@@ -652,6 +652,19 @@  static void *rwlock_functional_test(void *arg UNUSED)
 	lock_owner_delay = BASE_DELAY;
 
 	for (cnt = 1; cnt <= iterations; cnt++) {
+		/* Verify that we can obtain a read lock */
+		odp_rwlock_read_lock(&global_mem->global_rwlock);
+
+		/* Verify lock is unowned (no writer holds it) */
+		thread_delay(per_thread_mem, lock_owner_delay);
+		if (global_mem->global_lock_owner != 0) {
+			current_errs++;
+			sync_failures++;
+		}
+
+		/* Release the read lock */
+		odp_rwlock_read_unlock(&global_mem->global_rwlock);
+
 		/* Acquire the shared global lock */
 		odp_rwlock_write_lock(&global_mem->global_rwlock);