Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tests/by-util/test_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,43 @@ fn test_sync_data_but_not_file() {
}

#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(feature = "chmod")]
#[test]
fn test_sync_no_permission_dir() {
use std::os::unix::fs::PermissionsExt as _;
use uutests::util::TestScenario;
use uutests::util_name;

let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let dir = "foo";
at.mkdir_all(dir);
let path = at.subdir.as_path().join(dir);
let mut perms = fs::metadata(&path).unwrap().permissions();
perms.set_mode(0o0);
fs::set_permissions(&path, perms).unwrap();

ts.ccmd("chmod").arg("0").arg(dir).succeeds();
let result = ts.ucmd().arg("--data").arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied");
let result = ts.ucmd().arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied");
}

#[cfg(not(windows))]
#[cfg(feature = "chmod")]
#[test]
fn test_sync_no_permission_file() {
use std::os::unix::fs::PermissionsExt as _;
use uutests::util::TestScenario;
use uutests::util_name;

let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let f = "file";
at.touch(f);
let path = at.subdir.as_path().join(f);
let mut perms = fs::metadata(&path).unwrap().permissions();
perms.set_mode(0o200);
fs::set_permissions(&path, perms).unwrap();

ts.ccmd("chmod").arg("0200").arg(f).succeeds();
ts.ucmd().arg(f).succeeds();
}

Expand Down
Loading