crosvm/msg_socket/tests/struct.rs
Paul Kirth 6e1260face Revert "msg_socket: Fixed bug with all skipped fields in struct"
This reverts commit ca3817bda3.

Reverting prevents these errors when starting the vm:

[ERROR:src/linux.rs:2324] failed to recv VmMemoryControlRequest:
msg buffer size too small
[ERROR:src/linux.rs:2324] failed to recv VmMemoryControlRequest:
msg buffer size too small
[ERROR:src/linux.rs:2350] failed to recv VmIrqRequest:
msg buffer size too small

BUG=b:162032986
TEST=manual

Change-Id: I22a31fa36274d3b6dd4ebc7431ab9ac3878b735b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2380301
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-09-02 23:20:22 +00:00

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);
}