diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/base/process/process_util_unittest.cc | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/base/process/process_util_unittest.cc')
-rw-r--r-- | chromium/base/process/process_util_unittest.cc | 104 |
1 files changed, 69 insertions, 35 deletions
diff --git a/chromium/base/process/process_util_unittest.cc b/chromium/base/process/process_util_unittest.cc index 6bfc1d07388..20623a60e18 100644 --- a/chromium/base/process/process_util_unittest.cc +++ b/chromium/base/process/process_util_unittest.cc @@ -144,8 +144,9 @@ MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { return 0; } +// TODO(viettrungluu): This should be in a "MultiProcessTestTest". TEST_F(ProcessUtilTest, SpawnChild) { - base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); + base::ProcessHandle handle = SpawnChild("SimpleChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); EXPECT_TRUE(base::WaitForSingleProcess( handle, TestTimeouts::action_max_timeout())); @@ -161,7 +162,7 @@ TEST_F(ProcessUtilTest, KillSlowChild) { const std::string signal_file = ProcessUtilTest::GetSignalFilePath(kSignalFileSlow); remove(signal_file.c_str()); - base::ProcessHandle handle = this->SpawnChild("SlowChildProcess", false); + base::ProcessHandle handle = SpawnChild("SlowChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); SignalChildren(signal_file.c_str()); EXPECT_TRUE(base::WaitForSingleProcess( @@ -175,7 +176,7 @@ TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) { const std::string signal_file = ProcessUtilTest::GetSignalFilePath(kSignalFileSlow); remove(signal_file.c_str()); - base::ProcessHandle handle = this->SpawnChild("SlowChildProcess", false); + base::ProcessHandle handle = SpawnChild("SlowChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); int exit_code = 42; @@ -198,7 +199,7 @@ TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) { TEST_F(ProcessUtilTest, GetProcId) { base::ProcessId id1 = base::GetProcId(GetCurrentProcess()); EXPECT_NE(0ul, id1); - base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); + base::ProcessHandle handle = SpawnChild("SimpleChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); base::ProcessId id2 = base::GetProcId(handle); EXPECT_NE(0ul, id2); @@ -233,8 +234,7 @@ MULTIPROCESS_TEST_MAIN(CrashingChildProcess) { // This test intentionally crashes, so we don't need to run it under // AddressSanitizer. -// TODO(jschuh): crbug.com/175753 Fix this in Win64 bots. -#if defined(ADDRESS_SANITIZER) || (defined(OS_WIN) && defined(ARCH_CPU_X86_64)) +#if defined(ADDRESS_SANITIZER) || defined(SYZYASAN) #define MAYBE_GetTerminationStatusCrash DISABLED_GetTerminationStatusCrash #else #define MAYBE_GetTerminationStatusCrash GetTerminationStatusCrash @@ -243,8 +243,7 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) { const std::string signal_file = ProcessUtilTest::GetSignalFilePath(kSignalFileCrash); remove(signal_file.c_str()); - base::ProcessHandle handle = this->SpawnChild("CrashingChildProcess", - false); + base::ProcessHandle handle = SpawnChild("CrashingChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); int exit_code = 42; @@ -291,8 +290,7 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) { const std::string signal_file = ProcessUtilTest::GetSignalFilePath(kSignalFileKill); remove(signal_file.c_str()); - base::ProcessHandle handle = this->SpawnChild("KilledChildProcess", - false); + base::ProcessHandle handle = SpawnChild("KilledChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); int exit_code = 42; @@ -322,7 +320,7 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) { // Note: a platform may not be willing or able to lower the priority of // a process. The calls to SetProcessBackground should be noops then. TEST_F(ProcessUtilTest, SetProcessBackgrounded) { - base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess", false); + base::ProcessHandle handle = SpawnChild("SimpleChildProcess"); base::Process process(handle); int old_priority = process.GetPriority(); #if defined(OS_WIN) @@ -393,8 +391,8 @@ TEST_F(ProcessUtilTest, LaunchAsUser) { ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); base::LaunchOptions options; options.as_user = token; - EXPECT_TRUE(base::LaunchProcess( - this->MakeCmdLine("SimpleChildProcess", false), options, NULL)); + EXPECT_TRUE(base::LaunchProcess(MakeCmdLine("SimpleChildProcess"), options, + NULL)); } static const char kEventToTriggerHandleSwitch[] = "event-to-trigger-handle"; @@ -430,7 +428,7 @@ TEST_F(ProcessUtilTest, InheritSpecifiedHandles) { base::LaunchOptions options; options.handles_to_inherit = &handles_to_inherit; - CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess", false); + CommandLine cmd_line = MakeCmdLine("TriggerEventChildProcess"); cmd_line.AppendSwitchASCII(kEventToTriggerHandleSwitch, base::Uint64ToString(reinterpret_cast<uint64>(event.handle()))); @@ -505,8 +503,10 @@ int ProcessUtilTest::CountOpenFDsInChild() { base::FileHandleMappingVector fd_mapping_vec; fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe)); - base::ProcessHandle handle = this->SpawnChild( - "ProcessUtilsLeakFDChildProcess", fd_mapping_vec, false); + base::LaunchOptions options; + options.fds_to_remap = &fd_mapping_vec; + base::ProcessHandle handle = + SpawnChildWithOptions("ProcessUtilsLeakFDChildProcess", options); CHECK(handle); int ret = IGNORE_EINTR(close(fds[1])); DPCHECK(ret == 0); @@ -517,7 +517,7 @@ int ProcessUtilTest::CountOpenFDsInChild() { HANDLE_EINTR(read(fds[0], &num_open_files, sizeof(num_open_files))); CHECK_EQ(bytes_read, static_cast<ssize_t>(sizeof(num_open_files))); -#if defined(THREAD_SANITIZER) || defined(USE_HEAPCHECKER) +#if defined(THREAD_SANITIZER) // Compiler-based ThreadSanitizer makes this test slow. CHECK(base::WaitForSingleProcess(handle, base::TimeDelta::FromSeconds(3))); #else @@ -562,15 +562,12 @@ TEST_F(ProcessUtilTest, MAYBE_FDRemapping) { namespace { -std::string TestLaunchProcess(const base::EnvironmentMap& env_changes, +std::string TestLaunchProcess(const std::vector<std::string>& args, + const base::EnvironmentMap& env_changes, + const bool clear_environ, const int clone_flags) { - std::vector<std::string> args; base::FileHandleMappingVector fds_to_remap; - args.push_back(kPosixShell); - args.push_back("-c"); - args.push_back("echo $BASE_TEST"); - int fds[2]; PCHECK(pipe(fds) == 0); @@ -578,6 +575,7 @@ std::string TestLaunchProcess(const base::EnvironmentMap& env_changes, base::LaunchOptions options; options.wait = true; options.environ = env_changes; + options.clear_environ = clear_environ; options.fds_to_remap = &fds_to_remap; #if defined(OS_LINUX) options.clone_flags = clone_flags; @@ -589,7 +587,6 @@ std::string TestLaunchProcess(const base::EnvironmentMap& env_changes, char buf[512]; const ssize_t n = HANDLE_EINTR(read(fds[0], buf, sizeof(buf))); - PCHECK(n > 0); PCHECK(IGNORE_EINTR(close(fds[0])) == 0); @@ -609,37 +606,69 @@ const char kLargeString[] = TEST_F(ProcessUtilTest, LaunchProcess) { base::EnvironmentMap env_changes; + std::vector<std::string> echo_base_test; + echo_base_test.push_back(kPosixShell); + echo_base_test.push_back("-c"); + echo_base_test.push_back("echo $BASE_TEST"); + + std::vector<std::string> print_env; + print_env.push_back("/usr/bin/env"); const int no_clone_flags = 0; + const bool no_clear_environ = false; const char kBaseTest[] = "BASE_TEST"; env_changes[kBaseTest] = "bar"; - EXPECT_EQ("bar\n", TestLaunchProcess(env_changes, no_clone_flags)); + EXPECT_EQ("bar\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); env_changes.clear(); EXPECT_EQ(0, setenv(kBaseTest, "testing", 1 /* override */)); - EXPECT_EQ("testing\n", TestLaunchProcess(env_changes, no_clone_flags)); + EXPECT_EQ("testing\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); env_changes[kBaseTest] = std::string(); - EXPECT_EQ("\n", TestLaunchProcess(env_changes, no_clone_flags)); + EXPECT_EQ("\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); env_changes[kBaseTest] = "foo"; - EXPECT_EQ("foo\n", TestLaunchProcess(env_changes, no_clone_flags)); + EXPECT_EQ("foo\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); env_changes.clear(); EXPECT_EQ(0, setenv(kBaseTest, kLargeString, 1 /* override */)); EXPECT_EQ(std::string(kLargeString) + "\n", - TestLaunchProcess(env_changes, no_clone_flags)); + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); env_changes[kBaseTest] = "wibble"; - EXPECT_EQ("wibble\n", TestLaunchProcess(env_changes, no_clone_flags)); + EXPECT_EQ("wibble\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, no_clone_flags)); #if defined(OS_LINUX) // Test a non-trival value for clone_flags. // Don't test on Valgrind as it has limited support for clone(). if (!RunningOnValgrind()) { - EXPECT_EQ("wibble\n", TestLaunchProcess(env_changes, CLONE_FS | SIGCHLD)); + EXPECT_EQ( + "wibble\n", + TestLaunchProcess( + echo_base_test, env_changes, no_clear_environ, CLONE_FS | SIGCHLD)); } + + EXPECT_EQ( + "BASE_TEST=wibble\n", + TestLaunchProcess( + print_env, env_changes, true /* clear_environ */, no_clone_flags)); + env_changes.clear(); + EXPECT_EQ( + "", + TestLaunchProcess( + print_env, env_changes, true /* clear_environ */, no_clone_flags)); #endif } @@ -677,7 +706,13 @@ TEST_F(ProcessUtilTest, GetAppOutput) { #endif // defined(OS_ANDROID) } -TEST_F(ProcessUtilTest, GetAppOutputRestricted) { +// Flakes on Android, crbug.com/375840 +#if defined(OS_ANDROID) +#define MAYBE_GetAppOutputRestricted DISABLED_GetAppOutputRestricted +#else +#define MAYBE_GetAppOutputRestricted GetAppOutputRestricted +#endif +TEST_F(ProcessUtilTest, MAYBE_GetAppOutputRestricted) { // Unfortunately, since we can't rely on the path, we need to know where // everything is. So let's use /bin/sh, which is on every POSIX system, and // its built-ins. @@ -812,8 +847,7 @@ bool IsProcessDead(base::ProcessHandle child) { } TEST_F(ProcessUtilTest, DelayedTermination) { - base::ProcessHandle child_process = - SpawnChild("process_util_test_never_die", false); + base::ProcessHandle child_process = SpawnChild("process_util_test_never_die"); ASSERT_TRUE(child_process); base::EnsureProcessTerminated(child_process); base::WaitForSingleProcess(child_process, base::TimeDelta::FromSeconds(5)); @@ -832,7 +866,7 @@ MULTIPROCESS_TEST_MAIN(process_util_test_never_die) { TEST_F(ProcessUtilTest, ImmediateTermination) { base::ProcessHandle child_process = - SpawnChild("process_util_test_die_immediately", false); + SpawnChild("process_util_test_die_immediately"); ASSERT_TRUE(child_process); // Give it time to die. sleep(2); |