mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tests/cp, tests/test: Don't attempt to set sticky file bit on FreeBSD
On FreeBSD (and OpenBSD), only the superuser can set the file sticky bit.
This commit is contained in:
parent
aee1fcade4
commit
0ea1a7cd88
2 changed files with 16 additions and 6 deletions
|
@ -13,7 +13,7 @@ use std::os::unix::fs;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::fs::symlink_file;
|
use std::os::windows::fs::symlink_file;
|
||||||
|
@ -2381,13 +2381,18 @@ fn test_copy_symlink_force() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
#[cfg(unix)]
|
||||||
fn test_no_preserve_mode() {
|
fn test_no_preserve_mode() {
|
||||||
use std::os::unix::prelude::MetadataExt;
|
use std::os::unix::prelude::MetadataExt;
|
||||||
|
|
||||||
use uucore::mode::get_umask;
|
use uucore::mode::get_umask;
|
||||||
|
|
||||||
const PERMS_ALL: u32 = 0o7777;
|
const PERMS_ALL: u32 = if cfg!(target_os = "freebsd") {
|
||||||
|
// Only the superuser can set the sticky bit on a file.
|
||||||
|
0o6777
|
||||||
|
} else {
|
||||||
|
0o7777
|
||||||
|
};
|
||||||
|
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
|
@ -2407,11 +2412,16 @@ fn test_no_preserve_mode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
#[cfg(unix)]
|
||||||
fn test_preserve_mode() {
|
fn test_preserve_mode() {
|
||||||
use std::os::unix::prelude::MetadataExt;
|
use std::os::unix::prelude::MetadataExt;
|
||||||
|
|
||||||
const PERMS_ALL: u32 = 0o7777;
|
const PERMS_ALL: u32 = if cfg!(target_os = "freebsd") {
|
||||||
|
// Only the superuser can set the sticky bit on a file.
|
||||||
|
0o6777
|
||||||
|
} else {
|
||||||
|
0o7777
|
||||||
|
};
|
||||||
|
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
at.touch("file");
|
at.touch("file");
|
||||||
|
|
|
@ -553,7 +553,7 @@ fn test_nonexistent_file_is_not_symlink() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
// FixME: freebsd fails with 'chmod: sticky_file: Inappropriate file type or format'
|
// Only the superuser is allowed to set the sticky bit on files on FreeBSD.
|
||||||
// Windows has no concept of sticky bit
|
// Windows has no concept of sticky bit
|
||||||
#[cfg(not(any(windows, target_os = "freebsd")))]
|
#[cfg(not(any(windows, target_os = "freebsd")))]
|
||||||
fn test_file_is_sticky() {
|
fn test_file_is_sticky() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue