summaryrefslogtreecommitdiffstats
path: root/third_party/rust/nix/test/sys/test_termios.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/nix/test/sys/test_termios.rs')
-rw-r--r--third_party/rust/nix/test/sys/test_termios.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/third_party/rust/nix/test/sys/test_termios.rs b/third_party/rust/nix/test/sys/test_termios.rs
index 83919378a7..35cc7ab739 100644
--- a/third_party/rust/nix/test/sys/test_termios.rs
+++ b/third_party/rust/nix/test/sys/test_termios.rs
@@ -4,17 +4,26 @@ use tempfile::tempfile;
use nix::errno::Errno;
use nix::fcntl;
use nix::pty::openpty;
-use nix::sys::termios::{self, tcgetattr, LocalFlags, OutputFlags};
+use nix::sys::termios::{self, tcgetattr, BaudRate, LocalFlags, OutputFlags};
use nix::unistd::{read, write};
/// Helper function analogous to `std::io::Write::write_all`, but for `Fd`s
fn write_all<Fd: AsFd>(f: Fd, buf: &[u8]) {
let mut len = 0;
while len < buf.len() {
- len += write(f.as_fd().as_raw_fd(), &buf[len..]).unwrap();
+ len += write(f.as_fd(), &buf[len..]).unwrap();
}
}
+#[test]
+fn test_baudrate_try_from() {
+ assert_eq!(Ok(BaudRate::B0), BaudRate::try_from(libc::B0));
+ #[cfg(not(target_os = "haiku"))]
+ BaudRate::try_from(999999999).expect_err("assertion failed");
+ #[cfg(target_os = "haiku")]
+ BaudRate::try_from(99).expect_err("assertion failed");
+}
+
// Test tcgetattr on a terminal
#[test]
fn test_tcgetattr_pty() {