Common subdirectories: none/tests_orig/CVS and none/tests/CVS diff -Nu none/tests_orig/Makefile.am none/tests/Makefile.am --- none/tests_orig/Makefile.am Mon Sep 27 21:47:43 2004 +++ none/tests/Makefile.am Mon Sep 27 21:10:39 2004 @@ -44,6 +44,10 @@ mq.stderr.exp mq.vgtest \ mremap.stderr.exp mremap.stdout.exp mremap.vgtest \ munmap_exe.stderr.exp munmap_exe.vgtest \ + pthread_cond_destroy1.stderr.exp pthread_cond_destroy1.stdout.exp \ + pthread_cond_destroy1.vgtest \ + pthread_cond_destroy2.stderr.exp pthread_cond_destroy2.stdout.exp \ + pthread_cond_destroy2.vgtest \ pth_blockedsig.stderr.exp \ pth_blockedsig.stdout.exp pth_blockedsig.vgtest \ pushpopseg.stderr.exp pushpopseg.stdout.exp pushpopseg.vgtest \ @@ -76,7 +80,8 @@ resolv rlimit_nofile seg_override sem semlimit sha1_test \ shortpush shorts smc1 susphello pth_blockedsig pushpopseg \ syscall-restart1 syscall-restart2 system \ - coolo_sigaction gxx304 yield + coolo_sigaction gxx304 yield pthread_cond_destroy1 \ + pthread_cond_destroy2 AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include AM_CXXFLAGS = $(AM_CFLAGS) @@ -155,6 +160,10 @@ # pthread C ones pth_blockedsig_SOURCES = pth_blockedsig.c pth_blockedsig_LDADD = -lpthread +pthread_cond_destroy1_SOURCES = pthread_cond_destroy1.c +pthread_cond_destroy1_LDADD = -lpthread +pthread_cond_destroy2_SOURCES = pthread_cond_destroy2.c +pthread_cond_destroy2_LDADD = -lpthread # generic C++ ones coolo_sigaction_SOURCES = coolo_sigaction.cpp diff -Nu none/tests_orig/pthread_cond_destroy1.c none/tests/pthread_cond_destroy1.c --- none/tests_orig/pthread_cond_destroy1.c Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy1.c Mon Sep 27 21:10:39 2004 @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + + pthread_cond_t cond = PTHREAD_COND_INITIALIZER; + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + struct timeval now; + struct timespec timeout; + + assert(pthread_mutex_lock(&mutex) == 0); + assert(gettimeofday(&now, NULL) == 0); + timeout.tv_sec = now.tv_sec + 5; + timeout.tv_nsec = now.tv_usec * 1000; + + assert(pthread_cond_timedwait(&cond, &mutex, &timeout) == ETIMEDOUT); + assert(pthread_mutex_unlock(&mutex) == 0); + + assert(pthread_cond_destroy(&cond) == 0); + assert(pthread_mutex_destroy(&mutex) == 0); + + printf("PASS\n"); + return 0; +} diff -Nu none/tests_orig/pthread_cond_destroy1.stderr.exp none/tests/pthread_cond_destroy1.stderr.exp --- none/tests_orig/pthread_cond_destroy1.stderr.exp Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy1.stderr.exp Mon Sep 27 21:10:39 2004 @@ -0,0 +1,2 @@ + + diff -Nu none/tests_orig/pthread_cond_destroy1.stdout.exp none/tests/pthread_cond_destroy1.stdout.exp --- none/tests_orig/pthread_cond_destroy1.stdout.exp Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy1.stdout.exp Mon Sep 27 21:10:39 2004 @@ -0,0 +1 @@ +PASS diff -Nu none/tests_orig/pthread_cond_destroy1.vgtest none/tests/pthread_cond_destroy1.vgtest --- none/tests_orig/pthread_cond_destroy1.vgtest Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy1.vgtest Mon Sep 27 21:10:39 2004 @@ -0,0 +1 @@ +prog: pthread_cond_destroy1 diff -Nu none/tests_orig/pthread_cond_destroy2.c none/tests/pthread_cond_destroy2.c --- none/tests_orig/pthread_cond_destroy2.c Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy2.c Mon Sep 27 21:10:39 2004 @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include + +typedef struct arg_s { + pthread_cond_t cond; + pthread_mutex_t mutex; +} arg_t; + +static void *thread1(void *arg) { + arg_t *args = (arg_t*)arg; + assert(pthread_mutex_lock(&args->mutex) == 0); + assert(pthread_cond_wait(&args->cond, &args->mutex) == 0); + assert(pthread_mutex_unlock(&args->mutex) == 0); + return NULL; +} + +int main(int argc, char *argv[]) { + pthread_t th1; + arg_t args; + + assert(pthread_cond_init(&args.cond, NULL) == 0); + assert(pthread_mutex_init(&args.mutex, NULL) == 0); + + assert(pthread_create(&th1, NULL, thread1, &args) == 0); + + /* wait for thread1 waiting on conditional */ + sleep(1); + + /* should return with EBUSY, because of thread1 waiting on condition */ + assert(pthread_cond_destroy(&args.cond) == EBUSY); + + /* now signal thread1 */ + assert(pthread_cond_signal(&args.cond) == 0); + + assert(pthread_cond_destroy(&args.cond) == 0); + + assert(pthread_join(th1, NULL) == 0); + + printf("PASS\n"); + return 0; +} diff -Nu none/tests_orig/pthread_cond_destroy2.stderr.exp none/tests/pthread_cond_destroy2.stderr.exp --- none/tests_orig/pthread_cond_destroy2.stderr.exp Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy2.stderr.exp Mon Sep 27 21:10:39 2004 @@ -0,0 +1,2 @@ + + diff -Nu none/tests_orig/pthread_cond_destroy2.stdout.exp none/tests/pthread_cond_destroy2.stdout.exp --- none/tests_orig/pthread_cond_destroy2.stdout.exp Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy2.stdout.exp Mon Sep 27 21:10:39 2004 @@ -0,0 +1 @@ +PASS diff -Nu none/tests_orig/pthread_cond_destroy2.vgtest none/tests/pthread_cond_destroy2.vgtest --- none/tests_orig/pthread_cond_destroy2.vgtest Thu Jan 1 01:00:00 1970 +++ none/tests/pthread_cond_destroy2.vgtest Mon Sep 27 21:10:39 2004 @@ -0,0 +1 @@ +prog: pthread_cond_destroy2