mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
Add test case for unix permissions
This commit is contained in:
parent
e391079496
commit
04c01e0b1f
@ -2160,6 +2160,27 @@ mod tests {
|
||||
check!(fs::remove_file(&filename));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn set_get_unix_permissions() {
|
||||
use os::unix::fs::PermissionsExt;
|
||||
|
||||
let tmpdir = tmpdir();
|
||||
let filename = &tmpdir.join("set_get_unix_permissions");
|
||||
check!(fs::create_dir(filename));
|
||||
let mask = 0o7777;
|
||||
|
||||
check!(fs::set_permissions(filename,
|
||||
fs::Permissions::from_mode(0)));
|
||||
let metadata0 = check!(fs::metadata(filename));
|
||||
assert_eq!(mask & metadata0.permissions().mode(), 0);
|
||||
|
||||
check!(fs::set_permissions(filename,
|
||||
fs::Permissions::from_mode(0o1777)));
|
||||
let metadata1 = check!(fs::metadata(filename));
|
||||
assert_eq!(mask & metadata1.permissions().mode(), 0o1777);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn file_test_io_seek_read_write() {
|
||||
|
Loading…
Reference in New Issue
Block a user