]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use GetTempDir instead of hardcoded path to c:\windows\tmp for unittests
authorGisle Vanem <gvanem@broadpark.no>
Thu, 7 Apr 2011 22:34:11 +0000 (18:34 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 7 Apr 2011 22:34:11 +0000 (18:34 -0400)
changes/win_tmp_dir [new file with mode: 0644]
src/test/test.c

diff --git a/changes/win_tmp_dir b/changes/win_tmp_dir
new file mode 100644 (file)
index 0000000..13f6e7f
--- /dev/null
@@ -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.
index f5b6a222a745e43a837385f7844b5181d6900551..9b24a99b589f988d38d5b01f4dfead1c6c2ee5e2 100644 (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);