| 141 | #[cfg(not(target_os = "illumos"))] |
| 142 | #[test] |
| 143 | fn test_termios_special_codes() { |
| 144 | use rustix::pty::*; |
| 145 | use rustix::termios::*; |
| 146 | |
| 147 | let pty = match openpt(OpenptFlags::empty()) { |
| 148 | Ok(pty) => pty, |
| 149 | Err(rustix::io::Errno::NOSYS) => return, |
| 150 | Err(err) => panic!("{:?}", err), |
| 151 | }; |
| 152 | let mut tio = match tcgetattr(&pty) { |
| 153 | Ok(tio) => tio, |
| 154 | Err(rustix::io::Errno::NOSYS) => return, |
| 155 | #[cfg(apple)] |
| 156 | Err(rustix::io::Errno::NOTTY) => return, |
| 157 | Err(err) => panic!("{:?}", err), |
| 158 | }; |
| 159 | |
| 160 | // Check some initial values of `special_codes`. On Linux, `VINTR`'s code |
| 161 | // is set to ETX. On BSD's, it appears to be set to zero for |
| 162 | // pseudo-terminals. |
| 163 | #[cfg(linux_kernel)] |
| 164 | assert_eq!(tio.special_codes[SpecialCodeIndex::VINTR], 3); |
| 165 | #[cfg(bsd)] |
| 166 | assert_eq!(tio.special_codes[SpecialCodeIndex::VINTR], 0); |
| 167 | assert_eq!(tio.special_codes[SpecialCodeIndex::VEOL], 0); |
| 168 | |
| 169 | tio.special_codes[SpecialCodeIndex::VINTR] = 47; |
| 170 | tio.special_codes[SpecialCodeIndex::VEOL] = 99; |
| 171 | |
| 172 | tcsetattr(&pty, OptionalActions::Now, &tio).unwrap(); |
| 173 | |
| 174 | let new_tio = tcgetattr(&pty).unwrap(); |
| 175 | |
| 176 | assert_eq!(new_tio.special_codes[SpecialCodeIndex::VINTR], 47); |
| 177 | assert_eq!(new_tio.special_codes[SpecialCodeIndex::VEOL], 99); |
| 178 | } |
| 179 | |
| 180 | // Disable on illumos where `tcgetattr` doesn't appear to support |
| 181 | // pseudoterminals. |