MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_ttyname_ok

Function test_ttyname_ok

tests/termios/ttyname.rs:7–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6#[test]
7fn test_ttyname_ok() {
8 let file = match File::open("/dev/stdin") {
9 Ok(file) => file,
10 Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return,
11 Err(err) => panic!("{:?}", err),
12 };
13 if isatty(&file) {
14 let name = ttyname(&file, Vec::new()).unwrap().into_string().unwrap();
15 assert!(name.starts_with("/dev/"));
16 assert!(!name.ends_with('/'));
17 assert!(std::fs::metadata(&name)
18 .unwrap()
19 .file_type()
20 .is_char_device());
21 }
22}
23
24#[test]
25fn test_ttyname_not_tty() {

Callers

nothing calls this directly

Calls 4

kindMethod · 0.80
openFunction · 0.50
isattyFunction · 0.50
ttynameFunction · 0.50

Tested by

no test coverage detected