src/sys/appmgr/integration_tests/sandbox/services/multiple_components.cc
// This test runs multiple components in the same environment, and checks that
// their service sandboxes are isolated.
This test runs multiple components in the same environment, and checks that
their service sandboxes are isolated.
This test runs multiple components in the same environment and checks that their service sandboxes are isolated .
TEST_F(NamespaceTest, MultipleComponents) {
  static const std::vector<const char*> kTests = {
      "fuchsia-pkg://fuchsia.com/some_services#meta/some_services.cmx",
      "fuchsia-pkg://fuchsia.com/no_services#meta/no_services.cmx"};
  int num_running = kTests.size();
  std::vector<fuchsia::sys::ComponentControllerPtr> controllers;
  for (const char* test_url : kTests) {
    fuchsia::sys::LaunchInfo launch_info;
    launch_info.url = test_url;
    fuchsia::sys::ComponentControllerPtr controller;
    CreateComponentInCurrentEnvironment(std::move(launch_info), controller.NewRequest());
    controller.events().OnTerminated = [test_url, &num_running](
                                           int64_t return_code,
                                           fuchsia::sys::TerminationReason termination_reason) {
      EXPECT_EQ(return_code, 0) << test_url << " exited with non-ok status";
      EXPECT_EQ(termination_reason, fuchsia::sys::TerminationReason::EXITED)
          << test_url << " exited unexpectedly";
      --num_running;
    };
    controllers.push_back(std::move(controller));
  }
  RunLoopUntil([&num_running] { return num_running == 0; });
  EXPECT_EQ(num_running, 0);
}
TEST_F ( NamespaceTest , MultipleComponents ) { static const std :: vector < const char * > kTests = { " " , " " } ; int num_running = kTests . size ( ) ; std :: vector < fuchsia :: sys :: ComponentControllerPtr > controllers ; for ( const char * test_url : kTests ) { fuchsia :: sys :: LaunchInfo launch_info ; launch_info . url = test_url ; fuchsia :: sys :: ComponentControllerPtr controller ; CreateComponentInCurrentEnvironment ( std :: move ( launch_info ) , controller . NewRequest ( ) ) ; controller . events ( ) . OnTerminated = [ test_url , & num_running ] ( int64_t return_code , fuchsia :: sys :: TerminationReason termination_reason ) { EXPECT_EQ ( return_code , 0 ) << test_url << " " ; EXPECT_EQ ( termination_reason , fuchsia :: sys :: TerminationReason :: EXITED ) << test_url << " " ; -- num_running ; } ; controllers . push_back ( std :: move ( controller ) ) ; } RunLoopUntil ( [ & num_running ] { return num_running == 0 ; } ) ; EXPECT_EQ ( num_running , 0 ) ; }
This test runs multiple components in the same environment, and checks that
their service sandboxes are isolated.
This test runs multiple components in the same environment and checks that their service sandboxes are isolated .