summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-04-07 20:27:39 -0400
committerNick Mathewson <nickm@torproject.org>2011-04-07 20:27:39 -0400
commit85ac832a1474e274ff4a6ad9444cf5e0ab12450e (patch)
tree91cdfc6019b3b5fc63b75ee7f8af365659ce05db
parent67d88a7d6021e95a2d423a9f26811accd1da39b6 (diff)
parent70e02914682eb1959d8b385f76b5acf7486158cc (diff)
downloadtor-85ac832a1474e274ff4a6ad9444cf5e0ab12450e.tar.gz
tor-85ac832a1474e274ff4a6ad9444cf5e0ab12450e.zip
Merge remote-tracking branch 'origin/maint-0.2.2'
-rw-r--r--changes/win_tmp_dir4
-rw-r--r--src/test/test.c14
2 files changed, 14 insertions, 4 deletions
diff --git a/changes/win_tmp_dir b/changes/win_tmp_dir
new file mode 100644
index 0000000000..13f6e7f1cf
--- /dev/null
+++ b/changes/win_tmp_dir
@@ -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.
diff --git a/src/test/test.c b/src/test/test.c
index 02e3970557..e2f8b115d3 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);