Make some net unittests compile and pass on linux.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@991 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: 4fa725ecd63006b46f2693f219a10a7c62e1a617
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 @@
*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 @@
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
};