mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-23 22:47:12 +01:00
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
This commit is contained in:
parent
64f4cff192
commit
32b165ab61
1 changed files with 11 additions and 3 deletions
|
@ -1368,18 +1368,24 @@ static strmap_t *_thread_test_strmap = NULL;
|
||||||
|
|
||||||
static void _thread_test_func(void* _s) ATTR_NORETURN;
|
static void _thread_test_func(void* _s) ATTR_NORETURN;
|
||||||
|
|
||||||
|
static int t1_count = 0;
|
||||||
|
static int t2_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_thread_test_func(void* _s)
|
_thread_test_func(void* _s)
|
||||||
{
|
{
|
||||||
char *s = _s;
|
char *s = _s;
|
||||||
int i;
|
int i, *count;
|
||||||
tor_mutex_t *m;
|
tor_mutex_t *m;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
char *cp;
|
char *cp;
|
||||||
if (!strcmp(s, "thread 1"))
|
if (!strcmp(s, "thread 1")) {
|
||||||
m = _thread_test_start1;
|
m = _thread_test_start1;
|
||||||
else
|
count = &t1_count;
|
||||||
|
} else {
|
||||||
m = _thread_test_start2;
|
m = _thread_test_start2;
|
||||||
|
count = &t2_count;
|
||||||
|
}
|
||||||
tor_mutex_acquire(m);
|
tor_mutex_acquire(m);
|
||||||
|
|
||||||
tor_snprintf(buf, sizeof(buf), "%lu", tor_get_thread_id());
|
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) {
|
for (i=0; i<100000; ++i) {
|
||||||
tor_mutex_acquire(_thread_test_mutex);
|
tor_mutex_acquire(_thread_test_mutex);
|
||||||
strmap_set(_thread_test_strmap, "last to run", cp);
|
strmap_set(_thread_test_strmap, "last to run", cp);
|
||||||
|
++*count;
|
||||||
tor_mutex_release(_thread_test_mutex);
|
tor_mutex_release(_thread_test_mutex);
|
||||||
}
|
}
|
||||||
tor_mutex_acquire(_thread_test_mutex);
|
tor_mutex_acquire(_thread_test_mutex);
|
||||||
|
@ -1438,6 +1445,7 @@ test_threads(void)
|
||||||
tor_mutex_free(_thread_test_mutex);
|
tor_mutex_free(_thread_test_mutex);
|
||||||
|
|
||||||
if (timedout) {
|
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 1"));
|
||||||
test_assert(strmap_get(_thread_test_strmap, "thread 2"));
|
test_assert(strmap_get(_thread_test_strmap, "thread 2"));
|
||||||
test_assert(!timedout);
|
test_assert(!timedout);
|
||||||
|
|
Loading…
Add table
Reference in a new issue