Commit 40fd7056 authored by jiangj@opera.com's avatar jiangj@opera.com

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
parent 8ff4fb5d
...@@ -32,7 +32,12 @@ void GetNSExecutablePath(base::FilePath* path) { ...@@ -32,7 +32,12 @@ void GetNSExecutablePath(base::FilePath* path) {
int rv = _NSGetExecutablePath(WriteInto(&executable_path, executable_length), int rv = _NSGetExecutablePath(WriteInto(&executable_path, executable_length),
&executable_length); &executable_length);
DCHECK_EQ(rv, 0); 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 // Returns true if the module for |address| is found. |path| will contain
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment