From de499669ef49ec851ef18ef45c13dc2698bd20df Mon Sep 17 00:00:00 2001 From: "kjellander@webrtc.org" Date: Thu, 29 Aug 2013 11:26:41 +0000 Subject: [PATCH] Fix fileutils.cc for tests running under Win memory tools. On Windows, when tests are run under memory tools like DrMemory and TSan, slashes occur in the path as directory separators. This makes the fileutils.cc fail to figure out the project root, making paths to resource files invalid. By replacing slashes in the path with backslashes for Windows this can be fixed. BUG=2318 TEST=running the same command as the bot locally, succeeding after this patch is applied. R=phoglund@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2137004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4640 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/test/testsupport/fileutils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webrtc/test/testsupport/fileutils.cc b/webrtc/test/testsupport/fileutils.cc index d19d50fe0..c89f9bd1a 100644 --- a/webrtc/test/testsupport/fileutils.cc +++ b/webrtc/test/testsupport/fileutils.cc @@ -12,6 +12,7 @@ #ifdef WIN32 #include +#include #define GET_CURRENT_DIR _getcwd #else #include @@ -67,6 +68,13 @@ void SetExecutablePath(const std::string& path) { if (path.find(working_dir) != std::string::npos) { temp_path = path.substr(working_dir.length() + 1); } + // On Windows, when tests are run under memory tools like DrMemory and TSan, + // slashes occur in the path as directory separators. Make sure we replace + // such cases with backslashes in order for the paths to be correct. +#ifdef WIN32 + std::replace(temp_path.begin(), temp_path.end(), '/', '\\'); +#endif + // Trim away the executable name; only store the relative dir path. temp_path = temp_path.substr(0, temp_path.find_last_of(kPathDelimiter)); strncpy(relative_dir_path, temp_path.c_str(), FILENAME_MAX);