2019-04-22 22:59:43 +00:00
|
|
|
// Copyright 2019 The Chromium OS Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2018-11-02 01:15:16 +00:00
|
|
|
use msg_socket::*;
|
2019-04-11 21:30:00 +00:00
|
|
|
use sys_util::EventFd;
|
2018-11-02 01:15:16 +00:00
|
|
|
|
|
|
|
#[derive(MsgOnSocket)]
|
|
|
|
struct Message(u8, u16, EventFd);
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn sock_send_recv_tuple() {
|
|
|
|
let (req, res) = pair::<Message, Message>().unwrap();
|
|
|
|
let e0 = EventFd::new().unwrap();
|
|
|
|
let e1 = e0.try_clone().unwrap();
|
|
|
|
req.send(&Message(1, 0x12, e0)).unwrap();
|
|
|
|
let r = res.recv().unwrap();
|
|
|
|
assert_eq!(r.0, 1);
|
|
|
|
assert_eq!(r.1, 0x12);
|
|
|
|
r.2.write(0x0f0f).unwrap();
|
|
|
|
assert_eq!(e1.read().unwrap(), 0x0f0f);
|
|
|
|
}
|