zircon/kernel/object/root_job_observer_tests.cc
// Ensure that the callback fires when the root job is killed.
Ensure that the callback fires when the root job is killed.
Ensure that the callback fires when the root job is killed .
bool TestCallbackFiresOnRootJobDeath() {
  BEGIN_TEST;
  Event root_job_killed;
  fbl::RefPtr<JobDispatcher> root_job = JobDispatcher::CreateRootJob();
  KernelHandle<ProcessDispatcher> child_process = CreateProcess(root_job);
  RootJobObserver observer{root_job, nullptr, [&root_job_killed]() { root_job_killed.Signal(); }};
  EXPECT_EQ(root_job_killed.Wait(DeadlineAfter(ZX_MSEC(1))), ZX_ERR_TIMED_OUT);
  ASSERT_TRUE(root_job->Kill(1));
  EXPECT_EQ(root_job_killed.Wait(), ZX_OK);
  END_TEST;
}
bool TestCallbackFiresOnRootJobDeath ( ) { BEGIN_TEST ; Event root_job_killed ; fbl :: RefPtr < JobDispatcher > root_job = JobDispatcher :: CreateRootJob ( ) ; KernelHandle < ProcessDispatcher > child_process = CreateProcess ( root_job ) ; RootJobObserver observer { root_job , nullptr , [ & root_job_killed ] ( ) { root_job_killed . Signal ( ) ; } } ; EXPECT_EQ ( root_job_killed . Wait ( DeadlineAfter ( ZX_MSEC ( 1 ) ) ) , ZX_ERR_TIMED_OUT ) ; ASSERT_TRUE ( root_job -> Kill ( 1 ) ) ; EXPECT_EQ ( root_job_killed . Wait ( ) , ZX_OK ) ; END_TEST ; }
Ensure that the callback fires when the root job is killed.
Ensure that the callback fires when the root job is killed .
// Create the root job with a child process, and start watching it. // Shouldn't be signalled yet. // Kill the root job. // Ensure we are signalled.