summaryrefslogtreecommitdiff
path: root/tests/rwlock2.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rwlock2.c')
-rw-r--r--tests/rwlock2.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/rwlock2.c b/tests/rwlock2.c
new file mode 100644
index 0000000..cfb3228
--- /dev/null
+++ b/tests/rwlock2.c
@@ -0,0 +1,34 @@
+/*
+ * rwlock2.c
+ *
+ * Declare a static rwlock object, lock it,
+ * and then unlock it again.
+ *
+ * Depends on API functions:
+ * pthread_rwlock_rdlock()
+ * pthread_rwlock_unlock()
+ */
+
+#include "test.h"
+
+pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
+
+int
+main()
+{
+ assert(rwlock == PTHREAD_RWLOCK_INITIALIZER);
+
+ assert(pthread_rwlock_rdlock(&rwlock) == 0);
+
+ assert(rwlock != PTHREAD_RWLOCK_INITIALIZER);
+
+ assert(rwlock != NULL);
+
+ assert(pthread_rwlock_unlock(&rwlock) == 0);
+
+ assert(pthread_rwlock_destroy(&rwlock) == 0);
+
+ assert(rwlock == NULL);
+
+ return 0;
+}