From 687407741be82c69af25183a363129a215b38959 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Thu, 23 May 2019 12:14:22 +0200 Subject: [PATCH] src/tools/xattr.rs: add test for is_valid_xattr_name() Signed-off-by: Christian Ebner --- src/tools/xattr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/xattr.rs b/src/tools/xattr.rs index caa49312..e76eaace 100644 --- a/src/tools/xattr.rs +++ b/src/tools/xattr.rs @@ -172,4 +172,17 @@ mod tests { std::fs::remove_file(&path).unwrap(); } + + #[test] + fn test_is_valid_xattr_name() { + let empty = Vec::new(); + let too_long = vec![b'a'; 265]; + + assert!(!is_valid_xattr_name(empty.as_slice())); + assert!(!is_valid_xattr_name(too_long.as_slice())); + assert!(!is_valid_xattr_name(b"system.attr")); + assert!(is_valid_xattr_name(b"user.attr")); + assert!(is_valid_xattr_name(b"trusted.attr")); + assert!(is_valid_xattr_name(b"security.capability")); + } }