* [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion
2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
@ 2025-09-22 10:49 ` Ricardo B. Marlière via ltp
2025-09-22 10:49 ` [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround Ricardo B. Marlière via ltp
2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
2 siblings, 0 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 10:49 UTC (permalink / raw)
To: Linux Test Project; +Cc: Ricardo B. Marlière
From: Ricardo B. Marlière <rbm@suse.com>
Link: https://austingroupbugs.net/view.php?id=1111
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
.../conformance/interfaces/pthread_rwlock_rdlock/2-1.c | 13 +++++++------
.../conformance/interfaces/pthread_rwlock_rdlock/2-2.c | 13 +++++++------
.../conformance/interfaces/pthread_rwlock_rdlock/2-3.c | 13 +++++++------
.../interfaces/pthread_rwlock_rdlock/assertions.xml | 15 ++++++++-------
4 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
index 288eb3e3566abf26100f999d02081b5ef02a6694..fa57e64985ef46da143d3f323bb3c727eeb3db66 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
@@ -6,12 +6,13 @@
* Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
*
- * If the Thread Execution Scheduling option is supported,
- * and the threads involved in the lock are executing with the
- * scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- * acquire the lock if a writer holds the lock or if writers of
- * higher or equal priority are blocked on the lock;
- * otherwise, the calling thread shall acquire the lock.
+ * If the Thread Execution Scheduling option is supported,
+ * and the threads that hold or are blocked on the lock are
+ * executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ * the calling thread shall not acquire the lock if a writer
+ * holds the lock or if the calling thread does not already hold
+ * a read lock and writers of higher or equal priority are blocked
+ * on the lock; otherwise, the calling thread shall acquire the lock.
*
* In this case, we test "higher priority writer block"
*
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
index 3593e4c7966bef183bc5979e296beff512196d47..f6ffddfbe417a7affdf1114b9cc2e97bc09f8fac 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
@@ -6,12 +6,13 @@
* Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
*
- * If the Thread Execution Scheduling option is supported,
- * and the threads involved in the lock are executing with the
- * scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- * acquire the lock if a writer holds the lock or if writers of
- * higher or equal priority are blocked on the lock;
- * otherwise, the calling thread shall acquire the lock.
+ * If the Thread Execution Scheduling option is supported,
+ * and the threads that hold or are blocked on the lock are
+ * executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ * the calling thread shall not acquire the lock if a writer
+ * holds the lock or if the calling thread does not already hold
+ * a read lock and writers of higher or equal priority are blocked
+ * on the lock; otherwise, the calling thread shall acquire the lock.
*
* In this case, we test "equal priority writer block"
*
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
index 40170dbb2d025ffda3693644c7d9aa4246f16bcf..aa1511bae3703efc92bc8569d7f4dc81f6219aa3 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-3.c
@@ -6,12 +6,13 @@
* Test that pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
*
- * If the Thread Execution Scheduling option is supported,
- * and the threads involved in the lock are executing with the
- * scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- * acquire the lock if a writer holds the lock or if writers of
- * higher or equal priority are blocked on the lock;
- * otherwise, the calling thread shall acquire the lock.
+ * If the Thread Execution Scheduling option is supported,
+ * and the threads that hold or are blocked on the lock are
+ * executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ * the calling thread shall not acquire the lock if a writer
+ * holds the lock or if the calling thread does not already hold
+ * a read lock and writers of higher or equal priority are blocked
+ * on the lock; otherwise, the calling thread shall acquire the lock.
*
* In this case, reader has higher priority than the writer
*
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
index 07263b3dedde488196037e7140fcaa367cc49f5c..deb318cb786a5299c20b846eabfbad1111cb24ed 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/assertions.xml
@@ -6,13 +6,14 @@
no writers blocked on the lock.
</assertion>
- <assertion id="2" tag="ref:XSH6:34768:34771">
- If the Thread Execution Scheduling option is supported,
- and the threads involved in the lock are executing with the
- scheduling policies SCHED_FIFO or SCHED_RR, the calling thread shall not
- acquire the lock if a writer holds the lock or if writers of
- higher or equal priority are blocked on the lock;
- otherwise, the calling thread shall acquire the lock.
+ <assertion id="2" tag="ref:XSH8:{System Interfaces:pthread_rwlock_rdlock:DESCRIPTION}">
+ If the Thread Execution Scheduling option is supported,
+ and the threads that hold or are blocked on the lock are
+ executing with the scheduling policies SCHED_FIFO or SCHED_RR,
+ the calling thread shall not acquire the lock if a writer
+ holds the lock or if the calling thread does not already hold
+ a read lock and writers of higher or equal priority are blocked
+ on the lock; otherwise, the calling thread shall acquire the lock.
</assertion>
<assertion id="3" tag="ref:XSH6:34772:34775">
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* [LTP] [PATCH v2 2/2] open_posix: pthread_rwlock_rdlock: Add GLIBC workaround
2025-09-22 10:49 [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add GLIBC workaround Ricardo B. Marlière via ltp
2025-09-22 10:49 ` [LTP] [PATCH v2 1/2] open_posix: pthread_rwlock_rdlock: Update second assertion Ricardo B. Marlière via ltp
@ 2025-09-22 10:49 ` Ricardo B. Marlière via ltp
2025-09-22 14:15 ` [LTP] [PATCH v2 0/2] Update pthread_rwlock_rdlock 2nd assertion and add " Cyril Hrubis
2 siblings, 0 replies; 6+ messages in thread
From: Ricardo B. Marlière via ltp @ 2025-09-22 10:49 UTC (permalink / raw)
To: Linux Test Project; +Cc: Ricardo B. Marlière
From: Ricardo B. Marlière <rbm@suse.com>
GNU/Linux does not support the POSIX standard with regards to the second
assertion of this test. Work around it by making use of the non-portable
flag PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP.
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=13701
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
.../conformance/interfaces/pthread_rwlock_rdlock/2-1.c | 8 +++++++-
.../conformance/interfaces/pthread_rwlock_rdlock/2-2.c | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
index fa57e64985ef46da143d3f323bb3c727eeb3db66..3b27a0bbbbdfaadf37fa94e129a937cdd9e986db 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-1.c
@@ -144,13 +144,19 @@ int main(void)
int cnt = 0;
pthread_t rd_thread, wr_thread;
int priority;
+ pthread_rwlockattr_t attr;
+
+ pthread_rwlockattr_init(&attr);
+#ifdef __GNUC__
+ pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+#endif
/* main thread needs to have the highest priority */
priority = sched_get_priority_min(TRD_POLICY) + 2;
set_priority(pthread_self(), TRD_POLICY, priority);
printf("main: has priority: %d\n", priority);
- if (pthread_rwlock_init(&rwlock, NULL) != 0) {
+ if (pthread_rwlock_init(&rwlock, &attr) != 0) {
printf("main: Error at pthread_rwlock_init()\n");
return PTS_UNRESOLVED;
}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
index f6ffddfbe417a7affdf1114b9cc2e97bc09f8fac..4799b1e885caab509fd31173c34ae89beace68e6 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
@@ -144,12 +144,18 @@ int main(void)
int cnt = 0;
pthread_t rd_thread, wr_thread;
int priority;
+ pthread_rwlockattr_t attr;
+
+ pthread_rwlockattr_init(&attr);
+#ifdef __GNUC__
+ pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
+#endif
/* main thread needs to have the highest priority */
priority = sched_get_priority_min(TRD_POLICY) + 2;
set_priority(pthread_self(), TRD_POLICY, priority);
- if (pthread_rwlock_init(&rwlock, NULL) != 0) {
+ if (pthread_rwlock_init(&rwlock, &attr) != 0) {
printf("main: Error at pthread_rwlock_init()\n");
return PTS_UNRESOLVED;
}
--
2.51.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread