src/tools/xattr.rs: add test for is_valid_xattr_name()

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-05-23 12:14:22 +02:00 committed by Dietmar Maurer
parent 357e4614e2
commit 687407741b

View File

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