Skip to content

Commit

Permalink
Merge pull request #374 from tommady/279-increate-the-code-coverage-o…
Browse files Browse the repository at this point in the history
…f-src-rootfs-part-7

part of PR 340 adding test_make_parent_mount_private
  • Loading branch information
utam0k committed Oct 9, 2021
2 parents bf4da50 + 4c90cfd commit b23cfc8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/rootfs/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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]);
}
}

0 comments on commit b23cfc8

Please sign in to comment.