diff options
Diffstat (limited to 'base')
-rw-r--r-- | base/base_paths_linux.cc | 11 | ||||
-rw-r--r-- | base/base_paths_linux.h | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/base/base_paths_linux.cc b/base/base_paths_linux.cc index 69c9078..298c231 100644 --- a/base/base_paths_linux.cc +++ b/base/base_paths_linux.cc @@ -31,12 +31,15 @@ #include <unistd.h> +#include "base/file_util.h" #include "base/logging.h" +#include "base/path_service.h" #include "base/sys_string_conversions.h" namespace base { bool PathProviderLinux(int key, std::wstring* result) { + std::wstring cur; switch (key) { case base::FILE_EXE: case base::FILE_MODULE: { // TODO(evanm): is this correct? @@ -50,6 +53,14 @@ bool PathProviderLinux(int key, std::wstring* result) { *result = base::SysNativeMBToWide(bin_dir); return true; } + case base::DIR_SOURCE_ROOT: + // On linux, unit tests execute two levels deep from the source root. + // For example: chrome/{Debug|Hammer}/net_unittest + PathService::Get(base::DIR_EXE, &cur); + file_util::UpOneDirectory(&cur); + file_util::UpOneDirectory(&cur); + *result = cur; + return true; } return false; } diff --git a/base/base_paths_linux.h b/base/base_paths_linux.h index b0f3d48..0ba3a19 100644 --- a/base/base_paths_linux.h +++ b/base/base_paths_linux.h @@ -43,6 +43,9 @@ enum { FILE_MODULE, // Path and filename of the module containing the code for the // PathService (which could differ from FILE_EXE if the // PathService were compiled into a shared object, for example). + DIR_SOURCE_ROOT, // Returns the root of the source tree. This key is useful + // for tests that need to locate various resources. It + // should not be used outside of test code. PATH_LINUX_END }; |