]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make unit tests slower but more reliable by disabling an old optimization.
authorNick Mathewson <nickm@torproject.org>
Thu, 18 Dec 2008 06:12:19 +0000 (06:12 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 18 Dec 2008 06:12:19 +0000 (06:12 +0000)
To turn it back on, re-define CACHE_GENERATED_KEYS option in test.c.

svn:r17677

src/or/test.c

index 30042621d4a1771c39b11fcf363f82732a935735..2fa2aac12ecf60e63f89939743aa80200c22c4d1 100644 (file)
@@ -106,16 +106,27 @@ remove_directory(void)
   rmdir(temp_dir);
 }
 
+/** Define this if unit tests spend too much time generating public keys*/
+#undef CACHE_GENERATED_KEYS
+
 static crypto_pk_env_t *pregen_keys[5] = {NULL, NULL, NULL, NULL, NULL};
 static crypto_pk_env_t *
 pk_generate(int idx)
 {
+#ifdef CACHE_GENERATED_KEYS
   tor_assert(idx < (int)(sizeof(pregen_keys)/sizeof(pregen_keys[0])));
   if (! pregen_keys[idx]) {
     pregen_keys[idx] = crypto_new_pk_env();
     tor_assert(!crypto_pk_generate_key(pregen_keys[idx]));
   }
   return crypto_pk_dup_key(pregen_keys[idx]);
+#else
+  crypto_pk_env_t *result;
+  (void) idx;
+  result = crypto_new_pk_env();
+  tor_assert(!crypto_pk_generate_key(result));
+  return result;
+#endif
 }
 
 static void