aboutsummaryrefslogtreecommitdiff
path: root/src/test/test.c
diff options
context:
space:
mode:
authorGisle Vanem <gvanem@broadpark.no>2011-04-07 18:34:11 -0400
committerNick Mathewson <nickm@torproject.org>2011-04-07 18:34:11 -0400
commit70e02914682eb1959d8b385f76b5acf7486158cc (patch)
tree79995486839ce9f1d94eb9584d730fbef7de1d26 /src/test/test.c
parentba0cd8094f8e6ae0113ad69958d9d0973bb1f2c3 (diff)
downloadtor-70e02914682eb1959d8b385f76b5acf7486158cc.tar
tor-70e02914682eb1959d8b385f76b5acf7486158cc.tar.gz
Use GetTempDir instead of hardcoded path to c:\windows\tmp for unittests
Diffstat (limited to 'src/test/test.c')
-rw-r--r--src/test/test.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/test/test.c b/src/test/test.c
index f5b6a222a..9b24a99b5 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -84,10 +84,16 @@ setup_directory(void)
if (is_setup) return;
#ifdef MS_WINDOWS
- // XXXX
- tor_snprintf(temp_dir, sizeof(temp_dir),
- "c:\\windows\\temp\\tor_test_%d", (int)getpid());
- r = mkdir(temp_dir);
+ {
+ char buf[MAX_PATH];
+ const char *tmp = buf;
+ /* If this fails, we're probably screwed anyway */
+ if (!GetTempPath(sizeof(buf),buf))
+ tmp = "c:\\windows\\temp";
+ tor_snprintf(temp_dir, sizeof(temp_dir),
+ "%s\\tor_test_%d", tmp, (int)getpid());
+ r = mkdir(temp_dir);
+ }
#else
tor_snprintf(temp_dir, sizeof(temp_dir), "/tmp/tor_test_%d", (int) getpid());
r = mkdir(temp_dir, 0700);