Skip to content

Commit

Permalink
lsm: Add tests for xattrs_have_selinux
Browse files Browse the repository at this point in the history
Prep for a refactoring.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Oct 15, 2024
1 parent 1212f32 commit 2d0512c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/src/lsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,19 @@ where
f(w)
})
}

#[cfg(test)]
mod tests {
use super::*;
use gio::glib::Variant;

#[test]
fn test_selinux_xattr() {
let notfound: &[&[(&[u8], &[u8])]] = &[&[], &[(b"foo", b"bar")]];
for case in notfound {
assert!(!xattrs_have_selinux(&Variant::from(case)));
}
let found: &[(&[u8], &[u8])] = &[(b"foo", b"bar"), (SELINUX_XATTR, b"foo_t")];
assert!(xattrs_have_selinux(&Variant::from(found)));
}
}

0 comments on commit 2d0512c

Please sign in to comment.