summary refs log tree commit diff
path: root/msg_socket/src/lib.rs
diff options
context:
space:
mode:
authorZach Reizner <zachr@google.com>2018-11-01 18:15:16 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-11-07 06:35:06 -0800
commit3c71bb953e64a1f9f7e77a8564eecc15675dacbc (patch)
treecea9e3f99c5d3f5018ba33b97c1594b32369aead /msg_socket/src/lib.rs
parent60f55da93784b55cfb97c98725268e87665cc56e (diff)
downloadcrosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar.gz
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar.bz2
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar.lz
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar.xz
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.tar.zst
crosvm-3c71bb953e64a1f9f7e77a8564eecc15675dacbc.zip
msg_socket_on_derive: use fully qualified types
The types from msg_socket were assumed to be in scope for the custom
derive implementation, which would cause mysterious compiler errors if
the custom derive was invoked in a module without msg_socket types in
scope.

This CL uses fully qualified types in the generated output to avoid
these errors.

This change also uses `extern crate msg_socket` in case the call site
doesn't have it in scope.

BUG=None
TEST=cargo test -p msg_on_socket_derive

Change-Id: Ie6443cd4ffc070d27e71de123090a58f19846472
Reviewed-on: https://chromium-review.googlesource.com/1314208
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
Diffstat (limited to 'msg_socket/src/lib.rs')
-rw-r--r--msg_socket/src/lib.rs103
1 files changed, 0 insertions, 103 deletions
diff --git a/msg_socket/src/lib.rs b/msg_socket/src/lib.rs
index c4d60df..e1a1b48 100644
--- a/msg_socket/src/lib.rs
+++ b/msg_socket/src/lib.rs
@@ -199,106 +199,3 @@ impl<I: MsgOnSocket, O: MsgOnSocket> MsgReceiver<O> for UnlinkMsgSocket<I, O> {}
 
 impl<M: MsgOnSocket> MsgSender<M> for Sender<M> {}
 impl<M: MsgOnSocket> MsgReceiver<M> for Receiver<M> {}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use sys_util::EventFd;
-
-    #[derive(MsgOnSocket)]
-    struct Request {
-        field0: u8,
-        field1: EventFd,
-        field2: u32,
-    }
-
-    #[derive(MsgOnSocket)]
-    enum Response {
-        A(u8),
-        B,
-        C(u32, EventFd),
-        D([u8; 4]),
-        E { f0: u8, f1: u32 },
-    }
-
-    #[derive(MsgOnSocket)]
-    struct Message(u8, u16, EventFd);
-
-    #[test]
-    fn sock_send_recv_struct() {
-        let (req, res) = pair::<Request, Response>().unwrap();
-        let e0 = EventFd::new().unwrap();
-        let e1 = e0.try_clone().unwrap();
-        req.send(&Request {
-            field0: 2,
-            field1: e0,
-            field2: 0xf0f0,
-        }).unwrap();
-        let r = res.recv().unwrap();
-        assert_eq!(r.field0, 2);
-        assert_eq!(r.field2, 0xf0f0);
-        r.field1.write(0x0f0f).unwrap();
-        assert_eq!(e1.read().unwrap(), 0x0f0f);
-    }
-
-    #[test]
-    fn sock_send_recv_enum() {
-        let (req, res) = pair::<Request, Response>().unwrap();
-        let e0 = EventFd::new().unwrap();
-        let e1 = e0.try_clone().unwrap();
-        res.send(&Response::C(0xf0f0, e0)).unwrap();
-        let r = req.recv().unwrap();
-        match r {
-            Response::C(v, efd) => {
-                assert_eq!(v, 0xf0f0);
-                efd.write(0x0f0f).unwrap();
-            }
-            _ => panic!("wrong type"),
-        };
-        assert_eq!(e1.read().unwrap(), 0x0f0f);
-
-        res.send(&Response::B).unwrap();
-        match req.recv().unwrap() {
-            Response::B => {}
-            _ => panic!("Wrong enum type"),
-        };
-
-        res.send(&Response::A(0x3)).unwrap();
-        match req.recv().unwrap() {
-            Response::A(v) => assert_eq!(v, 0x3),
-            _ => panic!("Wrong enum type"),
-        };
-
-        res.send(&Response::D([0, 1, 2, 3])).unwrap();
-        match req.recv().unwrap() {
-            Response::D(v) => assert_eq!(v, [0, 1, 2, 3]),
-            _ => panic!("Wrong enum type"),
-        };
-
-        res.send(&Response::E {
-            f0: 0x12,
-            f1: 0x0f0f,
-        }).unwrap();
-        match req.recv().unwrap() {
-            Response::E { f0, f1 } => {
-                assert_eq!(f0, 0x12);
-                assert_eq!(f1, 0x0f0f);
-            }
-            _ => panic!("Wrong enum type"),
-        };
-    }
-
-    #[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);
-    }
-
-}