]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix the isc_rwlock_tryupgrade() function's unit test
authorAram Sargsyan <aram@isc.org>
Wed, 16 Apr 2025 12:56:18 +0000 (12:56 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Wed, 16 Apr 2025 15:59:42 +0000 (15:59 +0000)
The pthread-based implementation of the isc_rwlock_tryupgrade()
function always returns ISC_R_LOCKBUSY. Fix the test by adding
conditional checks.

tests/isc/rwlock_test.c

index 74f9e4ca22af3cb08719523bb0c8fff1f27c8c3a..893f8cfc4d47ea22f1301b8639a46e82437740b1 100644 (file)
@@ -138,8 +138,17 @@ ISC_RUN_TEST_IMPL(isc_rwlock_tryupgrade) {
        isc_result_t result;
        isc_rwlock_lock(&rwlock, isc_rwlocktype_read);
        result = isc_rwlock_tryupgrade(&rwlock);
+#if USE_PTHREAD_RWLOCK
+       /*
+        * Our pthread-based rwlock implementation does not support tryupgrade,
+        * and always returns ISC_R_LOCKBUSY.
+        */
+       assert_int_equal(result, ISC_R_LOCKBUSY);
+       isc_rwlock_unlock(&rwlock, isc_rwlocktype_read);
+#else
        assert_int_equal(result, ISC_R_SUCCESS);
        isc_rwlock_unlock(&rwlock, isc_rwlocktype_write);
+#endif /* USE_PTHREAD_RWLOCK */
 }
 
 static void *