Skip to content

Commit fb76c21

Browse files
committed
Fix test_ptymaster_drop after PR #1098
This test cannot be compiled under Redox. PR #1098 attempted to disable it for Redox, but actually disabled it everywhere. AFAICT, Cargo has no syntax to conditionally enable a target, except based on features. Instead, use conditional compilation within the test.
1 parent 1ae5dd8 commit fb76c21

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ name = "test-mount"
5858
path = "test/test_mount.rs"
5959
harness = false
6060

61-
[[target.'cfg(not(target_os = "redox"))'.test]]
61+
[[test]]
6262
name = "test-ptymaster-drop"
6363
path = "test/test_ptymaster_drop.rs"

test/test_ptymaster_drop.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
use nix::fcntl::OFlag;
2-
use nix::pty::*;
3-
use nix::unistd::close;
4-
use std::os::unix::io::AsRawFd;
1+
#[cfg(not(target_os = "redox"))]
2+
mod t {
3+
use nix::fcntl::OFlag;
4+
use nix::pty::*;
5+
use nix::unistd::close;
6+
use std::os::unix::io::AsRawFd;
57

6-
/// Regression test for Issue #659
7-
/// `PtyMaster` should panic rather than double close the file descriptor
8-
/// This must run in its own test process because it deliberately creates a race
9-
/// condition.
10-
#[test]
11-
#[should_panic(expected = "Closing an invalid file descriptor!")]
12-
// In Travis on i686-unknown-linux-musl, this test gets SIGABRT. I don't know
13-
// why. It doesn't happen on any other target, and it doesn't happen on my PC.
14-
#[cfg_attr(all(target_env = "musl", target_arch = "x86"), ignore)]
15-
fn test_double_close() {
16-
let m = posix_openpt(OFlag::O_RDWR).unwrap();
17-
close(m.as_raw_fd()).unwrap();
18-
drop(m); // should panic here
8+
/// Regression test for Issue #659
9+
///
10+
/// `PtyMaster` should panic rather than double close the file descriptor
11+
/// This must run in its own test process because it deliberately creates a
12+
/// race condition.
13+
#[test]
14+
#[should_panic(expected = "Closing an invalid file descriptor!")]
15+
// In Travis on i686-unknown-linux-musl, this test gets SIGABRT. I don't
16+
// know why. It doesn't happen on any other target, and it doesn't happen
17+
// on my PC.
18+
#[cfg_attr(all(target_env = "musl", target_arch = "x86"), ignore)]
19+
fn test_double_close() {
20+
let m = posix_openpt(OFlag::O_RDWR).unwrap();
21+
close(m.as_raw_fd()).unwrap();
22+
drop(m); // should panic here
23+
}
1924
}

0 commit comments

Comments
 (0)