Skip to content

Commit

Permalink
Merge #1157
Browse files Browse the repository at this point in the history
1157: Fix some race conditions in the integration tests r=asomers a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
  • Loading branch information
bors[bot] and asomers committed Dec 1, 2019
2 parents fd59067 + 722fc77 commit 50374c6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -80,6 +80,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Fix length of abstract socket addresses
([#1120](https://github.com/nix-rust/nix/pull/1120))

- Fix initialization of msghdr in recvmsg/sendmsg when built with musl
([#1136](https://github.com/nix-rust/nix/pull/1136))

Expand Down
2 changes: 2 additions & 0 deletions test/sys/test_signal.rs
Expand Up @@ -18,6 +18,8 @@ fn test_killpg_none() {

#[test]
fn test_old_sigaction_flags() {
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");

extern "C" fn handler(_: ::libc::c_int) {}
let act = SigAction::new(
SigHandler::Handler(handler),
Expand Down
24 changes: 16 additions & 8 deletions test/test_unistd.rs
Expand Up @@ -101,6 +101,8 @@ fn test_mkfifo_directory() {
#[test]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
fn test_mkfifoat_none() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");

let tempdir = tempfile::tempdir().unwrap();
let mkfifoat_fifo = tempdir.path().join("mkfifoat_fifo");

Expand Down Expand Up @@ -128,11 +130,10 @@ fn test_mkfifoat() {
#[test]
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
fn test_mkfifoat_directory_none() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");

// mkfifoat should fail if a directory is given
assert_eq!(
mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok(),
false
);
assert!(!mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok());
}

#[test]
Expand All @@ -144,10 +145,7 @@ fn test_mkfifoat_directory() {
let mkfifoat_dir = "mkfifoat_dir";
stat::mkdirat(dirfd, mkfifoat_dir, Mode::S_IRUSR).unwrap();

assert_eq!(
mkfifoat(Some(dirfd), mkfifoat_dir, Mode::S_IRUSR).is_ok(),
false
);
assert!(!mkfifoat(Some(dirfd), mkfifoat_dir, Mode::S_IRUSR).is_ok());
}

#[test]
Expand Down Expand Up @@ -637,6 +635,8 @@ fn test_canceling_alarm() {

#[test]
fn test_symlinkat() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");

let tempdir = tempfile::tempdir().unwrap();

let target = tempdir.path().join("a");
Expand Down Expand Up @@ -682,6 +682,8 @@ fn test_linkat_file() {

#[test]
fn test_linkat_olddirfd_none() {
let _dr = ::DirRestore::new();

let tempdir_oldfile = tempfile::tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
Expand All @@ -704,6 +706,8 @@ fn test_linkat_olddirfd_none() {

#[test]
fn test_linkat_newdirfd_none() {
let _dr = ::DirRestore::new();

let tempdir_oldfile = tempfile::tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
Expand All @@ -727,6 +731,8 @@ fn test_linkat_newdirfd_none() {
#[test]
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
fn test_linkat_no_follow_symlink() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");

let tempdir = tempfile::tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir.path().join(oldfilename);
Expand Down Expand Up @@ -761,6 +767,8 @@ fn test_linkat_no_follow_symlink() {

#[test]
fn test_linkat_follow_symlink() {
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");

let tempdir = tempfile::tempdir().unwrap();
let oldfilename = "foo.txt";
let oldfilepath = tempdir.path().join(oldfilename);
Expand Down

0 comments on commit 50374c6

Please sign in to comment.