summaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-03-06 23:48:55 +0000
committerNick Mathewson <nickm@torproject.org>2007-03-06 23:48:55 +0000
commit2036470b62910f9ea8b7782958ad4031087b6423 (patch)
treed2924f255c06055b542e3b71408add6eb169bb6e /src/or/test.c
parent0d5f981f09132bc4f6824a6220dc51434319e4fb (diff)
downloadtor-2036470b62910f9ea8b7782958ad4031087b6423.tar.gz
tor-2036470b62910f9ea8b7782958ad4031087b6423.zip
r12098@catbus: nickm | 2007-03-06 18:48:50 -0500
Try to make unit tests happier on 64-bit platforms. svn:r9752
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 309d4032a3..f707551b2f 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -1181,19 +1181,23 @@ _thread_test_func(void* _s)
char *s = _s;
int i;
tor_mutex_t *m;
+ char buf[64];
+ char *cp;
if (!strcmp(s, "thread 1"))
m = _thread_test_start1;
else
m = _thread_test_start2;
tor_mutex_acquire(m);
+ tor_snprintf(buf, sizeof(buf), "%lu", tor_get_thread_id());
+ cp = tor_strdup(buf);
+
for (i=0; i<1000; ++i) {
tor_mutex_acquire(_thread_test_mutex);
- strmap_set(_thread_test_strmap, "last to run",
- (void*)(int)tor_get_thread_id());
+ strmap_set(_thread_test_strmap, "last to run", cp);
tor_mutex_release(_thread_test_mutex);
}
- strmap_set(_thread_test_strmap, s, (void*)(int)tor_get_thread_id());
+ strmap_set(_thread_test_strmap, s, tor_strdup(buf));
tor_mutex_release(m);
@@ -1234,14 +1238,14 @@ test_threads(void)
tor_mutex_free(_thread_test_mutex);
/* different thread IDs. */
- test_neq_ptr(strmap_get(_thread_test_strmap, "thread 1"),
- strmap_get(_thread_test_strmap, "thread 2"));
- test_assert(strmap_get(_thread_test_strmap, "thread 1") ==
- strmap_get(_thread_test_strmap, "last to run") ||
- strmap_get(_thread_test_strmap, "thread 2") ==
- strmap_get(_thread_test_strmap, "last to run"));
-
- strmap_free(_thread_test_strmap, NULL);
+ test_assert(strcmp(strmap_get(_thread_test_strmap, "thread 1"),
+ strmap_get(_thread_test_strmap, "thread 2")));
+ test_assert(!strcmp(strmap_get(_thread_test_strmap, "thread 1"),
+ strmap_get(_thread_test_strmap, "last to run")) ||
+ !strcmp(strmap_get(_thread_test_strmap, "thread 2"),
+ strmap_get(_thread_test_strmap, "last to run")));
+
+ strmap_free(_thread_test_strmap, _tor_free);
tor_free(s1);
tor_free(s2);