• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 use msg_socket::*;
6 use sys_util::EventFd;
7 
8 #[derive(MsgOnSocket)]
9 struct Message(u8, u16, EventFd);
10 
11 #[test]
sock_send_recv_tuple()12 fn sock_send_recv_tuple() {
13     let (req, res) = pair::<Message, Message>().unwrap();
14     let e0 = EventFd::new().unwrap();
15     let e1 = e0.try_clone().unwrap();
16     req.send(&Message(1, 0x12, e0)).unwrap();
17     let r = res.recv().unwrap();
18     assert_eq!(r.0, 1);
19     assert_eq!(r.1, 0x12);
20     r.2.write(0x0f0f).unwrap();
21     assert_eq!(e1.read().unwrap(), 0x0f0f);
22 }
23