diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-07-16 11:31:22 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-07-16 11:39:03 +0200 |
commit | 3f683aadcd03c311c1d987ab847a77dbe3fb2bf1 (patch) | |
tree | 0188f572c1835cf13c707b386a55895b30820946 /src/test/test.c | |
parent | 4da4c4c63f02e9551eaeb8ad9ce5c6f2d1f34ef9 (diff) | |
download | tor-3f683aadcd03c311c1d987ab847a77dbe3fb2bf1.tar.gz tor-3f683aadcd03c311c1d987ab847a77dbe3fb2bf1.zip |
When making a tempdir for windows unit tests, avoid an extra backslash
The extra \ is harmless, but mildly unpleasant.
Fixes 12392; bugfix on 0.2.2.25-alpha where we started using
GetTempDir(). Based on a patch by Gisle Vanem.
Diffstat (limited to 'src/test/test.c')
-rw-r--r-- | src/test/test.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/test/test.c b/src/test/test.c index 8bce9c91f4..429e79ccdc 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -106,11 +106,18 @@ setup_directory(void) { char buf[MAX_PATH]; const char *tmp = buf; + const char *extra_backslash = ""; /* If this fails, we're probably screwed anyway */ if (!GetTempPathA(sizeof(buf),buf)) - tmp = "c:\\windows\\temp"; + tmp = "c:\\windows\\temp\\"; + if (strcmpend(tmp, "\\")) { + /* According to MSDN, it should be impossible for GetTempPath to give us + * an answer that doesn't end with \. But let's make sure. */ + extra_backslash = "\\"; + } tor_snprintf(temp_dir, sizeof(temp_dir), - "%s\\tor_test_%d_%s", tmp, (int)getpid(), rnd32); + "%s%stor_test_%d_%s", tmp, extra_backslash, + (int)getpid(), rnd32); r = mkdir(temp_dir); } #else |