Skip to content

Commit 5729d0f

Browse files
authored
Merge pull request #1353 from asomers/test_reliability2
Fix intermittency in some tests
2 parents a848ab5 + da204cf commit 5729d0f

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

test/sys/test_aio.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ fn test_aio_suspend() {
164164
loop {
165165
{
166166
let cbbuf = [&wcb, &rcb];
167-
assert!(aio_suspend(&cbbuf[..], Some(timeout)).is_ok());
167+
let r = aio_suspend(&cbbuf[..], Some(timeout));
168+
match r {
169+
Err(Error::Sys(Errno::EINTR)) => continue,
170+
Err(e) => panic!("aio_suspend returned {:?}", e),
171+
Ok(_) => ()
172+
};
168173
}
169174
if rcb.error() != Err(Error::from(Errno::EINPROGRESS)) &&
170175
wcb.error() != Err(Error::from(Errno::EINPROGRESS)) {

test/test_unistd.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::ffi::CString;
1919
use std::fs::DirBuilder;
2020
use std::fs::{self, File};
2121
use std::io::Write;
22-
use std::mem;
2322
use std::os::unix::prelude::*;
2423
#[cfg(not(target_os = "redox"))]
2524
use std::path::Path;
@@ -336,11 +335,17 @@ macro_rules! execve_test_factory(
336335
}
337336
}
338337

338+
// These tests frequently fail on musl, probably due to
339+
// https://github.com/nix-rust/nix/issues/555
340+
#[cfg_attr(target_env = "musl", ignore)]
339341
#[test]
340342
fn test_cstr_ref() {
341343
common_test(syscall_cstr_ref);
342344
}
343345

346+
// These tests frequently fail on musl, probably due to
347+
// https://github.com/nix-rust/nix/issues/555
348+
#[cfg_attr(target_env = "musl", ignore)]
344349
#[test]
345350
fn test_cstring() {
346351
common_test(syscall_cstring);
@@ -356,6 +361,8 @@ cfg_if!{
356361
execve_test_factory!(test_fexecve, fexecve, File::open("/system/bin/sh").unwrap().into_raw_fd());
357362
} else if #[cfg(any(target_os = "freebsd",
358363
target_os = "linux"))] {
364+
// These tests frequently fail on musl, probably due to
365+
// https://github.com/nix-rust/nix/issues/555
359366
execve_test_factory!(test_execve, execve, CString::new("/bin/sh").unwrap().as_c_str());
360367
execve_test_factory!(test_fexecve, fexecve, File::open("/bin/sh").unwrap().into_raw_fd());
361368
} else if #[cfg(any(target_os = "dragonfly",
@@ -378,11 +385,14 @@ execve_test_factory!(test_execvpe, execvpe, &CString::new("sh").unwrap());
378385
cfg_if!{
379386
if #[cfg(target_os = "android")] {
380387
use nix::fcntl::AtFlags;
381-
execve_test_factory!(test_execveat_empty, execveat, File::open("/system/bin/sh").unwrap().into_raw_fd(),
388+
execve_test_factory!(test_execveat_empty, execveat,
389+
File::open("/system/bin/sh").unwrap().into_raw_fd(),
382390
"", AtFlags::AT_EMPTY_PATH);
383-
execve_test_factory!(test_execveat_relative, execveat, File::open("/system/bin/").unwrap().into_raw_fd(),
391+
execve_test_factory!(test_execveat_relative, execveat,
392+
File::open("/system/bin/").unwrap().into_raw_fd(),
384393
"./sh", AtFlags::empty());
385-
execve_test_factory!(test_execveat_absolute, execveat, File::open("/").unwrap().into_raw_fd(),
394+
execve_test_factory!(test_execveat_absolute, execveat,
395+
File::open("/").unwrap().into_raw_fd(),
386396
"/system/bin/sh", AtFlags::empty());
387397
} else if #[cfg(all(target_os = "linux", any(target_arch ="x86_64", target_arch ="x86")))] {
388398
use nix::fcntl::AtFlags;
@@ -466,9 +476,7 @@ fn test_fchown() {
466476
fchown(fd, uid, gid).unwrap();
467477
fchown(fd, uid, None).unwrap();
468478
fchown(fd, None, gid).unwrap();
469-
470-
mem::drop(path);
471-
fchown(fd, uid, gid).unwrap_err();
479+
fchown(999999999, uid, gid).unwrap_err();
472480
}
473481

474482
#[test]

0 commit comments

Comments
 (0)