Use GetTempDir instead of hardcoded path to c:\windows\tmp for unittests

This commit is contained in:
Gisle Vanem
2011-04-07 18:34:11 -04:00
committed by Nick Mathewson
parent ba0cd8094f
commit 70e0291468
2 changed files with 14 additions and 4 deletions
+4
View File
@@ -0,0 +1,4 @@
o Unit tests:
- Use GetTempDir to find the proper temporary directory location on
Windows when generating temporary files for the unit tests. Patch
by Gisle Vanem.
+10 -4
View File
@@ -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);