summaryrefslogtreecommitdiffstats
path: root/base/base_paths_linux.cc
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 19:30:46 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 19:30:46 +0000
commit95d050e357cd2f2a226621dd8639baaf30cad544 (patch)
treea44275da340d48f19a8898c80ac841800ec55141 /base/base_paths_linux.cc
parent697b87dd539e18cf21d5e65a7e55919f615e394c (diff)
downloadchromium_src-95d050e357cd2f2a226621dd8639baaf30cad544.zip
chromium_src-95d050e357cd2f2a226621dd8639baaf30cad544.tar.gz
chromium_src-95d050e357cd2f2a226621dd8639baaf30cad544.tar.bz2
Hack to make tests work if out is a symlink: see if the current dir is the source root.
Fix some tests that were manually getting sourcedir from DIR_EXE instead of using DIR_SOURCE_ROOT. BUG=none TEST=rm -r out, ln -s /somedir/out out, run tests Review URL: http://codereview.chromium.org/192064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/base_paths_linux.cc')
-rw-r--r--base/base_paths_linux.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc
index 151c411..ca5ca4e 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_linux.cc
@@ -39,12 +39,23 @@ bool PathProviderLinux(int key, FilePath* result) {
case base::DIR_SOURCE_ROOT:
// On linux, unit tests execute two levels deep from the source root.
// For example: sconsbuild/{Debug|Release}/net_unittest
- if (!PathService::Get(base::DIR_EXE, &path))
- return false;
- path = path.Append(FilePath::kParentDirectory)
- .Append(FilePath::kParentDirectory);
- *result = path;
- return true;
+ if (PathService::Get(base::DIR_EXE, &path)) {
+ path = path.DirName().DirName();
+ if (file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ *result = path;
+ return true;
+ }
+ }
+ // If that failed (maybe the build output is symlinked to a different
+ // drive) try assuming the current directory is the source root.
+ if (file_util::GetCurrentDirectory(&path) &&
+ file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ *result = path;
+ return true;
+ }
+ LOG(ERROR) << "Couldn't find your source root. "
+ << "Try running from your chromium/src directory.";
+ return false;
}
return false;
}