| Index: base/process/process_util_unittest.cc
|
| diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
|
| index 1f7f1b2c776edcfe2942c7564a74a209942804ec..5ed06fb3738b3a22ca42c2e49bdf68317e56b9f6 100644
|
| --- a/base/process/process_util_unittest.cc
|
| +++ b/base/process/process_util_unittest.cc
|
| @@ -50,10 +50,6 @@
|
| #include <sys/wait.h>
|
| #include <unistd.h>
|
| #endif
|
| -#if defined(OS_WIN)
|
| -#include <windows.h>
|
| -#include "base/win/windows_version.h"
|
| -#endif
|
| #if defined(OS_MACOSX)
|
| #include <mach/vm_param.h>
|
| #include <malloc/malloc.h>
|
| @@ -79,12 +75,7 @@ const char kSignalFileKill[] = "KilledChildProcess.die";
|
| const char kSignalFileTerm[] = "TerminatedChildProcess.die";
|
| #endif
|
|
|
| -#if defined(OS_WIN)
|
| -const int kExpectedStillRunningExitCode = 0x102;
|
| -const int kExpectedKilledExitCode = 1;
|
| -#else
|
| const int kExpectedStillRunningExitCode = 0;
|
| -#endif
|
|
|
| // Sleeps until file filename is created.
|
| void WaitToDie(const char* filename) {
|
| @@ -200,19 +191,6 @@ TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) {
|
| remove(signal_file.c_str());
|
| }
|
|
|
| -#if defined(OS_WIN)
|
| -// TODO(cpu): figure out how to test this in other platforms.
|
| -TEST_F(ProcessUtilTest, GetProcId) {
|
| - base::ProcessId id1 = base::GetProcId(GetCurrentProcess());
|
| - EXPECT_NE(0ul, id1);
|
| - base::Process process = SpawnChild("SimpleChildProcess");
|
| - ASSERT_TRUE(process.IsValid());
|
| - base::ProcessId id2 = process.Pid();
|
| - EXPECT_NE(0ul, id2);
|
| - EXPECT_NE(id1, id2);
|
| -}
|
| -#endif
|
| -
|
| #if !defined(OS_MACOSX)
|
| // This test is disabled on Mac, since it's flaky due to ReportCrash
|
| // taking a variable amount of time to parse and load the debug and
|
| @@ -262,9 +240,7 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) {
|
| WaitForChildTermination(process.Handle(), &exit_code);
|
| EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_CRASHED, status);
|
|
|
| -#if defined(OS_WIN)
|
| - EXPECT_EQ(0xc0000005, exit_code);
|
| -#elif defined(OS_POSIX)
|
| +#if defined(OS_POSIX)
|
| int signaled = WIFSIGNALED(exit_code);
|
| EXPECT_NE(0, signaled);
|
| int signal = WTERMSIG(exit_code);
|
| @@ -279,11 +255,7 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) {
|
|
|
| MULTIPROCESS_TEST_MAIN(KilledChildProcess) {
|
| WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileKill).c_str());
|
| -#if defined(OS_WIN)
|
| - // Kill ourselves.
|
| - HANDLE handle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, ::GetCurrentProcessId());
|
| - ::TerminateProcess(handle, kExpectedKilledExitCode);
|
| -#elif defined(OS_POSIX)
|
| +#if defined(OS_POSIX)
|
| // Send a SIGKILL to this process, just like the OOM killer would.
|
| ::kill(getpid(), SIGKILL);
|
| #endif
|
| @@ -321,9 +293,7 @@ TEST_F(ProcessUtilTest, GetTerminationStatusSigKill) {
|
| EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED, status);
|
| #endif
|
|
|
| -#if defined(OS_WIN)
|
| - EXPECT_EQ(kExpectedKilledExitCode, exit_code);
|
| -#elif defined(OS_POSIX)
|
| +#if defined(OS_POSIX)
|
| int signaled = WIFSIGNALED(exit_code);
|
| EXPECT_NE(0, signaled);
|
| int signal = WTERMSIG(exit_code);
|
| @@ -359,98 +329,6 @@ TEST_F(ProcessUtilTest, GetTerminationStatusSigTerm) {
|
| }
|
| #endif
|
|
|
| -#if defined(OS_WIN)
|
| -// TODO(estade): if possible, port this test.
|
| -TEST_F(ProcessUtilTest, GetAppOutput) {
|
| - // Let's create a decently long message.
|
| - std::string message;
|
| - for (int i = 0; i < 1025; i++) { // 1025 so it does not end on a kilo-byte
|
| - // boundary.
|
| - message += "Hello!";
|
| - }
|
| - // cmd.exe's echo always adds a \r\n to its output.
|
| - std::string expected(message);
|
| - expected += "\r\n";
|
| -
|
| - FilePath cmd(L"cmd.exe");
|
| - base::CommandLine cmd_line(cmd);
|
| - cmd_line.AppendArg("/c");
|
| - cmd_line.AppendArg("echo " + message + "");
|
| - std::string output;
|
| - ASSERT_TRUE(base::GetAppOutput(cmd_line, &output));
|
| - EXPECT_EQ(expected, output);
|
| -
|
| - // Let's make sure stderr is ignored.
|
| - base::CommandLine other_cmd_line(cmd);
|
| - other_cmd_line.AppendArg("/c");
|
| - // http://msdn.microsoft.com/library/cc772622.aspx
|
| - cmd_line.AppendArg("echo " + message + " >&2");
|
| - output.clear();
|
| - ASSERT_TRUE(base::GetAppOutput(other_cmd_line, &output));
|
| - EXPECT_EQ("", output);
|
| -}
|
| -
|
| -// TODO(estade): if possible, port this test.
|
| -TEST_F(ProcessUtilTest, LaunchAsUser) {
|
| - base::UserTokenHandle token;
|
| - ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token));
|
| - base::LaunchOptions options;
|
| - options.as_user = token;
|
| - EXPECT_TRUE(base::LaunchProcess(MakeCmdLine("SimpleChildProcess"),
|
| - options).IsValid());
|
| -}
|
| -
|
| -static const char kEventToTriggerHandleSwitch[] = "event-to-trigger-handle";
|
| -
|
| -MULTIPROCESS_TEST_MAIN(TriggerEventChildProcess) {
|
| - std::string handle_value_string =
|
| - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| - kEventToTriggerHandleSwitch);
|
| - CHECK(!handle_value_string.empty());
|
| -
|
| - uint64 handle_value_uint64;
|
| - CHECK(base::StringToUint64(handle_value_string, &handle_value_uint64));
|
| - // Give ownership of the handle to |event|.
|
| - base::WaitableEvent event(base::win::ScopedHandle(
|
| - reinterpret_cast<HANDLE>(handle_value_uint64)));
|
| -
|
| - event.Signal();
|
| -
|
| - return 0;
|
| -}
|
| -
|
| -TEST_F(ProcessUtilTest, InheritSpecifiedHandles) {
|
| - // Manually create the event, so that it can be inheritable.
|
| - SECURITY_ATTRIBUTES security_attributes = {};
|
| - security_attributes.nLength = static_cast<DWORD>(sizeof(security_attributes));
|
| - security_attributes.lpSecurityDescriptor = NULL;
|
| - security_attributes.bInheritHandle = true;
|
| -
|
| - // Takes ownership of the event handle.
|
| - base::WaitableEvent event(base::win::ScopedHandle(
|
| - CreateEvent(&security_attributes, true, false, NULL)));
|
| - base::HandlesToInheritVector handles_to_inherit;
|
| - handles_to_inherit.push_back(event.handle());
|
| - base::LaunchOptions options;
|
| - options.handles_to_inherit = &handles_to_inherit;
|
| -
|
| - base::CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess");
|
| - cmd_line.AppendSwitchASCII(kEventToTriggerHandleSwitch,
|
| - base::Uint64ToString(reinterpret_cast<uint64>(event.handle())));
|
| -
|
| - // This functionality actually requires Vista or later. Make sure that it
|
| - // fails properly on XP.
|
| - if (base::win::GetVersion() < base::win::VERSION_VISTA) {
|
| - EXPECT_FALSE(base::LaunchProcess(cmd_line, options).IsValid());
|
| - return;
|
| - }
|
| -
|
| - // Launch the process and wait for it to trigger the event.
|
| - ASSERT_TRUE(base::LaunchProcess(cmd_line, options).IsValid());
|
| - EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout()));
|
| -}
|
| -#endif // defined(OS_WIN)
|
| -
|
| #if defined(OS_POSIX)
|
|
|
| namespace {
|
|
|