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

Function test_termios_winsize

tests/termios/termios.rs:46–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44
45#[test]
46fn test_termios_winsize() {
47 use rustix::pty::*;
48 use rustix::termios::*;
49
50 let pty = match openpt(OpenptFlags::empty()) {
51 Ok(pty) => pty,
52 Err(rustix::io::Errno::NOSYS) => return,
53 Err(err) => panic!("{:?}", err),
54 };
55
56 // Sizes for a pseudoterminal start out 0.
57 let mut sizes = match tcgetwinsize(&pty) {
58 Ok(sizes) => sizes,
59 // Apple doesn't appear to support `tcgetwinsize` on a pty.
60 #[cfg(apple)]
61 Err(rustix::io::Errno::NOTTY) => return,
62 Err(err) => panic!("{:?}", err),
63 };
64 assert_eq!(sizes.ws_row, 0);
65 assert_eq!(sizes.ws_col, 0);
66 assert_eq!(sizes.ws_xpixel, 0);
67 assert_eq!(sizes.ws_ypixel, 0);
68
69 // Set some arbitrary sizes.
70 sizes.ws_row = 28;
71 sizes.ws_col = 82;
72 sizes.ws_xpixel = 365;
73 sizes.ws_ypixel = 794;
74 tcsetwinsize(&pty, sizes).unwrap();
75
76 // Check that the sizes roundtripped.
77 let check_sizes = tcgetwinsize(&pty).unwrap();
78 assert_eq!(check_sizes.ws_row, sizes.ws_row);
79 assert_eq!(check_sizes.ws_col, sizes.ws_col);
80 assert_eq!(check_sizes.ws_xpixel, sizes.ws_xpixel);
81 assert_eq!(check_sizes.ws_ypixel, sizes.ws_ypixel);
82}
83
84// Disable on illumos where `tcgetattr` doesn't appear to support
85// pseudoterminals.

Callers

nothing calls this directly

Calls 3

openptFunction · 0.50
tcgetwinsizeFunction · 0.50
tcsetwinsizeFunction · 0.50

Tested by

no test coverage detected