summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/debug/debugger_posix.cc6
-rw-r--r--base/dir_reader_posix_unittest.cc4
-rw-r--r--base/files/file_path_watcher_stub.cc7
-rw-r--r--base/memory/mru_cache_unittest.cc2
-rw-r--r--base/message_loop.h4
-rw-r--r--base/os_compat_android.cc2
-rw-r--r--base/process_util.h8
-rw-r--r--base/process_util_unittest.cc71
-rw-r--r--base/synchronization/cancellation_flag_unittest.cc2
9 files changed, 80 insertions, 26 deletions
diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc
index 089d53d..8b4c8f1 100644
--- a/base/debug/debugger_posix.cc
+++ b/base/debug/debugger_posix.cc
@@ -6,7 +6,6 @@
#include "build/build_config.h"
#include <errno.h>
-#include <execinfo.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -18,6 +17,10 @@
#include <string>
#include <vector>
+#if !defined(OS_ANDROID)
+#include <execinfo.h>
+#endif
+
#if defined(__GLIBCXX__)
#include <cxxabi.h>
#endif
@@ -45,7 +48,6 @@
#endif
#if defined(OS_ANDROID)
-#include <execinfo.h>
#include "base/threading/platform_thread.h"
#endif
diff --git a/base/dir_reader_posix_unittest.cc b/base/dir_reader_posix_unittest.cc
index dd53783..5aefb9a 100644
--- a/base/dir_reader_posix_unittest.cc
+++ b/base/dir_reader_posix_unittest.cc
@@ -13,6 +13,10 @@
#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(OS_ANDROID)
+#include "base/os_compat_android.h"
+#endif
+
namespace base {
TEST(DirReaderPosixUnittest, Read) {
diff --git a/base/files/file_path_watcher_stub.cc b/base/files/file_path_watcher_stub.cc
index a693dc7..6c49101 100644
--- a/base/files/file_path_watcher_stub.cc
+++ b/base/files/file_path_watcher_stub.cc
@@ -15,10 +15,13 @@ namespace {
class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
public:
virtual bool Watch(const FilePath& path,
- FileWatcher::Delegate* delegate,
- base::MessageLoopProxy*) OVERRIDE {
+ FilePathWatcher::Delegate* delegate) OVERRIDE {
return false;
}
+
+ virtual void Cancel() OVERRIDE {}
+
+ virtual void CancelOnMessageLoopThread() OVERRIDE {}
};
} // namespace
diff --git a/base/memory/mru_cache_unittest.cc b/base/memory/mru_cache_unittest.cc
index 39677f2..1fe9ce2 100644
--- a/base/memory/mru_cache_unittest.cc
+++ b/base/memory/mru_cache_unittest.cc
@@ -267,5 +267,5 @@ TEST(MRUCacheTest, HashingMRUCache) {
EXPECT_EQ(two.value, cache.Get("Second")->second.value);
cache.ShrinkToSize(1);
EXPECT_EQ(two.value, cache.Get("Second")->second.value);
- EXPECT_EQ(cache.end(), cache.Get("First"));
+ EXPECT_TRUE(cache.Get("First") == cache.end());
}
diff --git a/base/message_loop.h b/base/message_loop.h
index ab4978a..67980ea 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -27,7 +27,7 @@
#include "base/message_pump_win.h"
#elif defined(OS_POSIX)
#include "base/message_pump_libevent.h"
-#if !defined(OS_MACOSX)
+#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
#if defined(USE_WAYLAND)
#include "base/message_pump_wayland.h"
@@ -85,7 +85,7 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
#if defined(OS_WIN)
typedef base::MessagePumpWin::Dispatcher Dispatcher;
typedef base::MessagePumpForUI::Observer Observer;
-#elif !defined(OS_MACOSX)
+#elif !defined(OS_MACOSX) && !defined(OS_ANDROID)
typedef base::MessagePumpDispatcher Dispatcher;
typedef base::MessagePumpObserver Observer;
#endif
diff --git a/base/os_compat_android.cc b/base/os_compat_android.cc
index 5c4f2ab..d500656 100644
--- a/base/os_compat_android.cc
+++ b/base/os_compat_android.cc
@@ -4,7 +4,7 @@
#include "base/os_compat_android.h"
-#include "base/string_util.h"
+#include "base/stringprintf.h"
// There is no futimes() avaiable in Bionic, so we provide our own
// implementation until it is there.
diff --git a/base/process_util.h b/base/process_util.h
index 574332f8..4cd1da3 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -164,7 +164,7 @@ BASE_EXPORT void CloseProcessHandle(ProcessHandle process);
// Win XP SP1 as well.
BASE_EXPORT ProcessId GetProcId(ProcessHandle process);
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_ANDROID)
// Returns the path to the executable of the given process.
BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process);
@@ -184,7 +184,7 @@ const int kMaxOomScore = 1000;
// translate the given value into [0, 15]. Some aliasing of values
// may occur in that case, of course.
BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score);
-#endif // defined(OS_LINUX)
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_POSIX)
// Returns the ID for the parent of the given process.
@@ -712,7 +712,7 @@ class BASE_EXPORT ProcessMetrics {
DISALLOW_COPY_AND_ASSIGN(ProcessMetrics);
};
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_ANDROID)
// Data from /proc/meminfo about system-wide memory consumption.
// Values are in KB.
struct SystemMemoryInfoKB {
@@ -730,7 +730,7 @@ struct SystemMemoryInfoKB {
// Fills in the provided |meminfo| structure. Returns true on success.
// Exposed for memory debugging widget.
BASE_EXPORT bool GetSystemMemoryInfo(SystemMemoryInfoKB* meminfo);
-#endif // defined(OS_LINUX)
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
// Returns the memory committed by the system in KBytes.
// Returns 0 if it can't compute the commit charge.
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 60cdcf9..fcd65a5 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -34,6 +34,9 @@
#include <sys/resource.h>
#include <sys/socket.h>
#endif
+#if defined(OS_ANDROID)
+#include <sys/wait.h>
+#endif
#if defined(OS_WIN)
#include <windows.h>
#endif
@@ -50,6 +53,14 @@ const wchar_t kProcessName[] = L"base_unittests.exe";
const wchar_t kProcessName[] = L"base_unittests";
#endif // defined(OS_WIN)
+#if defined(OS_ANDROID)
+const char kShellPath[] = "/system/bin/sh";
+const char kPosixShell[] = "sh";
+#else
+const char kShellPath[] = "/bin/sh";
+const char kPosixShell[] = "bash";
+#endif
+
const char kSignalFileSlow[] = "SlowChildProcess.die";
const char kSignalFileCrash[] = "CrashingChildProcess.die";
const char kSignalFileKill[] = "KilledChildProcess.die";
@@ -533,7 +544,7 @@ std::string TestLaunchProcess(const base::environment_vector& env_changes,
std::vector<std::string> args;
base::file_handle_mapping_vector fds_to_remap;
- args.push_back("bash");
+ args.push_back(kPosixShell);
args.push_back("-c");
args.push_back("echo $BASE_TEST");
@@ -654,6 +665,24 @@ TEST_F(ProcessUtilTest, AlterEnvironment) {
TEST_F(ProcessUtilTest, GetAppOutput) {
std::string output;
+
+#if defined(OS_ANDROID)
+ std::vector<std::string> argv;
+ argv.push_back("sh"); // Instead of /bin/sh, force path search to find it.
+ argv.push_back("-c");
+
+ argv.push_back("exit 0");
+ EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output));
+ EXPECT_STREQ("", output.c_str());
+
+ argv[2] = "exit 1";
+ EXPECT_FALSE(base::GetAppOutput(CommandLine(argv), &output));
+ EXPECT_STREQ("", output.c_str());
+
+ argv[2] = "echo foobar42";
+ EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output));
+ EXPECT_STREQ("foobar42\n", output.c_str());
+#else
EXPECT_TRUE(base::GetAppOutput(CommandLine(FilePath("true")), &output));
EXPECT_STREQ("", output.c_str());
@@ -665,6 +694,7 @@ TEST_F(ProcessUtilTest, GetAppOutput) {
argv.push_back("foobar42");
EXPECT_TRUE(base::GetAppOutput(CommandLine(argv), &output));
EXPECT_STREQ("foobar42", output.c_str());
+#endif // defined(OS_ANDROID)
}
TEST_F(ProcessUtilTest, GetAppOutputRestricted) {
@@ -672,8 +702,8 @@ TEST_F(ProcessUtilTest, GetAppOutputRestricted) {
// everything is. So let's use /bin/sh, which is on every POSIX system, and
// its built-ins.
std::vector<std::string> argv;
- argv.push_back("/bin/sh"); // argv[0]
- argv.push_back("-c"); // argv[1]
+ argv.push_back(std::string(kShellPath)); // argv[0]
+ argv.push_back("-c"); // argv[1]
// On success, should set |output|. We use |/bin/sh -c 'exit 0'| instead of
// |true| since the location of the latter may be |/bin| or |/usr/bin| (and we
@@ -718,18 +748,25 @@ TEST_F(ProcessUtilTest, GetAppOutputRestrictedSIGPIPE) {
std::vector<std::string> argv;
std::string output;
- argv.push_back("/bin/sh");
+ argv.push_back(std::string(kShellPath)); // argv[0]
argv.push_back("-c");
+#if defined(OS_ANDROID)
+ argv.push_back("while echo 12345678901234567890; do :; done");
+ EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10));
+ EXPECT_STREQ("1234567890", output.c_str());
+#else
argv.push_back("yes");
EXPECT_TRUE(base::GetAppOutputRestricted(CommandLine(argv), &output, 10));
EXPECT_STREQ("y\ny\ny\ny\ny\n", output.c_str());
+#endif
}
#endif
TEST_F(ProcessUtilTest, GetAppOutputRestrictedNoZombies) {
std::vector<std::string> argv;
- argv.push_back("/bin/sh"); // argv[0]
- argv.push_back("-c"); // argv[1]
+
+ argv.push_back(std::string(kShellPath)); // argv[0]
+ argv.push_back("-c"); // argv[1]
argv.push_back("echo 123456789012345678901234567890"); // argv[2]
// Run |GetAppOutputRestricted()| 300 (> default per-user processes on Mac OS
@@ -753,9 +790,9 @@ TEST_F(ProcessUtilTest, GetAppOutputWithExitCode) {
std::vector<std::string> argv;
std::string output;
int exit_code;
- argv.push_back("/bin/sh"); // argv[0]
- argv.push_back("-c"); // argv[1]
- argv.push_back("echo foo"); // argv[2];
+ argv.push_back(std::string(kShellPath)); // argv[0]
+ argv.push_back("-c"); // argv[1]
+ argv.push_back("echo foo"); // argv[2];
EXPECT_TRUE(base::GetAppOutputWithExitCode(CommandLine(argv), &output,
&exit_code));
EXPECT_STREQ("foo\n", output.c_str());
@@ -776,7 +813,7 @@ TEST_F(ProcessUtilTest, GetParentProcessId) {
EXPECT_EQ(ppid, getppid());
}
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_ANDROID)
TEST_F(ProcessUtilTest, ParseProcStatCPU) {
// /proc/self/stat for a process running "top".
const char kTopStat[] = "960 (top) S 16230 960 16230 34818 960 "
@@ -796,7 +833,7 @@ TEST_F(ProcessUtilTest, ParseProcStatCPU) {
EXPECT_EQ(0, base::ParseProcStatCPU(kSelfStat));
}
-#endif // defined(OS_LINUX)
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // defined(OS_POSIX)
@@ -809,6 +846,9 @@ int tc_set_new_mode(int mode);
}
#endif // defined(USE_TCMALLOC)
+// Android doesn't implement set_new_handler, so we can't use the
+// OutOfMemoryTest cases.
+#if !defined(OS_ANDROID)
class OutOfMemoryDeathTest : public testing::Test {
public:
OutOfMemoryDeathTest()
@@ -913,7 +953,8 @@ TEST_F(OutOfMemoryDeathTest, ViaSharedLibraries) {
}
#endif // OS_LINUX
-#if defined(OS_POSIX)
+// Android doesn't implement posix_memalign().
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
TEST_F(OutOfMemoryDeathTest, Posix_memalign) {
typedef int (*memalign_t)(void **, size_t, size_t);
#if defined(OS_MACOSX)
@@ -923,7 +964,7 @@ TEST_F(OutOfMemoryDeathTest, Posix_memalign) {
reinterpret_cast<memalign_t>(dlsym(RTLD_DEFAULT, "posix_memalign"));
#else
memalign_t memalign = posix_memalign;
-#endif // OS_*
+#endif // defined(OS_MACOSX)
if (memalign) {
// Grab the return value of posix_memalign to silence a compiler warning
// about unused return values. We don't actually care about the return
@@ -934,7 +975,7 @@ TEST_F(OutOfMemoryDeathTest, Posix_memalign) {
}, "");
}
}
-#endif // OS_POSIX
+#endif // defined(OS_POSIX) && !defined(OS_ANDROID)
#if defined(OS_MACOSX)
@@ -1040,4 +1081,6 @@ TEST_F(OutOfMemoryDeathTest, PsychoticallyBigObjCObject) {
#endif // !ARCH_CPU_64_BITS
#endif // OS_MACOSX
+#endif // !defined(OS_ANDROID)
+
#endif // !defined(OS_WIN)
diff --git a/base/synchronization/cancellation_flag_unittest.cc b/base/synchronization/cancellation_flag_unittest.cc
index c405c79..e4b5830 100644
--- a/base/synchronization/cancellation_flag_unittest.cc
+++ b/base/synchronization/cancellation_flag_unittest.cc
@@ -26,7 +26,9 @@ class CancelTask : public Task {
public:
explicit CancelTask(CancellationFlag* flag) : flag_(flag) {}
virtual void Run() {
+#if GTEST_HAS_DEATH_TEST
ASSERT_DEBUG_DEATH(flag_->Set(), "");
+#endif
}
private:
CancellationFlag* flag_;