From 32b165ab618be4815b907f8f499c1f6296bec11b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 2 Jul 2007 21:08:03 +0000 Subject: [PATCH] r13604@catbus: nickm | 2007-07-02 16:58:40 -0400 Some temporary output to try to figure out where bsd thread unit tests are going wrong svn:r10728 --- src/or/test.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/or/test.c b/src/or/test.c index 80a9c5710b..d34c723879 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -1368,18 +1368,24 @@ static strmap_t *_thread_test_strmap = NULL; static void _thread_test_func(void* _s) ATTR_NORETURN; +static int t1_count = 0; +static int t2_count = 0; + static void _thread_test_func(void* _s) { char *s = _s; - int i; + int i, *count; tor_mutex_t *m; char buf[64]; char *cp; - if (!strcmp(s, "thread 1")) + if (!strcmp(s, "thread 1")) { m = _thread_test_start1; - else + count = &t1_count; + } else { m = _thread_test_start2; + count = &t2_count; + } tor_mutex_acquire(m); tor_snprintf(buf, sizeof(buf), "%lu", tor_get_thread_id()); @@ -1388,6 +1394,7 @@ _thread_test_func(void* _s) for (i=0; i<100000; ++i) { tor_mutex_acquire(_thread_test_mutex); strmap_set(_thread_test_strmap, "last to run", cp); + ++*count; tor_mutex_release(_thread_test_mutex); } tor_mutex_acquire(_thread_test_mutex); @@ -1438,6 +1445,7 @@ test_threads(void) tor_mutex_free(_thread_test_mutex); if (timedout) { + printf("\nTimed out: %d %d", t1_count, t2_count); test_assert(strmap_get(_thread_test_strmap, "thread 1")); test_assert(strmap_get(_thread_test_strmap, "thread 2")); test_assert(!timedout);