Skip to content
Open
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
123 changes: 67 additions & 56 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
use rand::RngCore;

#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "illumos",
target_vendor = "apple",
))]
use crate::assert_matches::assert_matches;
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "illumos",
target_vendor = "apple",
))]
use crate::fs::TryLockError;
use crate::fs::{self, File, FileTimes, OpenOptions};
use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError};
use crate::io::prelude::*;
use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
use crate::mem::MaybeUninit;
Expand Down Expand Up @@ -222,15 +205,22 @@ fn file_test_io_seek_and_write() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_multiple_shared() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_multiple_shared_test.txt");
Expand All @@ -247,15 +237,22 @@ fn file_lock_multiple_shared() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_blocking() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_blocking_test.txt");
Expand All @@ -273,15 +270,22 @@ fn file_lock_blocking() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_drop() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand All @@ -296,15 +300,22 @@ fn file_lock_drop() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_dup() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand Down Expand Up @@ -1252,7 +1263,7 @@ fn readlink_not_symlink() {
}

#[test]
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
fn links_work() {
let tmpdir = tmpdir();
let input = tmpdir.join("in.txt");
Expand Down Expand Up @@ -1748,7 +1759,7 @@ fn metadata_access_times() {

/// Test creating hard links to symlinks.
#[test]
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
fn symlink_hard_link() {
let tmpdir = tmpdir();
if !got_symlink_permission(&tmpdir) {
Expand Down
Loading