diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-04-05 16:53:07 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-05 16:53:07 -0400 |
commit | 55817c4c5065a7689e17c329b3f4695b6d888220 (patch) | |
tree | 838e2f54fceb11ae7ba5b496037b9729ff89133f /src/test | |
parent | b349f09b4763fb17bf77e3ed128996094d01ac84 (diff) | |
parent | d1dc23c9386c6c85ec50c5b4d0a9077ffcb78683 (diff) | |
download | tor-55817c4c5065a7689e17c329b3f4695b6d888220.tar.gz tor-55817c4c5065a7689e17c329b3f4695b6d888220.zip |
Merge remote-tracking branch 'origin/maint-0.2.4'
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test.c b/src/test/test.c index bd2fa0bb21..1a8565aa16 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -88,8 +88,14 @@ setup_directory(void) { static int is_setup = 0; int r; + char rnd[256], rnd32[256]; if (is_setup) return; +/* Due to base32 limitation needs to be a multiple of 5. */ +#define RAND_PATH_BYTES 5 + crypto_rand(rnd, RAND_PATH_BYTES); + base32_encode(rnd32, sizeof(rnd32), rnd, RAND_PATH_BYTES); + #ifdef _WIN32 { char buf[MAX_PATH]; @@ -98,11 +104,11 @@ setup_directory(void) if (!GetTempPathA(sizeof(buf),buf)) tmp = "c:\\windows\\temp"; tor_snprintf(temp_dir, sizeof(temp_dir), - "%s\\tor_test_%d", tmp, (int)getpid()); + "%s\\tor_test_%d_%s", tmp, (int)getpid(), rnd32); r = mkdir(temp_dir); } #else - tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d", (int) getpid()); + tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d_%s", (int) getpid(), rnd32); r = mkdir(temp_dir, 0700); #endif if (r) { @@ -2182,6 +2188,7 @@ main(int c, const char **v) return 1; } crypto_set_tls_dh_prime(NULL); + crypto_seed_rng(1); rep_hist_init(); network_init(); setup_directory(); @@ -2194,8 +2201,6 @@ main(int c, const char **v) return 1; } - crypto_seed_rng(1); - atexit(remove_directory); have_failed = (tinytest_main(c, v, testgroups) != 0); |