Skip to content

Commit 56c741d

Browse files
committed
links old version of cf{g,s}et{i,o}speed for glibc
1 parent 7726e8f commit 56c741d

File tree

3 files changed

+517
-0
lines changed

3 files changed

+517
-0
lines changed

libc-test/build.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,6 +4784,30 @@ fn test_linux(target: &str) {
47844784
_ => false,
47854785
});
47864786

4787+
if gnu {
4788+
// old constants, so tests fail if glibc is too new
4789+
cfg.skip_const(|s| {
4790+
[
4791+
"B50", "B75", "B110", "B134", "B150", "B200", "B300", "B600", "B1200", "B1800",
4792+
"B2400", "B4800", "B9600", "B19200", "B38400", "EXTA", "EXTB", "B57600", "B115200",
4793+
"B230400", "B460800", "B500000", "B576000", "B921600", "B1000000", "B1152000",
4794+
"B1500000", "B2000000", "B2500000", "B3000000", "B3500000", "B4000000",
4795+
]
4796+
.contains(&s.ident())
4797+
});
4798+
// old symbols, so tests fail if glibc is too new
4799+
cfg.skip_fn_ptrcheck(|s| {
4800+
[
4801+
"cfgetispeed",
4802+
"cfgetospeed",
4803+
"cfsetispeed",
4804+
"cfsetospeed",
4805+
"cfsetspeed",
4806+
]
4807+
.contains(&s)
4808+
});
4809+
}
4810+
47874811
ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap();
47884812

47894813
if !l4re {

libc-test/tests/linux_gnu_baud.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
2+
#[test]
3+
fn baud() {
4+
use libc::*;
5+
let controller_fd = unsafe { posix_openpt(O_RDWR | O_NOCTTY) };
6+
assert!(controller_fd >= 0);
7+
unsafe {
8+
grantpt(controller_fd);
9+
unlockpt(controller_fd);
10+
}
11+
let mut buffer = [0; 256];
12+
let ret = unsafe { ptsname_r(controller_fd, buffer.as_mut_ptr(), 256) };
13+
assert!(ret >= 0);
14+
let terminal_fd = unsafe { open(buffer.as_ptr(), O_RDWR | O_NOCTTY) };
15+
assert!(terminal_fd >= 0);
16+
let mut tio: termios = unsafe { std::mem::zeroed() };
17+
let ret = unsafe { tcgetattr(terminal_fd, &mut tio) };
18+
assert!(ret >= 0);
19+
assert_eq!(unsafe { cfgetispeed(&tio) }, B38400);
20+
assert_eq!(unsafe { cfgetospeed(&tio) }, B38400);
21+
let ret = unsafe { cfsetspeed(&mut tio, B1000000) };
22+
assert!(ret >= 0);
23+
assert_eq!(unsafe { cfgetispeed(&tio) }, B1000000);
24+
assert_eq!(unsafe { cfgetospeed(&tio) }, B1000000);
25+
let ret = unsafe { cfsetispeed(&mut tio, B9600) };
26+
assert!(ret >= 0);
27+
assert_eq!(unsafe { cfgetispeed(&tio) }, B9600);
28+
assert!(matches!(unsafe { cfgetospeed(&tio) }, B9600 | B1000000));
29+
let ret = unsafe { cfsetospeed(&mut tio, B19200) };
30+
assert!(ret >= 0);
31+
assert!(matches!(unsafe { cfgetispeed(&tio) }, B9600 | B19200));
32+
assert_eq!(unsafe { cfgetospeed(&tio) }, B19200);
33+
}

0 commit comments

Comments
 (0)