1 use rustix::io; 2 use rustix::termios::{isatty, ttyname}; 3 use std::fs::File; 4 5 #[test] test_ttyname_ok()6fn test_ttyname_ok() { 7 let file = File::open("/dev/stdin").unwrap(); 8 if isatty(&file) { 9 assert!(ttyname(&file, Vec::new()) 10 .unwrap() 11 .into_string() 12 .unwrap() 13 .starts_with("/dev/")); 14 } 15 } 16 17 #[test] test_ttyname_not_tty()18fn test_ttyname_not_tty() { 19 let file = File::open("Cargo.toml").unwrap(); 20 assert_eq!(ttyname(&file, Vec::new()).unwrap_err(), io::Errno::NOTTY); 21 22 let file = File::open("/dev/null").unwrap(); 23 assert_eq!(ttyname(&file, Vec::new()).unwrap_err(), io::Errno::NOTTY); 24 } 25