src/bringup/bin/bootsvc/integration_test/integration-test.cc
// Make sure that bootsvc gave us a namespace with only /boot and /svc.
Make sure that bootsvc gave us a namespace with only /boot and /svc.
Make sure that bootsvc gave us a namespace with only / boot and / svc .
TEST(BootsvcIntegrationTest, Namespace) {
  fdio_flat_namespace_t* ns;
  ASSERT_EQ(fdio_ns_export_root(&ns), ZX_OK);
  for (size_t i = 0; i < ns->count; ++i) {
    zx_handle_close(ns->handle[i]);
  }
  ASSERT_EQ(ns->count, 2);
  EXPECT_STR_EQ(ns->path[0], "/boot");
  EXPECT_STR_EQ(ns->path[1], "/svc");
  free(ns);
  fbl::unique_fd fd;
  EXPECT_EQ(ZX_OK, fdio_open_fd(
                       "/boot",
                       fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_EXECUTABLE | fio::OPEN_FLAG_POSIX,
                       fd.reset_and_get_address()));
  EXPECT_EQ(fd_get_flags(std::move(fd)), fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_EXECUTABLE);
  EXPECT_EQ(ZX_OK,
            fdio_open_fd("/svc",
                         fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_WRITABLE | fio::OPEN_FLAG_POSIX,
                         fd.reset_and_get_address()));
  EXPECT_EQ(fd_get_flags(std::move(fd)), fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_WRITABLE);
}
TEST ( BootsvcIntegrationTest , Namespace ) { fdio_flat_namespace_t * ns ; ASSERT_EQ ( fdio_ns_export_root ( & ns ) , ZX_OK ) ; for ( size_t i = 0 ; i < ns -> count ; ++ i ) { zx_handle_close ( ns -> handle [ i ] ) ; } ASSERT_EQ ( ns -> count , 2 ) ; EXPECT_STR_EQ ( ns -> path [ 0 ] , " " ) ; EXPECT_STR_EQ ( ns -> path [ 1 ] , " " ) ; free ( ns ) ; fbl :: unique_fd fd ; EXPECT_EQ ( ZX_OK , fdio_open_fd ( " " , fio :: OPEN_RIGHT_READABLE | fio :: OPEN_RIGHT_EXECUTABLE | fio :: OPEN_FLAG_POSIX , fd . reset_and_get_address ( ) ) ) ; EXPECT_EQ ( fd_get_flags ( std :: move ( fd ) ) , fio :: OPEN_RIGHT_READABLE | fio :: OPEN_RIGHT_EXECUTABLE ) ; EXPECT_EQ ( ZX_OK , fdio_open_fd ( " " , fio :: OPEN_RIGHT_READABLE | fio :: OPEN_RIGHT_WRITABLE | fio :: OPEN_FLAG_POSIX , fd . reset_and_get_address ( ) ) ) ; EXPECT_EQ ( fd_get_flags ( std :: move ( fd ) ) , fio :: OPEN_RIGHT_READABLE | fio :: OPEN_RIGHT_WRITABLE ) ; }
Make sure that bootsvc gave us a namespace with only /boot and /svc.
Make sure that bootsvc gave us a namespace with only / boot and / svc .
// Close the cloned handles, since we don't need them // /boot should be RX and /svc should be RW. We use OPEN_FLAG_POSIX + fuchsia.io.Node.NodeGetFlags // to check that these are also the maximum rights supported.