| 86 | #[cfg(not(target_os = "illumos"))] |
| 87 | #[test] |
| 88 | fn test_termios_modes() { |
| 89 | use rustix::pty::*; |
| 90 | use rustix::termios::*; |
| 91 | |
| 92 | let pty = match openpt(OpenptFlags::empty()) { |
| 93 | Ok(pty) => pty, |
| 94 | Err(rustix::io::Errno::NOSYS) => return, |
| 95 | Err(err) => panic!("{:?}", err), |
| 96 | }; |
| 97 | let mut tio = match tcgetattr(&pty) { |
| 98 | Ok(tio) => tio, |
| 99 | Err(rustix::io::Errno::NOSYS) => return, |
| 100 | #[cfg(apple)] |
| 101 | Err(rustix::io::Errno::NOTTY) => return, |
| 102 | Err(err) => panic!("{:?}", err), |
| 103 | }; |
| 104 | |
| 105 | assert!(!tio.local_modes.contains(LocalModes::TOSTOP)); |
| 106 | assert!(!tio.output_modes.contains(OutputModes::ONOCR)); |
| 107 | assert!(!tio.input_modes.contains(InputModes::IGNBRK)); |
| 108 | assert!(!tio.control_modes.contains(ControlModes::CLOCAL)); |
| 109 | |
| 110 | tio.local_modes.insert(LocalModes::TOSTOP); |
| 111 | tio.output_modes.insert(OutputModes::ONOCR); |
| 112 | tio.input_modes.insert(InputModes::IGNBRK); |
| 113 | tio.control_modes.insert(ControlModes::CLOCAL); |
| 114 | |
| 115 | tcsetattr(&pty, OptionalActions::Now, &tio).unwrap(); |
| 116 | |
| 117 | let new_tio = tcgetattr(&pty).unwrap(); |
| 118 | |
| 119 | assert!(new_tio.local_modes.contains(LocalModes::TOSTOP)); |
| 120 | assert!(new_tio.output_modes.contains(OutputModes::ONOCR)); |
| 121 | assert!(new_tio.input_modes.contains(InputModes::IGNBRK)); |
| 122 | assert!(new_tio.control_modes.contains(ControlModes::CLOCAL)); |
| 123 | |
| 124 | tio.local_modes.remove(LocalModes::TOSTOP); |
| 125 | tio.output_modes.remove(OutputModes::ONOCR); |
| 126 | tio.input_modes.remove(InputModes::IGNBRK); |
| 127 | tio.control_modes.remove(ControlModes::CLOCAL); |
| 128 | |
| 129 | tcsetattr(&pty, OptionalActions::Now, &tio).unwrap(); |
| 130 | |
| 131 | let new_tio = tcgetattr(&pty).unwrap(); |
| 132 | |
| 133 | assert!(!new_tio.local_modes.contains(LocalModes::TOSTOP)); |
| 134 | assert!(!new_tio.output_modes.contains(OutputModes::ONOCR)); |
| 135 | assert!(!new_tio.input_modes.contains(InputModes::IGNBRK)); |
| 136 | assert!(!new_tio.control_modes.contains(ControlModes::CLOCAL)); |
| 137 | } |
| 138 | |
| 139 | // Disable on illumos where `tcgetattr` doesn't appear to support |
| 140 | // pseudoterminals. |