pub struct TestRealm<'a> { /* private fields */ }
Expand description
A realm within a netemul sandbox.
Implementations§
source§impl<'a> TestRealm<'a>
impl<'a> TestRealm<'a>
sourcepub fn connect_to_protocol<S>(&self) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
pub fn connect_to_protocol<S>(&self) -> Result<S::Proxy, Error>where
S: DiscoverableProtocolMarker,
Connects to a protocol within the realm.
sourcepub fn open_diagnostics_directory(
&self,
child_name: &str
) -> Result<DirectoryProxy, Error>
pub fn open_diagnostics_directory( &self, child_name: &str ) -> Result<DirectoryProxy, Error>
Opens the diagnostics directory of a component.
sourcepub fn connect_to_protocol_with_server_end<S: DiscoverableProtocolMarker>(
&self,
server_end: ServerEnd<S>
) -> Result<(), Error>
pub fn connect_to_protocol_with_server_end<S: DiscoverableProtocolMarker>( &self, server_end: ServerEnd<S> ) -> Result<(), Error>
Connects to a protocol within the realm.
sourcepub async fn get_moniker(&self) -> Result<String, Error>
pub async fn get_moniker(&self) -> Result<String, Error>
Gets the moniker of the root of the managed realm.
sourcepub async fn start_child_component(&self, child_name: &str) -> Result<(), Error>
pub async fn start_child_component(&self, child_name: &str) -> Result<(), Error>
Starts the specified child component of the managed realm.
sourcepub async fn stop_child_component(&self, child_name: &str) -> Result<(), Error>
pub async fn stop_child_component(&self, child_name: &str) -> Result<(), Error>
Stops the specified child component of the managed realm.
sourcepub async fn join_network<S>(
&self,
network: &TestNetwork<'a>,
ep_name: S
) -> Result<TestInterface<'a>, Error>
pub async fn join_network<S>( &self, network: &TestNetwork<'a>, ep_name: S ) -> Result<TestInterface<'a>, Error>
Use default endpoint/interface configuration and the specified address configuration to create a test interface.
Characters may be dropped from the front of ep_name
if it exceeds the
maximum length.
sourcepub async fn join_network_with_if_config<S>(
&self,
network: &TestNetwork<'a>,
ep_name: S,
if_config: InterfaceConfig<'a>
) -> Result<TestInterface<'a>, Error>
pub async fn join_network_with_if_config<S>( &self, network: &TestNetwork<'a>, ep_name: S, if_config: InterfaceConfig<'a> ) -> Result<TestInterface<'a>, Error>
Use default endpoint configuration and the specified interface/address configuration to create a test interface.
Characters may be dropped from the front of ep_name
if it exceeds the
maximum length.
sourcepub async fn join_network_with(
&self,
network: &TestNetwork<'a>,
ep_name: impl Into<Cow<'a, str>>,
ep_config: EndpointConfig,
if_config: InterfaceConfig<'a>
) -> Result<TestInterface<'a>, Error>
pub async fn join_network_with( &self, network: &TestNetwork<'a>, ep_name: impl Into<Cow<'a, str>>, ep_config: EndpointConfig, if_config: InterfaceConfig<'a> ) -> Result<TestInterface<'a>, Error>
Joins network
with by creating an endpoint with ep_config
and
installing it into the realm with if_config
.
Returns a TestInterface
corresponding to the added interface. The
interface is guaranteed to have its link up and be enabled when this
async function resolves.
Note that this realm needs a Netstack for this operation to succeed.
Characters may be dropped from the front of ep_name
if it exceeds the maximum length.
sourcepub async fn install_endpoint(
&self,
endpoint: TestEndpoint<'a>,
if_config: InterfaceConfig<'a>
) -> Result<TestInterface<'a>, Error>
pub async fn install_endpoint( &self, endpoint: TestEndpoint<'a>, if_config: InterfaceConfig<'a> ) -> Result<TestInterface<'a>, Error>
Installs and configures the endpoint in this realm.
Note that if name
is not None
, the string must fit within interface name limits.
sourcepub async fn add_raw_device(
&self,
path: &Path,
device: ClientEnd<DeviceProxy_Marker>
) -> Result<(), Error>
pub async fn add_raw_device( &self, path: &Path, device: ClientEnd<DeviceProxy_Marker> ) -> Result<(), Error>
Adds a raw device connector to the realm’s devfs.
sourcepub async fn add_virtual_device(
&self,
e: &TestEndpoint<'_>,
path: &Path
) -> Result<(), Error>
pub async fn add_virtual_device( &self, e: &TestEndpoint<'_>, path: &Path ) -> Result<(), Error>
Adds a device to the realm’s virtual device filesystem.
sourcepub async fn remove_virtual_device(&self, path: &Path) -> Result<(), Error>
pub async fn remove_virtual_device(&self, path: &Path) -> Result<(), Error>
Removes a device from the realm’s virtual device filesystem.
sourcepub async fn datagram_socket(
&self,
domain: Domain,
proto: DatagramSocketProtocol
) -> Result<Socket, Error>
pub async fn datagram_socket( &self, domain: Domain, proto: DatagramSocketProtocol ) -> Result<Socket, Error>
Creates a Datagram [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket/Provider
in this realm.
sourcepub async fn raw_socket(
&self,
domain: Domain,
association: ProtocolAssociation
) -> Result<Socket, Error>
pub async fn raw_socket( &self, domain: Domain, association: ProtocolAssociation ) -> Result<Socket, Error>
Creates a raw [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket.raw/Provider
in this realm.
sourcepub async fn packet_socket(&self, kind: Kind) -> Result<Socket, Error>
pub async fn packet_socket(&self, kind: Kind) -> Result<Socket, Error>
Creates a [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket.packet/Provider
in this realm.
sourcepub async fn stream_socket(
&self,
domain: Domain,
proto: StreamSocketProtocol
) -> Result<Socket, Error>
pub async fn stream_socket( &self, domain: Domain, proto: StreamSocketProtocol ) -> Result<Socket, Error>
Creates a Stream [socket2::Socket
] backed by the implementation of
fuchsia.posix.socket/Provider
in this realm.
sourcepub async fn shutdown(&self) -> Result<(), Error>
pub async fn shutdown(&self) -> Result<(), Error>
Shuts down the realm.
It is often useful to call this method to ensure that the realm
completes orderly shutdown before allowing other resources to be dropped
and get cleaned up, such as TestEndpoint
s, which components in the
realm might be interacting with.
sourcepub async fn icmp_socket<Ip: FuchsiaIpExt>(
&self
) -> Result<DatagramSocket, Error>
pub async fn icmp_socket<Ip: FuchsiaIpExt>( &self ) -> Result<DatagramSocket, Error>
Constructs an ICMP socket.
sourcepub async fn ping_once<Ip: FuchsiaIpExt>(
&self,
addr: Ip::SockAddr,
seq: u16
) -> Result<(), Error>
pub async fn ping_once<Ip: FuchsiaIpExt>( &self, addr: Ip::SockAddr, seq: u16 ) -> Result<(), Error>
Sends a single ICMP echo request to addr
, and waits for the echo reply.
sourcepub async fn ping<Ip: FuchsiaIpExt>(
&self,
addr: Ip::SockAddr
) -> Result<(), Error>
pub async fn ping<Ip: FuchsiaIpExt>( &self, addr: Ip::SockAddr ) -> Result<(), Error>
Sends ICMP echo requests to addr
on a 1-second interval until a response
is received.
sourcepub async fn add_neighbor_entry(
&self,
interface: u64,
addr: IpAddress,
mac: MacAddress
) -> Result<(), Error>
pub async fn add_neighbor_entry( &self, interface: u64, addr: IpAddress, mac: MacAddress ) -> Result<(), Error>
Add a static neighbor entry.
Useful to prevent NUD resolving too slow and causing spurious test failures.