Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/cp, tests/test: Don't attempt to set sticky file bit on FreeBSD #5602

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
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
20 changes: 15 additions & 5 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::os::unix::fs;

#[cfg(unix)]
use std::os::unix::fs::MetadataExt;
#[cfg(all(unix, not(target_os = "freebsd")))]
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
#[cfg(windows)]
use std::os::windows::fs::symlink_file;
Expand Down Expand Up @@ -2381,13 +2381,18 @@ fn test_copy_symlink_force() {
}

#[test]
#[cfg(all(unix, not(target_os = "freebsd")))]
#[cfg(unix)]
fn test_no_preserve_mode() {
use std::os::unix::prelude::MetadataExt;

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!();
at.touch("file");
Expand All @@ -2407,11 +2412,16 @@ fn test_no_preserve_mode() {
}

#[test]
#[cfg(all(unix, not(target_os = "freebsd")))]
#[cfg(unix)]
fn test_preserve_mode() {
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!();
at.touch("file");
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ fn test_nonexistent_file_is_not_symlink() {
}

#[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
#[cfg(not(any(windows, target_os = "freebsd")))]
fn test_file_is_sticky() {
Expand Down
Loading