1
0
mirror of https://github.com/containers/youki synced 2024-09-27 22:49:57 +02:00

Merge pull request #374 from tommady/279-increate-the-code-coverage-of-src-rootfs-part-7

part of PR 340 adding test_make_parent_mount_private
This commit is contained in:
utam0k 2021-10-09 22:34:21 +09:00 committed by GitHub
commit b23cfc820f
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,11 +278,11 @@ impl Mount {
mod tests {
use super::*;
use crate::syscall::test::{MountArgs, TestHelperSyscall};
use crate::utils::TempDir;
use crate::utils::create_temp_dir;
#[test]
fn test_mount_to_container() {
let tmp_dir = TempDir::new("/tmp/test_mount_to_container").unwrap();
let tmp_dir = create_temp_dir("test_mount_to_container").unwrap();
{
let m = Mount::new();
let mount = &SpecMountBuilder::default()
@ -370,4 +370,28 @@ mod tests {
assert_eq!(got.len(), 2);
}
}
#[test]
fn test_make_parent_mount_private() {
let tmp_dir = create_temp_dir("test_make_parent_mount_private").unwrap();
let m = Mount::new();
assert!(m.make_parent_mount_private(tmp_dir.path()).is_ok());
let want = MountArgs {
source: None,
target: PathBuf::from("/"),
fstype: None,
flags: MsFlags::MS_PRIVATE,
data: None,
};
let got = m
.syscall
.as_any()
.downcast_ref::<TestHelperSyscall>()
.unwrap()
.get_mount_args();
assert_eq!(got.len(), 1);
assert_eq!(want, got[0]);
}
}