diff --git a/tests/rust-integration-tests/integration_test/src/tests/mounts_recursive/mod.rs b/tests/rust-integration-tests/integration_test/src/tests/mounts_recursive/mod.rs index 492f446a7a..1b4d1c22f0 100644 --- a/tests/rust-integration-tests/integration_test/src/tests/mounts_recursive/mod.rs +++ b/tests/rust-integration-tests/integration_test/src/tests/mounts_recursive/mod.rs @@ -243,16 +243,47 @@ fn check_recursive_noexec() -> TestResult { result } +fn check_recursive_readwrite() -> TestResult { + let rrw_test_base_dir = PathBuf::from_str("/tmp").unwrap(); + let rrw_dir_path = rrw_test_base_dir.join("rrw_dir"); + let rrw_subdir_path = rrw_dir_path.join("rrw_subdir"); + let mount_dest_path = PathBuf::from_str("/rrw").unwrap(); + + let mount_options = vec!["rbind".to_string(), "rrw".to_string()]; + let mut mount_spec = Mount::default(); + mount_spec + .set_destination(mount_dest_path) + .set_typ(None) + .set_source(Some(rrw_dir_path.clone())) + .set_options(Some(mount_options)); + let spec = get_spec( + vec![mount_spec], + // check /rrw mount can write + vec!["touch".to_string(), "/rrw/a.txt".to_string()], + ); + + let result = test_inside_container(spec, &|_| { + setup_mount(&rrw_dir_path, &rrw_subdir_path); + Ok(()) + }); + + clean_mount(&rrw_dir_path, &rrw_subdir_path); + + result +} + pub fn get_mounts_recursive_test() -> TestGroup { let rro_test = Test::new("rro_test", Box::new(check_recursive_readonly)); let rnosuid_test = Test::new("rnosuid_test", Box::new(check_recursive_nosuid)); let rnoexec_test = Test::new("rnoexec_test", Box::new(check_recursive_noexec)); + let rrw_test = Test::new("rrw_test", Box::new(check_recursive_readwrite)); let mut tg = TestGroup::new("mounts_recursive"); tg.add(vec![ Box::new(rro_test), Box::new(rnosuid_test), Box::new(rnoexec_test), + Box::new(rrw_test), ]); tg