mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 10:32:10 +00:00
6b19695c81
For now, this crate simply re-exports all of sys_util, but it will be updated to provide new interfaces when needed. This is the first step to making crosvm not directly depend on sys_util, so that we can make the interface changes we need without fear of negatively affecting (i.e. completely breaking) other usages within chromeos. BUG=b:162363783 TEST=./build_test Change-Id: I7d0aa3d8a1f66af1c7fee8fd649723ef17027150 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2325168 Tested-by: Michael Hoyle <mikehoyle@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Michael Hoyle <mikehoyle@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
38 lines
891 B
Rust
38 lines
891 B
Rust
// 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.
|
|
|
|
use base::EventFd;
|
|
|
|
use msg_socket::*;
|
|
|
|
#[derive(MsgOnSocket)]
|
|
struct Request {
|
|
field0: u8,
|
|
field1: EventFd,
|
|
field2: u32,
|
|
field3: bool,
|
|
}
|
|
|
|
#[derive(MsgOnSocket)]
|
|
struct DummyResponse {}
|
|
|
|
#[test]
|
|
fn sock_send_recv_struct() {
|
|
let (req, res) = pair::<Request, DummyResponse>().unwrap();
|
|
let e0 = EventFd::new().unwrap();
|
|
let e1 = e0.try_clone().unwrap();
|
|
req.send(&Request {
|
|
field0: 2,
|
|
field1: e0,
|
|
field2: 0xf0f0,
|
|
field3: true,
|
|
})
|
|
.unwrap();
|
|
let r = res.recv().unwrap();
|
|
assert_eq!(r.field0, 2);
|
|
assert_eq!(r.field2, 0xf0f0);
|
|
assert_eq!(r.field3, true);
|
|
r.field1.write(0x0f0f).unwrap();
|
|
assert_eq!(e1.read().unwrap(), 0x0f0f);
|
|
}
|