Skip to content

Commit 2d0512c

Browse files
committed
lsm: Add tests for xattrs_have_selinux
Prep for a refactoring. Signed-off-by: Colin Walters <[email protected]>
1 parent 1212f32 commit 2d0512c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/src/lsm.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,19 @@ where
419419
f(w)
420420
})
421421
}
422+
423+
#[cfg(test)]
424+
mod tests {
425+
use super::*;
426+
use gio::glib::Variant;
427+
428+
#[test]
429+
fn test_selinux_xattr() {
430+
let notfound: &[&[(&[u8], &[u8])]] = &[&[], &[(b"foo", b"bar")]];
431+
for case in notfound {
432+
assert!(!xattrs_have_selinux(&Variant::from(case)));
433+
}
434+
let found: &[(&[u8], &[u8])] = &[(b"foo", b"bar"), (SELINUX_XATTR, b"foo_t")];
435+
assert!(xattrs_have_selinux(&Variant::from(found)));
436+
}
437+
}

0 commit comments

Comments
 (0)