async fn create_isolated_devmgr() -> Result<IsolatedDevMgrTest, Error> {
        const ISOLATED_DEVMGR_MONIKER: &'static str = "isolated-devmgr";
        const ISOLATED_DEVMGR_URL: &'static str = "#meta/isolated-devmgr.cm";
        let mut realm = RealmBuilder::new().await.unwrap();
        let _ = realm
            .add_component(ISOLATED_DEVMGR_MONIKER, ComponentSource::url(ISOLATED_DEVMGR_URL))
            .await
            .unwrap();
        let _ = realm
            .add_route(CapabilityRoute {
                capability: Capability::directory("dev", "/dev", fio2::RW_STAR_DIR),
                source: RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER),
                targets: vec![RouteEndpoint::AboveRoot],
            })
            .expect("failed to add route")
            .add_protocol_route::<fidl_fuchsia_logger::LogSinkMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add LogSink route")
            .add_protocol_route::<fidl_fuchsia_process::LauncherMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add Launcher route")
            .add_protocol_route::<fidl_fuchsia_sys::LauncherMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add Loader route");
        let realm = realm.build().create().await.expect("failed to build realm");
        let dev_dir = io_util::directory::open_directory(
            realm.root.get_exposed_dir(),
            "dev",
            fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_WRITABLE,
        )
        .await?;
        // Block until the test control device is ready.
        let _control_dev_node =
            device_watcher::recursive_wait_and_open_node(&dev_dir, CONTROL_DEVICE_RELATIVE).await?;
        // One might think that it would be safe to just directly convert the control_dev_node to
        // a DirectoryProxy and return that. However, DeviceWatchers created from the converted
        // NodeProxy don't work - likely because we also open a channel to the control device as a
        // RootDeviceProxy later in the test.
        let control_dev_dir = io_util::directory::open_directory(
            &dev_dir,
            CONTROL_DEVICE_RELATIVE,
            fio::OPEN_RIGHT_READABLE,
        )
        .await?;
        Ok(IsolatedDevMgrTest { _realm: realm, dev_dir, control_dev_dir })
    }
/// On success, returns the RealmInstance containing an IsolatedDevMgr, alongside the DevMgrs's
/// `/dev` dir and the test control device directory. The RealmInstance must not be dropped
/// while the DevMgr is in use.
On success, returns the RealmInstance containing an IsolatedDevMgr, alongside the DevMgrs's
`/dev` dir and the test control device directory. The RealmInstance must not be dropped
while the DevMgr is in use.
On success returns the RealmInstance containing an IsolatedDevMgr alongside the DevMgrs ' s ` / dev ` dir and the test control device directory . The RealmInstance must not be dropped while the DevMgr is in use .
async fn create_isolated_devmgr() -> Result<IsolatedDevMgrTest, Error> {
        const ISOLATED_DEVMGR_MONIKER: &'static str = "isolated-devmgr";
        const ISOLATED_DEVMGR_URL: &'static str = "#meta/isolated-devmgr.cm";
        let mut realm = RealmBuilder::new().await.unwrap();
        let _ = realm
            .add_component(ISOLATED_DEVMGR_MONIKER, ComponentSource::url(ISOLATED_DEVMGR_URL))
            .await
            .unwrap();
        let _ = realm
            .add_route(CapabilityRoute {
                capability: Capability::directory("dev", "/dev", fio2::RW_STAR_DIR),
                source: RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER),
                targets: vec![RouteEndpoint::AboveRoot],
            })
            .expect("failed to add route")
            .add_protocol_route::<fidl_fuchsia_logger::LogSinkMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add LogSink route")
            .add_protocol_route::<fidl_fuchsia_process::LauncherMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add Launcher route")
            .add_protocol_route::<fidl_fuchsia_sys::LauncherMarker>(
                RouteEndpoint::AboveRoot,
                vec![RouteEndpoint::component(ISOLATED_DEVMGR_MONIKER)],
            )
            .expect("failed to add Loader route");
        let realm = realm.build().create().await.expect("failed to build realm");
        let dev_dir = io_util::directory::open_directory(
            realm.root.get_exposed_dir(),
            "dev",
            fio::OPEN_RIGHT_READABLE | fio::OPEN_RIGHT_WRITABLE,
        )
        .await?;
        // Block until the test control device is ready.
        let _control_dev_node =
            device_watcher::recursive_wait_and_open_node(&dev_dir, CONTROL_DEVICE_RELATIVE).await?;
        // One might think that it would be safe to just directly convert the control_dev_node to
        // a DirectoryProxy and return that. However, DeviceWatchers created from the converted
        // NodeProxy don't work - likely because we also open a channel to the control device as a
        // RootDeviceProxy later in the test.
        let control_dev_dir = io_util::directory::open_directory(
            &dev_dir,
            CONTROL_DEVICE_RELATIVE,
            fio::OPEN_RIGHT_READABLE,
        )
        .await?;
        Ok(IsolatedDevMgrTest { _realm: realm, dev_dir, control_dev_dir })
    }
async fn create_isolated_devmgr ( ) -> Result < IsolatedDevMgrTest , Error > { const ISOLATED_DEVMGR_MONIKER : & ' static str = " " ; const ISOLATED_DEVMGR_URL : & ' static str = " " ; let mut realm = RealmBuilder :: new ( ) . await . unwrap ( ) ; let _ = realm . add_component ( ISOLATED_DEVMGR_MONIKER , ComponentSource :: url ( ISOLATED_DEVMGR_URL ) ) . await . unwrap ( ) ; let _ = realm . add_route ( CapabilityRoute { capability : Capability :: directory ( " " , " " , fio2 :: RW_STAR_DIR ) , source : RouteEndpoint :: component ( ISOLATED_DEVMGR_MONIKER ) , targets : vec ! [ RouteEndpoint AboveRoot ] , } ) . expect ( " " ) . add_protocol_route :: < fidl_fuchsia_logger :: LogSinkMarker > ( RouteEndpoint :: AboveRoot , vec ! [ RouteEndpoint component ( ISOLATED_DEVMGR_MONIKER ) ] , ) . expect ( " " ) . add_protocol_route :: < fidl_fuchsia_process :: LauncherMarker > ( RouteEndpoint :: AboveRoot , vec ! [ RouteEndpoint component ( ISOLATED_DEVMGR_MONIKER ) ] , ) . expect ( " " ) . add_protocol_route :: < fidl_fuchsia_sys :: LauncherMarker > ( RouteEndpoint :: AboveRoot , vec ! [ RouteEndpoint component ( ISOLATED_DEVMGR_MONIKER ) ] , ) . expect ( " " ) ; let realm = realm . build ( ) . create ( ) . await . expect ( " " ) ; let dev_dir = io_util :: directory :: open_directory ( realm . root . get_exposed_dir ( ) , " " , fio :: OPEN_RIGHT_READABLE | fio :: OPEN_RIGHT_WRITABLE , ) . await ? ; // Block until the test control device is ready. let _control_dev_node = device_watcher :: recursive_wait_and_open_node ( & dev_dir , CONTROL_DEVICE_RELATIVE ) . await ? ; // One might think that it would be safe to just directly convert the control_dev_node to // a DirectoryProxy and return that. However, DeviceWatchers created from the converted // NodeProxy don't work - likely because we also open a channel to the control device as a // RootDeviceProxy later in the test. let control_dev_dir = io_util :: directory :: open_directory ( & dev_dir , CONTROL_DEVICE_RELATIVE , fio :: OPEN_RIGHT_READABLE , ) . await ? ; Ok ( IsolatedDevMgrTest { _realm : realm , dev_dir , control_dev_dir } ) }
On success, returns the RealmInstance containing an IsolatedDevMgr, alongside the DevMgrs's
`/dev` dir and the test control device directory.
On success returns the RealmInstance containing an IsolatedDevMgr alongside the DevMgrs ' s ` / dev ` dir and the test control device directory .