[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9752: Try to make unit tests happier on 64-bit platforms. (in tor/trunk: . src/or)



Author: nickm
Date: 2007-03-06 18:48:55 -0500 (Tue, 06 Mar 2007)
New Revision: 9752

Modified:
   tor/trunk/
   tor/trunk/src/or/test.c
Log:
 r12098@catbus:  nickm | 2007-03-06 18:48:50 -0500
 Try to make unit tests happier on 64-bit platforms.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12098] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-03-06 20:55:10 UTC (rev 9751)
+++ tor/trunk/src/or/test.c	2007-03-06 23:48:55 UTC (rev 9752)
@@ -1181,19 +1181,23 @@
   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 @@
   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"));
+  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, NULL);
+  strmap_free(_thread_test_strmap, _tor_free);
 
   tor_free(s1);
   tor_free(s2);