• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Chromium OS Authors. All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3 
4 //! Windows specific code that keeps rest of the code in the crate platform independent.
5 
6 #[cfg(all(test, feature = "vmm"))]
7 pub(crate) mod tests {
8     use crate::connection::TubeEndpoint;
9     use crate::master::Master;
10     use crate::message::MasterReq;
11     use crate::slave_req_handler::SlaveReqHandler;
12     use crate::slave_req_handler::VhostUserSlaveReqHandler;
13     use crate::SystemStream;
14     pub(crate) type TestEndpoint = TubeEndpoint<MasterReq>;
15     pub(crate) type TestMaster = Master<TestEndpoint>;
16 
create_pair() -> (TestMaster, TestEndpoint)17     pub(crate) fn create_pair() -> (TestMaster, TestEndpoint) {
18         let (master_tube, slave_tube) = SystemStream::pair().unwrap();
19         let master = Master::from_stream(master_tube, 2);
20         (master, TubeEndpoint::from(slave_tube))
21     }
22 
23     #[cfg(feature = "device")]
create_master_slave_pair<S>( backend: S, ) -> (TestMaster, SlaveReqHandler<S, TestEndpoint>) where S: VhostUserSlaveReqHandler,24     pub(crate) fn create_master_slave_pair<S>(
25         backend: S,
26     ) -> (TestMaster, SlaveReqHandler<S, TestEndpoint>)
27     where
28         S: VhostUserSlaveReqHandler,
29     {
30         let (master_tube, slave_tube) = SystemStream::pair().unwrap();
31         let master = Master::from_stream(master_tube, 2);
32         (
33             master,
34             SlaveReqHandler::<S, TubeEndpoint<MasterReq>>::from_stream(slave_tube, backend),
35         )
36     }
37 }
38