|
From: <sv...@va...> - 2010-04-29 06:06:38
|
Author: bart Date: 2010-04-29 07:06:29 +0100 (Thu, 29 Apr 2010) New Revision: 11108 Log: Added yet another regression test. Added: trunk/drd/tests/bug-235681.c trunk/drd/tests/bug-235681.stderr.exp trunk/drd/tests/bug-235681.vgtest Modified: trunk/drd/tests/ trunk/drd/tests/Makefile.am Property changes on: trunk/drd/tests ___________________________________________________________________ Name: svn:ignore - *.dSYM *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps annotate_barrier annotate_hb_err annotate_hb_race annotate_ignore_rw annotate_ignore_write annotate_publish_hg annotate_rwlock annotate_smart_pointer annotate_static atomic_var bar_bad bar_trivial boost_thread circular_buffer custom_alloc drd_bitmap_test fp_race hg01_all_ok hg02_deadlock hg03_inherit hg04_race hg05_race2 hg06_readshared hold_lock linuxthreads_det Makefile Makefile.in matinv memory_allocation monitor_example new_delete omp_matinv omp_prime omp_printf pth_barrier pth_barrier_race pth_barrier_reinit pth_broadcast pth_cancel_locked pth_cleanup_handler pth_cond_race pth_create_chain pth_create_glibc_2_0 pth_detached pth_detached_sem pth_inconsistent_cond_wait pth_mutex_reinit pth_process_shared_mutex pth_spinlock qt4_atomic qt4_mutex qt4_rwlock qt4_semaphore recursive_mutex rwlock_race rwlock_test rwlock_type_checking sem_as_mutex sem_open sigalrm tc01_simple_race tc02_simple_tls tc03_re_excl tc04_free_lock tc05_simple_race tc06_two_races tc07_hbl1 tc08_hbl2 tc09_bad_unlock tc10_rec_lock tc11_XCHG tc12_rwl_trivial tc13_laog1 tc15_laog_lockdel tc16_byterace tc17_sembar tc18_semabuse tc19_shadowmem tc20_verifywrap tc21_pthonce tc22_exit_w_lock tc23_bogus_condwait tc24_nonzero_sem thread_name trylock tsan_unittest unit_bitmap unit_vc vg_regtest.tmp* + *.dSYM *.stderr.diff* *.stderr.out *.stdout.diff* *.stdout.out .deps annotate_barrier annotate_hb_err annotate_hb_race annotate_ignore_rw annotate_ignore_write annotate_publish_hg annotate_rwlock annotate_smart_pointer annotate_static atomic_var bar_bad bar_trivial boost_thread bug-235681 circular_buffer custom_alloc drd_bitmap_test fp_race hg01_all_ok hg02_deadlock hg03_inherit hg04_race hg05_race2 hg06_readshared hold_lock linuxthreads_det Makefile Makefile.in matinv memory_allocation monitor_example new_delete omp_matinv omp_prime omp_printf pth_barrier pth_barrier_race pth_barrier_reinit pth_broadcast pth_cancel_locked pth_cleanup_handler pth_cond_race pth_create_chain pth_create_glibc_2_0 pth_detached pth_detached_sem pth_inconsistent_cond_wait pth_mutex_reinit pth_process_shared_mutex pth_spinlock qt4_atomic qt4_mutex qt4_rwlock qt4_semaphore recursive_mutex rwlock_race rwlock_test rwlock_type_checking sem_as_mutex sem_open sigalrm tc01_simple_race tc02_simple_tls tc03_re_excl tc04_free_lock tc05_simple_race tc06_two_races tc07_hbl1 tc08_hbl2 tc09_bad_unlock tc10_rec_lock tc11_XCHG tc12_rwl_trivial tc13_laog1 tc15_laog_lockdel tc16_byterace tc17_sembar tc18_semabuse tc19_shadowmem tc20_verifywrap tc21_pthonce tc22_exit_w_lock tc23_bogus_condwait tc24_nonzero_sem thread_name trylock tsan_unittest unit_bitmap unit_vc vg_regtest.tmp* Modified: trunk/drd/tests/Makefile.am =================================================================== --- trunk/drd/tests/Makefile.am 2010-04-29 05:53:22 UTC (rev 11107) +++ trunk/drd/tests/Makefile.am 2010-04-29 06:06:29 UTC (rev 11108) @@ -61,6 +61,8 @@ bar_trivial.vgtest \ boost_thread.stderr.exp \ boost_thread.vgtest \ + bug-235681.stderr.exp \ + bug-235681.vgtest \ circular_buffer.stderr.exp \ circular_buffer.vgtest \ custom_alloc.stderr.exp \ @@ -260,6 +262,7 @@ annotate_ignore_write \ annotate_publish_hg \ annotate_static \ + bug-235681 \ custom_alloc \ fp_race \ hold_lock \ Added: trunk/drd/tests/bug-235681.c =================================================================== --- trunk/drd/tests/bug-235681.c (rev 0) +++ trunk/drd/tests/bug-235681.c 2010-04-29 06:06:29 UTC (rev 11108) @@ -0,0 +1,80 @@ +/* + * pthread_cond_wait() test program. + * See also https://bugs.kde.org/show_bug.cgi?id=235681. + */ + +#include <string.h> +#include <stdio.h> +#include <assert.h> +#include <pthread.h> +#include <errno.h> +#include <unistd.h> + +pthread_mutex_t mutex; +pthread_cond_t cond_var; +int status; + +static void *run_fn(void *v) +{ + int rc; + + fprintf(stderr, "run_fn starting\n"); + + rc = pthread_mutex_lock(&mutex); + assert(!rc); + + while (!status) { + fprintf(stderr, "run_fn(): status==0\n"); + rc = pthread_cond_wait(&cond_var, &mutex); + assert(!rc); + fprintf(stderr, "run_fn(): woke up\n"); + } + fprintf(stderr, "run_fn(): status==1\n"); + + rc = pthread_mutex_unlock(&mutex); + assert(!rc); + + fprintf(stderr, "run_fn done\n"); + + return NULL; +} + +int main(int argc, char **argv) +{ + int rc; + pthread_t other_thread; + + rc = pthread_mutex_init(&mutex, NULL); + assert(!rc); + rc = pthread_cond_init(&cond_var, NULL); + assert(!rc); + + status = 0; + + rc = pthread_create(&other_thread, NULL, run_fn, NULL); + assert(!rc); + + /* yield the processor, and give the other thread a chance to get into the while loop */ + fprintf(stderr, "main(): sleeping...\n"); + sleep(1); + + rc = pthread_mutex_lock(&mutex); + assert(!rc); + /**** BEGIN CS *****/ + + fprintf(stderr, "main(): status=1\n"); + status = 1; + rc = pthread_cond_broadcast(&cond_var); + assert(!rc); + + /**** END CS *****/ + rc = pthread_mutex_unlock(&mutex); + assert(!rc); + + fprintf(stderr, "joining...\n"); + + rc = pthread_join(other_thread, NULL); + assert(!rc); + + return 0; +} Added: trunk/drd/tests/bug-235681.stderr.exp =================================================================== --- trunk/drd/tests/bug-235681.stderr.exp (rev 0) +++ trunk/drd/tests/bug-235681.stderr.exp 2010-04-29 06:06:29 UTC (rev 11108) @@ -0,0 +1,11 @@ + +run_fn starting +run_fn(): status==0 +main(): sleeping... +main(): status=1 +joining... +run_fn(): woke up +run_fn(): status==1 +run_fn done + +ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Added: trunk/drd/tests/bug-235681.vgtest =================================================================== --- trunk/drd/tests/bug-235681.vgtest (rev 0) +++ trunk/drd/tests/bug-235681.vgtest 2010-04-29 06:06:29 UTC (rev 11108) @@ -0,0 +1,4 @@ +prereq: test -e bug-235681 && ./supported_libpthread +vgopts: --read-var-info=yes --check-stack-var=yes --show-confl-seg=no --num-callers=3 +prog: bug-235681 +stderr_filter: filter_stderr |