• Home
  • Raw
  • Download

Lines Matching full:process

5 #include "base/process/process.h"
13 #include "base/process/kill.h"
31 #include "base/process/internal_linux.h"
58 // Fake port provider that returns the calling process's
61 mach_port_t TaskForPid(base::ProcessHandle process) const override { in TaskForPid()
73 std::string GetProcessCpuCgroup(const base::Process& process) { in GetProcessCpuCgroup() argument
76 base::FilePath(base::StringPrintf(kProcPath, process.Pid())), in GetProcessCpuCgroup()
98 bool AddProcessToCpuCgroup(const base::Process& process, in AddProcessToCpuCgroup() argument
102 return base::WriteFile(path, base::NumberToString(process.Pid())); in AddProcessToCpuCgroup()
114 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
115 ASSERT_TRUE(process.IsValid()); in TEST_F()
116 ASSERT_FALSE(process.is_current()); in TEST_F()
117 EXPECT_NE(process.Pid(), kNullProcessId); in TEST_F()
118 process.Close(); in TEST_F()
119 ASSERT_FALSE(process.IsValid()); in TEST_F()
123 Process process = Process::Current(); in TEST_F() local
124 ASSERT_TRUE(process.IsValid()); in TEST_F()
125 ASSERT_TRUE(process.is_current()); in TEST_F()
126 EXPECT_NE(process.Pid(), kNullProcessId); in TEST_F()
127 process.Close(); in TEST_F()
128 ASSERT_FALSE(process.IsValid()); in TEST_F()
132 Process process1(SpawnChild("SimpleChildProcess")); in TEST_F()
135 Process process2; in TEST_F()
143 Process process3 = Process::Current(); in TEST_F()
151 Process process1(SpawnChild("SimpleChildProcess")); in TEST_F()
154 Process process2 = process1.Duplicate(); in TEST_F()
166 Process process1 = Process::Current(); in TEST_F()
169 Process process2 = process1.Duplicate(); in TEST_F()
188 // The current process creation time should be less than or equal to the in TEST_F()
190 EXPECT_FALSE(Process::Current().CreationTime().is_null()); in TEST_F()
191 EXPECT_LE(Process::Current().CreationTime(), Time::Now()); in TEST_F()
197 // The creation time of a process should be between a time recorded before it in TEST_F()
199 // base::Time and process creation clocks don't match, tolerate some error. in TEST_F()
202 // On Linux, process creation time is relative to boot time which has a in TEST_F()
207 // On Windows, process creation time is based on the system clock while in TEST_F()
212 // On Mac and Fuchsia, process creation time should be very precise. in TEST_F()
218 Process process(SpawnChild("SleepyChildProcess")); in TEST_F() local
220 const Time creation = process.CreationTime(); in TEST_F()
223 EXPECT_TRUE(process.Terminate(kDummyExitCode, true)); in TEST_F()
228 Process process(SpawnChild("SleepyChildProcess")); in TEST_F() local
229 ASSERT_TRUE(process.IsValid()); in TEST_F()
233 GetTerminationStatus(process.Handle(), &exit_code)); in TEST_F()
238 process.Terminate(kExpectedExitCode, false); in TEST_F()
239 process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), in TEST_F()
243 GetTerminationStatus(process.Handle(), &exit_code)); in TEST_F()
252 // Process::TerminateCurrentProcessImmediately. in AtExitHandler()
260 // Process::TerminateCurrentProcessImmediately. in ~ThreadLocalObject()
269 Process::TerminateCurrentProcessImmediately(0); in MULTIPROCESS_TEST_MAIN()
273 Process process(SpawnChild("TerminateCurrentProcessImmediatelyWithCode0")); in TEST_F() local
274 ASSERT_TRUE(process.IsValid()); in TEST_F()
276 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), in TEST_F()
282 Process::TerminateCurrentProcessImmediately(250); in MULTIPROCESS_TEST_MAIN()
286 Process process(SpawnChild("TerminateCurrentProcessImmediatelyWithCode250")); in TEST_F() local
287 ASSERT_TRUE(process.IsValid()); in TEST_F()
289 ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), in TEST_F()
300 Process process(SpawnChild("FastSleepyChildProcess")); in TEST_F() local
301 ASSERT_TRUE(process.IsValid()); in TEST_F()
304 EXPECT_TRUE(process.WaitForExit(&exit_code)); in TEST_F()
309 Process process(SpawnChild("SleepyChildProcess")); in TEST_F() local
310 ASSERT_TRUE(process.IsValid()); in TEST_F()
314 EXPECT_FALSE(process.WaitForExitWithTimeout(timeout, &exit_code)); in TEST_F()
317 process.Terminate(kDummyExitCode, false); in TEST_F()
322 Process process(SpawnChild("FastSleepyChildProcess")); in TEST_F() local
323 ASSERT_TRUE(process.IsValid()); in TEST_F()
329 EXPECT_EQ(process.WaitForExitOrEvent(stop_watching_handle, &exit_code), in TEST_F()
330 base::Process::WaitExitStatus::PROCESS_EXITED); in TEST_F()
335 Process process(SpawnChild("SleepyChildProcess")); in TEST_F() local
336 ASSERT_TRUE(process.IsValid()); in TEST_F()
342 EXPECT_EQ(process.WaitForExitOrEvent(stop_watching_handle, &exit_code), in TEST_F()
343 base::Process::WaitExitStatus::STOP_EVENT_SIGNALED); in TEST_F()
346 process.Terminate(kDummyExitCode, false); in TEST_F()
350 // Ensure that the priority of a process is restored correctly after
353 // a process. The calls to SetProcessPriority should be noops then.
355 if (!Process::CanSetPriority()) { in TEST_F()
358 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
359 int old_os_priority = process.GetOSPriority(); in TEST_F()
361 // On the Mac, backgrounding a process requires a port to that process. in TEST_F()
364 // spawning a process and receiving its port. Because this test just checks in TEST_F()
365 // the ability to background/foreground a process, we can use the current in TEST_F()
366 // process's port instead. in TEST_F()
368 EXPECT_TRUE(process.SetPriority(&provider, Process::Priority::kBestEffort)); in TEST_F()
369 EXPECT_EQ(process.GetPriority(&provider), Process::Priority::kBestEffort); in TEST_F()
370 EXPECT_TRUE(process.SetPriority(&provider, Process::Priority::kUserBlocking)); in TEST_F()
371 EXPECT_EQ(process.GetPriority(&provider), Process::Priority::kUserBlocking); in TEST_F()
374 EXPECT_TRUE(process.SetPriority(base::Process::Priority::kBestEffort)); in TEST_F()
375 EXPECT_EQ(process.GetPriority(), Process::Priority::kBestEffort); in TEST_F()
376 EXPECT_TRUE(process.SetPriority(base::Process::Priority::kUserBlocking)); in TEST_F()
377 EXPECT_EQ(process.GetPriority(), Process::Priority::kUserBlocking); in TEST_F()
379 int new_os_priority = process.GetOSPriority(); in TEST_F()
474 // Test creation of thread while process is backgrounded. in MULTIPROCESS_TEST_MAIN()
499 // ProcessThreadBackgrounding: A test to create a process and verify
500 // that the threads in the process are backgrounded correctly.
507 // Register signal handlers to be notified of events in child process. in TEST_F()
511 Process process(SpawnChild("ProcessThreadBackgroundingMain")); in TEST_F() local
512 EXPECT_TRUE(process.IsValid()); in TEST_F()
520 AssertCompositingThreadProperties(process.Pid(), false); in TEST_F()
522 EXPECT_TRUE(process.SetPriority(Process::Priority::kBestEffort)); in TEST_F()
524 // Send a signal to create a thread while the process is backgrounded. in TEST_F()
525 kill(process.Pid(), SIGUSR1); in TEST_F()
532 AssertCompositingThreadProperties(process.Pid(), true); in TEST_F()
534 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
535 EXPECT_TRUE(process.GetPriority() == base::Process::Priority::kUserBlocking); in TEST_F()
538 AssertCompositingThreadProperties(process.Pid(), false); in TEST_F()
560 // Verify that all the threads in a process are kRealtimeAudio
561 // and not backgrounded even though the process may be backgrounded.
591 // Test the property of kRealTimeAudio threads in a backgrounded process.
598 // Register signal handler to check if RT thread was created by child process. in TEST_F()
601 Process process(SpawnChild("ProcessRTThreadBackgroundingMain")); in TEST_F() local
602 EXPECT_TRUE(process.IsValid()); in TEST_F()
609 AssertRTAudioThreadProperties(process.Pid()); in TEST_F()
611 EXPECT_TRUE(process.SetPriority(Process::Priority::kBestEffort)); in TEST_F()
612 EXPECT_TRUE(process.GetPriority() == base::Process::Priority::kBestEffort); in TEST_F()
614 // Verify that nothing changed when process is kBestEffort in TEST_F()
615 AssertRTAudioThreadProperties(process.Pid()); in TEST_F()
617 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
618 EXPECT_TRUE(process.GetPriority() == base::Process::Priority::kUserBlocking); in TEST_F()
620 // Verify that nothing changed when process is kUserBlocking in TEST_F()
621 AssertRTAudioThreadProperties(process.Pid()); in TEST_F()
627 // whether the process is still running. This may not be safe because of the
628 // potential reusing of the process id. So we won't export Process::IsRunning()
632 EXPECT_FALSE(Process::Current().WaitForExitWithTimeout( in TEST_F()
637 // On Mac OSX, we can detect whether a non-child process is running.
639 // Process 1 is the /sbin/launchd, it should be always running. in TEST_F()
640 EXPECT_FALSE(Process::Open(1).WaitForExitWithTimeout( in TEST_F()
674 Process process(SpawnChild("SleepyChildProcess")); in TEST_F() local
675 EXPECT_FALSE(process.WaitForExitWithTimeout( in TEST_F()
677 process.Terminate(0, true); in TEST_F()
678 EXPECT_TRUE(process.WaitForExitWithTimeout( in TEST_F()
693 Process::Priority::kUserBlocking); in TEST_F()
695 Process::Priority::kBestEffort); in TEST_F()
699 // TODO(b/172213843): base::Process is used by base::TestSuite::Initialize in TEST_F()
702 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
705 Process process; in TEST_F() local
706 process.InitializePriority(); in TEST_F()
707 const std::string unique_token = process.unique_token(); in TEST_F()
712 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
717 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
718 process.InitializePriority(); in TEST_F()
719 const std::string unique_token = process.unique_token(); in TEST_F()
722 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
723 EXPECT_EQ(process.GetPriority(), Process::Priority::kUserBlocking); in TEST_F()
724 std::string cgroup = GetProcessCpuCgroup(process); in TEST_F()
728 EXPECT_TRUE(process.SetPriority(Process::Priority::kBestEffort)); in TEST_F()
729 EXPECT_EQ(process.GetPriority(), Process::Priority::kBestEffort); in TEST_F()
731 EXPECT_TRUE(process.Terminate(0, false)); in TEST_F()
740 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
745 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
746 process.InitializePriority(); in TEST_F()
747 const std::string unique_token = process.unique_token(); in TEST_F()
750 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
751 EXPECT_EQ(process.GetPriority(), Process::Priority::kUserBlocking); in TEST_F()
752 std::string cgroup = GetProcessCpuCgroup(process); in TEST_F()
756 // Add another process to the cgroup to ensure it stays busy. in TEST_F()
758 Process process2(SpawnChild("SimpleChildProcess")); in TEST_F()
761 // Terminate the first process that should tirgger a cleanup of the cgroup in TEST_F()
762 EXPECT_TRUE(process.Terminate(0, false)); in TEST_F()
768 // Move the second process to free the cgroup in TEST_F()
783 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
786 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
787 const std::string unique_token = process.unique_token(); in TEST_F()
791 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
792 EXPECT_EQ(process.GetPriority(), Process::Priority::kUserBlocking); in TEST_F()
793 std::string cgroup = GetProcessCpuCgroup(process); in TEST_F()
799 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
804 // Create a process that will not be cleaned up in TEST_F()
805 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
806 process.InitializePriority(); in TEST_F()
807 const std::string unique_token = process.unique_token(); in TEST_F()
810 EXPECT_TRUE(process.SetPriority(Process::Priority::kBestEffort)); in TEST_F()
811 EXPECT_EQ(process.GetPriority(), Process::Priority::kBestEffort); in TEST_F()
823 Process::CleanUpStaleProcessStates(); in TEST_F()
828 // validate the active process cgroup is not deleted in TEST_F()
835 // clean up the process in TEST_F()
836 EXPECT_TRUE(process.Terminate(0, false)); in TEST_F()
843 if (!Process::OneGroupPerRendererEnabledForTesting()) in TEST_F()
848 // Create a process that will not be cleaned up in TEST_F()
849 Process process(SpawnChild("SimpleChildProcess")); in TEST_F() local
850 process.InitializePriority(); in TEST_F()
851 const std::string unique_token = process.unique_token(); in TEST_F()
854 EXPECT_TRUE(process.SetPriority(Process::Priority::kUserBlocking)); in TEST_F()
855 EXPECT_EQ(process.GetPriority(), Process::Priority::kUserBlocking); in TEST_F()
856 std::string cgroup = GetProcessCpuCgroup(process); in TEST_F()
866 Process::CleanUpStaleProcessStates(); in TEST_F()
872 // clean up the process in TEST_F()
873 EXPECT_TRUE(process.SetPriority(Process::Priority::kBestEffort)); in TEST_F()
874 EXPECT_EQ(process.GetPriority(), Process::Priority::kBestEffort); in TEST_F()
875 EXPECT_TRUE(process.Terminate(0, false)); in TEST_F()