Skip to content

Commit 5bfe6a1

Browse files
committed
Fix some race conditions in the integration tests
1 parent f3bf1df commit 5bfe6a1

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

test/sys/test_signal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ fn test_killpg_none() {
1818

1919
#[test]
2020
fn test_old_sigaction_flags() {
21+
let _m = ::SIGNAL_MTX.lock().expect("Mutex got poisoned by another test");
22+
2123
extern "C" fn handler(_: ::libc::c_int) {}
2224
let act = SigAction::new(
2325
SigHandler::Handler(handler),

test/test_unistd.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ fn test_mkfifo_directory() {
101101
#[test]
102102
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
103103
fn test_mkfifoat_none() {
104+
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
105+
104106
let tempdir = tempfile::tempdir().unwrap();
105107
let mkfifoat_fifo = tempdir.path().join("mkfifoat_fifo");
106108

@@ -128,11 +130,10 @@ fn test_mkfifoat() {
128130
#[test]
129131
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "android")))]
130132
fn test_mkfifoat_directory_none() {
133+
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
134+
131135
// mkfifoat should fail if a directory is given
132-
assert_eq!(
133-
mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok(),
134-
false
135-
);
136+
assert!(!mkfifoat(None, &env::temp_dir(), Mode::S_IRUSR).is_ok());
136137
}
137138

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

147-
assert_eq!(
148-
mkfifoat(Some(dirfd), mkfifoat_dir, Mode::S_IRUSR).is_ok(),
149-
false
150-
);
148+
assert!(!mkfifoat(Some(dirfd), mkfifoat_dir, Mode::S_IRUSR).is_ok());
151149
}
152150

153151
#[test]
@@ -637,6 +635,8 @@ fn test_canceling_alarm() {
637635

638636
#[test]
639637
fn test_symlinkat() {
638+
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
639+
640640
let tempdir = tempfile::tempdir().unwrap();
641641

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

683683
#[test]
684684
fn test_linkat_olddirfd_none() {
685+
let _dr = ::DirRestore::new();
686+
685687
let tempdir_oldfile = tempfile::tempdir().unwrap();
686688
let oldfilename = "foo.txt";
687689
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
@@ -704,6 +706,8 @@ fn test_linkat_olddirfd_none() {
704706

705707
#[test]
706708
fn test_linkat_newdirfd_none() {
709+
let _dr = ::DirRestore::new();
710+
707711
let tempdir_oldfile = tempfile::tempdir().unwrap();
708712
let oldfilename = "foo.txt";
709713
let oldfilepath = tempdir_oldfile.path().join(oldfilename);
@@ -727,6 +731,8 @@ fn test_linkat_newdirfd_none() {
727731
#[test]
728732
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
729733
fn test_linkat_no_follow_symlink() {
734+
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
735+
730736
let tempdir = tempfile::tempdir().unwrap();
731737
let oldfilename = "foo.txt";
732738
let oldfilepath = tempdir.path().join(oldfilename);
@@ -761,6 +767,8 @@ fn test_linkat_no_follow_symlink() {
761767

762768
#[test]
763769
fn test_linkat_follow_symlink() {
770+
let _m = ::CWD_LOCK.read().expect("Mutex got poisoned by another test");
771+
764772
let tempdir = tempfile::tempdir().unwrap();
765773
let oldfilename = "foo.txt";
766774
let oldfilepath = tempdir.path().join(oldfilename);

0 commit comments

Comments
 (0)