blob: a41304d73f589afe25d9d47dfc76e76eae82cc13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
use nix::errno::Errno;
use nix::sys::termios;
use nix::{Error, unistd};
#[test]
fn test_tcgetattr() {
for fd in 0..5 {
let termios = termios::tcgetattr(fd);
match unistd::isatty(fd) {
// If `fd` is a TTY, tcgetattr must succeed.
Ok(true) => assert!(termios.is_ok()),
// If it's an invalid file descriptor, tcgetattr should also return
// the same error
Err(Error::Sys(Errno::EBADF)) => {
assert_eq!(termios.err(), Some(Error::Sys(Errno::EBADF)));
},
// Otherwise it should return any error
_ => assert!(termios.is_err())
}
}
}
|