mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-28 19:54:35 +00:00
agent/rustjail: add unit tests for ms_move_rootfs and mask_path
Increase code coverage of mount.rs Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
d79fad2dd8
commit
b99fefad7e
@ -1031,4 +1031,37 @@ mod tests {
|
||||
let ret = pivot_rootfs("/tmp");
|
||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ms_move_rootfs() {
|
||||
let ret = ms_move_root("/abc");
|
||||
assert!(
|
||||
ret.is_err(),
|
||||
"Should fail. path doesn't exist. Got: {:?}",
|
||||
ret
|
||||
);
|
||||
|
||||
let ret = ms_move_root("/tmp");
|
||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mask_path() {
|
||||
let ret = mask_path("abc");
|
||||
assert!(
|
||||
ret.is_err(),
|
||||
"Should fail: path doesn't start with '/'. Got: {:?}",
|
||||
ret
|
||||
);
|
||||
|
||||
let ret = mask_path("abc/../");
|
||||
assert!(
|
||||
ret.is_err(),
|
||||
"Should fail: path contains '..'. Got: {:?}",
|
||||
ret
|
||||
);
|
||||
|
||||
let ret = mask_path("/tmp");
|
||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user