|
From: <sv...@va...> - 2011-03-12 14:02:15
|
Author: bart
Date: 2011-03-12 14:02:06 +0000 (Sat, 12 Mar 2011)
New Revision: 11634
Log:
Added --free-is-write stress test.
Added:
trunk/drd/tests/free_is_write.c
trunk/drd/tests/free_is_write.stderr.exp
trunk/drd/tests/free_is_write.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
Makefile
Makefile.in
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
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_detached3
pth_detached_sem
pth_inconsistent_cond_wait
pth_mutex_reinit
pth_process_shared_mutex
pth_spinlock
pth_uninitialized_cond
qt4_atomic
qt4_mutex
qt4_rwlock
qt4_semaphore
read_after_free
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
threaded-fork
trylock
tsan_unittest
unit_bitmap
unit_vc
vg_regtest.tmp*
+ *.dSYM
*.stderr.diff*
*.stderr.out
*.stdout.diff*
*.stdout.out
.deps
Makefile
Makefile.in
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
free_is_write
hg01_all_ok
hg02_deadlock
hg03_inherit
hg04_race
hg05_race2
hg06_readshared
hold_lock
linuxthreads_det
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_detached3
pth_detached_sem
pth_inconsistent_cond_wait
pth_mutex_reinit
pth_process_shared_mutex
pth_spinlock
pth_uninitialized_cond
qt4_atomic
qt4_mutex
qt4_rwlock
qt4_semaphore
read_after_free
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
threaded-fork
trylock
tsan_unittest
unit_bitmap
unit_vc
vg_regtest.tmp*
Modified: trunk/drd/tests/Makefile.am
===================================================================
--- trunk/drd/tests/Makefile.am 2011-03-12 12:43:39 UTC (rev 11633)
+++ trunk/drd/tests/Makefile.am 2011-03-12 14:02:06 UTC (rev 11634)
@@ -72,6 +72,8 @@
fp_race.vgtest \
fp_race2.stderr.exp \
fp_race2.vgtest \
+ free_is_write.vgtest \
+ free_is_write.stderr.exp \
hg01_all_ok.stderr.exp \
hg01_all_ok.vgtest \
hg02_deadlock.stderr.exp \
@@ -276,6 +278,7 @@
bug-235681 \
custom_alloc \
fp_race \
+ free_is_write \
hold_lock \
linuxthreads_det \
memory_allocation \
Added: trunk/drd/tests/free_is_write.c
===================================================================
--- trunk/drd/tests/free_is_write.c (rev 0)
+++ trunk/drd/tests/free_is_write.c 2011-03-12 14:02:06 UTC (rev 11634)
@@ -0,0 +1,70 @@
+/* Stress test for the --free-is-write command-line option. */
+
+#include <pthread.h>
+#include <assert.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <string.h>
+
+#define MALLOC_SIZE 22816
+#define THREAD_COUNT 10
+#define MALLOC_COUNT 1000
+
+static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+// 'mutex' protects 'count'.
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static unsigned count;
+
+void* thread_func(void* arg)
+{
+ unsigned i;
+
+ for (i = 0; i < MALLOC_COUNT; ++i) {
+ void* ptr;
+
+ ptr = malloc(MALLOC_SIZE);
+ memset(ptr, 0, MALLOC_SIZE);
+ free(ptr);
+ }
+
+ pthread_mutex_lock(&mutex);
+ ++count;
+ pthread_cond_signal(&cond);
+ pthread_mutex_unlock(&mutex);
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ pthread_t thread[THREAD_COUNT];
+ int result;
+ int i;
+
+ for (i = 0; i < THREAD_COUNT; i++) {
+ result = pthread_create(&thread[i], 0, thread_func, 0);
+ assert(result == 0);
+ }
+
+ pthread_mutex_lock(&mutex);
+ while (count < THREAD_COUNT && pthread_cond_wait(&cond, &mutex) == 0)
+ ;
+ pthread_mutex_unlock(&mutex);
+
+ for (i = 0; i < THREAD_COUNT; i++)
+ pthread_join(thread[i], 0);
+
+ fflush(stdout);
+
+ fprintf(stderr, "Done.\n");
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 2
+ * End:
+ */
Added: trunk/drd/tests/free_is_write.stderr.exp
===================================================================
--- trunk/drd/tests/free_is_write.stderr.exp (rev 0)
+++ trunk/drd/tests/free_is_write.stderr.exp 2011-03-12 14:02:06 UTC (rev 11634)
@@ -0,0 +1,4 @@
+
+Done.
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Added: trunk/drd/tests/free_is_write.vgtest
===================================================================
--- trunk/drd/tests/free_is_write.vgtest (rev 0)
+++ trunk/drd/tests/free_is_write.vgtest 2011-03-12 14:02:06 UTC (rev 11634)
@@ -0,0 +1,4 @@
+prereq: test -e free_is_write && ./supported_libpthread
+vgopts: --read-var-info=yes --free-is-write=yes --show-confl-seg=no
+prog: free_is_write
+args: -q
|