summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorjiangj@opera.com <jiangj@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 13:30:25 +0000
committerjiangj@opera.com <jiangj@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-06 13:30:25 +0000
commit40fd7056a83ec757fc3d3179da85e4d5b85cd3b9 (patch)
treeb6ff2dfcf5c732c0992277957285d962f19e4808 /base
parent8ff4fb5d09458b33dbff219857c9a35c546178a3 (diff)
downloadchromium_src-40fd7056a83ec757fc3d3179da85e4d5b85cd3b9.zip
chromium_src-40fd7056a83ec757fc3d3179da85e4d5b85cd3b9.tar.gz
chromium_src-40fd7056a83ec757fc3d3179da85e4d5b85cd3b9.tar.bz2
Fix GetNSExecutablePath for running tests with relative path
When running tests (zip_unittests.cc for instance) using base::DIR_SOURCE_ROOT with ./<test_executable_name> they will get incorrect directory names because ./ will be included in the return value of GetNSExecutablePath() and it will be consider as one level of parent directory by FilePath::DirName(). To avoid this problem we should alway convert the value returned by GetNSExecutablePath() into absolute path first. BUG=258846 TEST=see bug Review URL: https://chromiumcodereview.appspot.com/18309008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base_paths_mac.mm7
1 files changed, 6 insertions, 1 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index a1121aa..5d4461c 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -32,7 +32,12 @@ void GetNSExecutablePath(base::FilePath* path) {
int rv = _NSGetExecutablePath(WriteInto(&executable_path, executable_length),
&executable_length);
DCHECK_EQ(rv, 0);
- *path = base::FilePath(executable_path);
+
+ // _NSGetExecutablePath may return paths containing ./ or ../ which makes
+ // FilePath::DirName() work incorrectly, convert it to absolute path so that
+ // paths such as DIR_SOURCE_ROOT can work, since we expect absolute paths to
+ // be returned here.
+ *path = base::MakeAbsoluteFilePath(base::FilePath(executable_path));
}
// Returns true if the module for |address| is found. |path| will contain