Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4784,6 +4784,30 @@ fn test_linux(target: &str) {
_ => false,
});

if gnu {
// old constants, so tests fail if glibc is too new
cfg.skip_const(|s| {
[
"B50", "B75", "B110", "B134", "B150", "B200", "B300", "B600", "B1200", "B1800",
"B2400", "B4800", "B9600", "B19200", "B38400", "EXTA", "EXTB", "B57600", "B115200",
"B230400", "B460800", "B500000", "B576000", "B921600", "B1000000", "B1152000",
"B1500000", "B2000000", "B2500000", "B3000000", "B3500000", "B4000000",
]
.contains(&s.ident())
});
// old symbols, so tests fail if glibc is too new
cfg.skip_fn_ptrcheck(|s| {
[
"cfgetispeed",
"cfgetospeed",
"cfsetispeed",
"cfsetospeed",
"cfsetspeed",
]
.contains(&s)
});
}

ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap();

if !l4re {
Expand Down
33 changes: 33 additions & 0 deletions libc-test/tests/linux_gnu_baud.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#[cfg(all(target_os = "linux", target_env = "gnu"))]
#[test]
fn baud() {
use libc::*;
let controller_fd = unsafe { posix_openpt(O_RDWR | O_NOCTTY) };
assert!(controller_fd >= 0);
unsafe {
grantpt(controller_fd);
unlockpt(controller_fd);
}
let mut buffer = [0; 256];
let ret = unsafe { ptsname_r(controller_fd, buffer.as_mut_ptr(), 256) };
assert!(ret >= 0);
let terminal_fd = unsafe { open(buffer.as_ptr(), O_RDWR | O_NOCTTY) };
assert!(terminal_fd >= 0);
let mut tio: termios = unsafe { std::mem::zeroed() };
let ret = unsafe { tcgetattr(terminal_fd, &mut tio) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B38400);
assert_eq!(unsafe { cfgetospeed(&tio) }, B38400);
let ret = unsafe { cfsetspeed(&mut tio, B1000000) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B1000000);
assert_eq!(unsafe { cfgetospeed(&tio) }, B1000000);
let ret = unsafe { cfsetispeed(&mut tio, B9600) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B9600);
assert!(matches!(unsafe { cfgetospeed(&tio) }, B9600 | B1000000));
let ret = unsafe { cfsetospeed(&mut tio, B19200) };
assert!(ret >= 0);
assert!(matches!(unsafe { cfgetispeed(&tio) }, B9600 | B19200));
assert_eq!(unsafe { cfgetospeed(&tio) }, B19200);
}
Loading