This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v3 2/2] Mutex: add unit tests for new type
- From: Kemi Wang <kemi dot wang at intel dot com>
- To: Carlos <carlos at redhat dot com>, Siddhesh Poyarekar <siddhesh at gotplt dot org>, Glibc alpha <libc-alpha at sourceware dot org>
- Cc: Kemi Wang <kemi dot wang at intel dot com>
- Date: Mon, 14 Jan 2019 13:01:44 +0800
- Subject: [PATCH v3 2/2] Mutex: add unit tests for new type
- References: <1547442104-24364-1-git-send-email-kemi.wang@intel.com>
Since a new type mutex with GNU extension PTHREAD_MUTEX_QUEUESPINNER_NP is
introduced, some unit tests are added accordingly to avoid regression.
Similar to other mutex type, the initializer PTHREAD_QUEUESPINNER_MUTEX_INITIALIZER_NP
is tested in nptl/tst-initializers1.c
Based-on the template provided in tst-mutex5.c, the basic function
pthread_mutex_{init, trylock, lock, unlock} and pthread_mutexattr_{init,
settype, destroy} are tested in nptl/tst-mutex5b.c for this new type mutex with
GNU extension PTHREAD_MUTEX_QUEUESPINNER_NP. Adding extra PI
(PRIORITY_INHERIT) attribution testing in nptl/tst-mutexpi5b.c for this new
mutex type.
Based-on the template provided in tst-mutex7.c, the basic function
pthread_mutex_{lock, unlock} is tested with multiple threads running in
parallel in nptl/tst-mutex7b.c for this new type mutex with GNU extension
PTHREAD_MUTEX_QUEUESPINNER_NP. Adding extra PI attribution testing in
nptl/tst-mutexpi7b.c for this new type.
*nptl/Makefile (tests): Add tst-mutex5b, tst-mutexpi5b, tst-mutex7b,
and tst-mutexpi7b
*nptl/tst-initializer1.c: Add a test for the initializer
PTHREAD_QUEUESPINNER_MUTEX_INITIALIZER_NP
*nptl/tst-mutex5b.c: New file
*nptl/tst-mutexpi5b.c: Likewise
*nptl/tst-mutex7b.c: Likewise
*nptl/tst-mutexpi7b.c: Likewise
V2->V3:
a) Add changelog entry and a more detailed description of this change
b) Add two more test cases for this mutex type with PI attribution.
V1->V2:
No change.
Signed-off-by: Kemi Wang <kemi.wang@intel.com>
---
nptl/Makefile | 8 ++++----
nptl/tst-initializers1.c | 9 ++++++---
nptl/tst-mutex5b.c | 2 ++
nptl/tst-mutex7b.c | 2 ++
nptl/tst-mutexpi5b.c | 2 ++
nptl/tst-mutexpi7b.c | 2 ++
6 files changed, 18 insertions(+), 7 deletions(-)
create mode 100644 nptl/tst-mutex5b.c
create mode 100644 nptl/tst-mutex7b.c
create mode 100644 nptl/tst-mutexpi5b.c
create mode 100644 nptl/tst-mutexpi7b.c
diff --git a/nptl/Makefile b/nptl/Makefile
index 0de8df3..9669f94 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -242,10 +242,10 @@ LDLIBS-tst-minstack-throw = -lstdc++
tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
- tst-mutex7 tst-mutex9 tst-mutex10 tst-mutex5a tst-mutex7a \
- tst-mutex7robust tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 \
- tst-mutexpi5 tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a \
- tst-mutexpi9 \
+ tst-mutex7 tst-mutex9 tst-mutex10 tst-mutex5a tst-mutex5b tst-mutex7a \
+ tst-mutex7b tst-mutex7robust tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 \
+ tst-mutexpi4 tst-mutexpi5 tst-mutexpi5a tst-mutexpi5b tst-mutexpi6 \
+ tst-mutexpi7 tst-mutexpi7a tst-mutexpi7b tst-mutexpi9 \
tst-spin1 tst-spin2 tst-spin3 tst-spin4 \
tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
diff --git a/nptl/tst-initializers1.c b/nptl/tst-initializers1.c
index a8fdac1..080ee2f 100644
--- a/nptl/tst-initializers1.c
+++ b/nptl/tst-initializers1.c
@@ -25,6 +25,7 @@ pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
pthread_mutex_t mtx_adaptive = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
+pthread_mutex_t mtx_queuespinner = PTHREAD_QUEUESPINNER_MUTEX_INITIALIZER_NP;
pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
pthread_rwlock_t rwl_writer
= PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
@@ -41,18 +42,20 @@ do_test (void)
return 3;
if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP)
return 4;
- if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
+ if (mtx_queuespinner.__data.__kind != PTHREAD_MUTEX_QUEUESPINNER_NP)
return 5;
+ if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
+ return 6;
if (rwl_writer.__data.__flags
!= PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
- return 6;
+ return 7;
/* <libc-lock.h> __libc_rwlock_init definition for libc.so
relies on PTHREAD_RWLOCK_INITIALIZER being all zeros. If
that ever changes, <libc-lock.h> needs updating. */
size_t i;
for (i = 0; i < sizeof (rwl_normal); i++)
if (((char *) &rwl_normal)[i] != '\0')
- return 7;
+ return 8;
return 0;
}
diff --git a/nptl/tst-mutex5b.c b/nptl/tst-mutex5b.c
new file mode 100644
index 0000000..9da54ea
--- /dev/null
+++ b/nptl/tst-mutex5b.c
@@ -0,0 +1,2 @@
+#define TYPE PTHREAD_MUTEX_QUEUESPINNER_NP
+#include "tst-mutex5.c"
diff --git a/nptl/tst-mutex7b.c b/nptl/tst-mutex7b.c
new file mode 100644
index 0000000..c2c1410
--- /dev/null
+++ b/nptl/tst-mutex7b.c
@@ -0,0 +1,2 @@
+#define TYPE PTHREAD_MUTEX_QUEUESPINNER_NP
+#include "tst-mutex7.c"
diff --git a/nptl/tst-mutexpi5b.c b/nptl/tst-mutexpi5b.c
new file mode 100644
index 0000000..8985447
--- /dev/null
+++ b/nptl/tst-mutexpi5b.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex5b.c"
diff --git a/nptl/tst-mutexpi7b.c b/nptl/tst-mutexpi7b.c
new file mode 100644
index 0000000..900dd89
--- /dev/null
+++ b/nptl/tst-mutexpi7b.c
@@ -0,0 +1,2 @@
+#define ENABLE_PI 1
+#include "tst-mutex7b.c"
--
2.7.4