From 36902bab31c2028a73a2ca0a7cc1f8202fe34d7d Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 6 Feb 2020 10:43:55 +0000 Subject: [PATCH] rust/rpc: add partial data test --- rust/src/nfs/rpc_records.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rust/src/nfs/rpc_records.rs b/rust/src/nfs/rpc_records.rs index 446935a0ba..723c73e55d 100644 --- a/rust/src/nfs/rpc_records.rs +++ b/rust/src/nfs/rpc_records.rs @@ -359,3 +359,23 @@ named!(pub parse_rpc_udp_reply, } )) ); + +#[cfg(test)] +mod tests { + use crate::nfs::rpc_records::*; + use nom::Err::Incomplete; + use nom::Needed::Size; + + #[test] + fn test_parse_input_too_short() { + let buf: &[u8] = &[ + 0x80, 0x0, 0x0, 0x9c, 0x8e, 0x28, 0x2, 0x7e + ]; + let r = parse_rpc_request_partial(buf); + match r { + Err(Incomplete(e)) => { assert_eq!(e, Size(4)); }, + _ => { panic!("failed {:?}",r); } + } + } +} + -- 2.47.2