summaryrefslogtreecommitdiffstats
path: root/third_party/rust/nix/test/test_pty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/nix/test/test_pty.rs')
-rw-r--r--third_party/rust/nix/test/test_pty.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/third_party/rust/nix/test/test_pty.rs b/third_party/rust/nix/test/test_pty.rs
index 4cc6620c3c..368ec129b0 100644
--- a/third_party/rust/nix/test/test_pty.rs
+++ b/third_party/rust/nix/test/test_pty.rs
@@ -1,9 +1,9 @@
use std::fs::File;
-use std::io::{Read, Write};
+use std::io::{stdout, Read, Write};
use std::os::unix::prelude::*;
use std::path::Path;
-use libc::{_exit, STDOUT_FILENO};
+use libc::_exit;
use nix::fcntl::{open, OFlag};
use nix::pty::*;
use nix::sys::stat;
@@ -12,7 +12,7 @@ use nix::unistd::{pause, write};
/// Test equivalence of `ptsname` and `ptsname_r`
#[test]
-#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg(linux_android)]
fn test_ptsname_equivalence() {
let _m = crate::PTSNAME_MTX.lock();
@@ -29,7 +29,7 @@ fn test_ptsname_equivalence() {
/// Test data copying of `ptsname`
// TODO need to run in a subprocess, since ptsname is non-reentrant
#[test]
-#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg(linux_android)]
fn test_ptsname_copy() {
let _m = crate::PTSNAME_MTX.lock();
@@ -47,7 +47,7 @@ fn test_ptsname_copy() {
/// Test data copying of `ptsname_r`
#[test]
-#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg(linux_android)]
fn test_ptsname_r_copy() {
// Open a new PTTY master
let master_fd = posix_openpt(OFlag::O_RDWR).unwrap();
@@ -61,7 +61,7 @@ fn test_ptsname_r_copy() {
/// Test that `ptsname` returns different names for different devices
#[test]
-#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg(linux_android)]
fn test_ptsname_unique() {
let _m = crate::PTSNAME_MTX.lock();
@@ -96,7 +96,7 @@ fn open_ptty_pair() -> (PtyMaster, File) {
open(Path::new(&slave_name), OFlag::O_RDWR, stat::Mode::empty())
.unwrap();
- #[cfg(target_os = "illumos")]
+ #[cfg(solarish)]
// TODO: rewrite using ioctl!
#[allow(clippy::comparison_chain)]
{
@@ -185,7 +185,7 @@ fn test_openpty() {
// Writing to one should be readable on the other one
let string = "foofoofoo\n";
let mut buf = [0u8; 10];
- write(pty.master.as_raw_fd(), string.as_bytes()).unwrap();
+ write(&pty.master, string.as_bytes()).unwrap();
crate::read_exact(&pty.slave, &mut buf);
assert_eq!(&buf, string.as_bytes());
@@ -199,7 +199,7 @@ fn test_openpty() {
let string2 = "barbarbarbar\n";
let echoed_string2 = "barbarbarbar\r\n";
let mut buf = [0u8; 14];
- write(pty.slave.as_raw_fd(), string2.as_bytes()).unwrap();
+ write(&pty.slave, string2.as_bytes()).unwrap();
crate::read_exact(&pty.master, &mut buf);
assert_eq!(&buf, echoed_string2.as_bytes());
@@ -224,7 +224,7 @@ fn test_openpty_with_termios() {
// Writing to one should be readable on the other one
let string = "foofoofoo\n";
let mut buf = [0u8; 10];
- write(pty.master.as_raw_fd(), string.as_bytes()).unwrap();
+ write(&pty.master, string.as_bytes()).unwrap();
crate::read_exact(&pty.slave, &mut buf);
assert_eq!(&buf, string.as_bytes());
@@ -237,7 +237,7 @@ fn test_openpty_with_termios() {
let string2 = "barbarbarbar\n";
let echoed_string2 = "barbarbarbar\n";
let mut buf = [0u8; 13];
- write(pty.slave.as_raw_fd(), string2.as_bytes()).unwrap();
+ write(&pty.slave, string2.as_bytes()).unwrap();
crate::read_exact(&pty.master, &mut buf);
assert_eq!(&buf, echoed_string2.as_bytes());
@@ -258,7 +258,7 @@ fn test_forkpty() {
let pty = unsafe { forkpty(None, None).unwrap() };
match pty.fork_result {
Child => {
- write(STDOUT_FILENO, string.as_bytes()).unwrap();
+ write(stdout(), string.as_bytes()).unwrap();
pause(); // we need the child to stay alive until the parent calls read
unsafe {
_exit(0);