|
From: <sv...@va...> - 2012-12-24 10:23:23
|
bart 2012-12-24 10:23:16 +0000 (Mon, 24 Dec 2012)
New Revision: 13199
Log:
drd/tests/pth_cond_destroy_busy: Add
Added files:
trunk/drd/tests/pth_cond_destroy_busy.c
trunk/drd/tests/pth_cond_destroy_busy.stderr.exp
trunk/drd/tests/pth_cond_destroy_busy.vgtest
Modified files:
trunk/drd/tests/Makefile.am
Added: trunk/drd/tests/pth_cond_destroy_busy.stderr.exp (+12 -0)
===================================================================
--- trunk/drd/tests/pth_cond_destroy_busy.stderr.exp 2012-12-24 10:22:14 +00:00 (rev 13198)
+++ trunk/drd/tests/pth_cond_destroy_busy.stderr.exp 2012-12-24 10:23:16 +00:00 (rev 13199)
@@ -0,0 +1,12 @@
+
+destruction of condition variable being waited upon: cond 0x........
+ at 0x........: pthread_cond_destroy (drd_pthread_intercepts.c:?)
+ by 0x........: main (pth_cond_destroy_busy.c:?)
+cond 0x........ was first observed at:
+ at 0x........: pthread_cond_init (drd_pthread_intercepts.c:?)
+ by 0x........: main (pth_cond_destroy_busy.c:?)
+
+First pthread_cond_destroy() call returned EBUSY
+Second pthread_cond_destroy() call returned success
+
+ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Added: trunk/drd/tests/pth_cond_destroy_busy.vgtest (+2 -0)
===================================================================
--- trunk/drd/tests/pth_cond_destroy_busy.vgtest 2012-12-24 10:22:14 +00:00 (rev 13198)
+++ trunk/drd/tests/pth_cond_destroy_busy.vgtest 2012-12-24 10:23:16 +00:00 (rev 13199)
@@ -0,0 +1,2 @@
+prereq: ./supported_libpthread
+prog: pth_cond_destroy_busy
Added: trunk/drd/tests/pth_cond_destroy_busy.c (+69 -0)
===================================================================
--- trunk/drd/tests/pth_cond_destroy_busy.c 2012-12-24 10:22:14 +00:00 (rev 13198)
+++ trunk/drd/tests/pth_cond_destroy_busy.c 2012-12-24 10:23:16 +00:00 (rev 13199)
@@ -0,0 +1,69 @@
+/*
+ * Invoke pthread_cond_destroy() on a condition variable that is being waited
+ * upon.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h> // printf()
+#include <pthread.h>
+
+static pthread_mutex_t s_mutex;
+static pthread_cond_t s_cond;
+static int s_i;
+
+static const char* err_to_str(int errnum)
+{
+ switch (errnum) {
+ case 0: return "success";
+ case EBUSY: return "EBUSY";
+ case EINVAL: return "EINVAL";
+ default: return "?";
+ }
+}
+
+static void* thread_func(void* thread_arg)
+{
+ pthread_mutex_lock(&s_mutex);
+ s_i = 1;
+ pthread_cond_signal(&s_cond);
+ while (s_i == 1)
+ pthread_cond_wait(&s_cond, &s_mutex);
+ pthread_mutex_unlock(&s_mutex);
+
+ return 0;
+}
+
+int main(int argc, char** argv)
+{
+ pthread_t threadid;
+ int ret;
+
+ pthread_mutex_init(&s_mutex, 0);
+ pthread_cond_init(&s_cond, 0);
+
+ pthread_create(&threadid, 0, thread_func, 0);
+
+ pthread_mutex_lock(&s_mutex);
+ while (s_i == 0)
+ pthread_cond_wait(&s_cond, &s_mutex);
+ pthread_mutex_unlock(&s_mutex);
+
+ ret = pthread_cond_destroy(&s_cond);
+ fprintf(stderr, "First pthread_cond_destroy() call returned %s.\n",
+ err_to_str(ret));
+
+ pthread_mutex_lock(&s_mutex);
+ s_i = 2;
+ pthread_cond_signal(&s_cond);
+ pthread_mutex_unlock(&s_mutex);
+
+ pthread_join(threadid, 0);
+
+ ret = pthread_cond_destroy(&s_cond);
+ fprintf(stderr, "Second pthread_cond_destroy() call returned %s.\n",
+ err_to_str(ret));
+ pthread_mutex_destroy(&s_mutex);
+
+ return 0;
+}
Modified: trunk/drd/tests/Makefile.am (+3 -0)
===================================================================
--- trunk/drd/tests/Makefile.am 2012-12-24 10:22:14 +00:00 (rev 13198)
+++ trunk/drd/tests/Makefile.am 2012-12-24 10:23:16 +00:00 (rev 13199)
@@ -156,6 +156,8 @@
pth_cancel_locked.vgtest \
pth_cleanup_handler.stderr.exp \
pth_cleanup_handler.vgtest \
+ pth_cond_destroy_busy.stderr.exp \
+ pth_cond_destroy_busy.vgtest \
pth_cond_race.stderr.exp \
pth_cond_race.vgtest \
pth_cond_race2.stderr.exp \
@@ -315,6 +317,7 @@
pth_broadcast \
pth_cancel_locked \
pth_cleanup_handler \
+ pth_cond_destroy_busy \
pth_cond_race \
pth_create_chain \
pth_detached \
|