-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bzip2.rs
: improve test coverage
#31
Conversation
8ad5cc5
to
77f0f9c
Compare
Codecov ReportAttention: Patch coverage is
|
77f0f9c
to
76e6ab6
Compare
tests/quick.rs
Outdated
#[cfg(unix)] | ||
unsafe fn custom_tty() -> ( | ||
std::sync::MutexGuard<'static, ()>, | ||
std::process::Stdio, | ||
std::process::Stdio, | ||
) { | ||
use std::{os::fd::FromRawFd, sync::Mutex}; | ||
|
||
// only one thread should be doing this at a time | ||
static X: Mutex<()> = Mutex::new(()); | ||
|
||
let guard = X.lock().unwrap(); | ||
|
||
// Open the master PTY using libc | ||
let cstring = std::ffi::CString::new("/dev/ptmx").unwrap(); | ||
let master_fd = unsafe { libc::open(cstring.as_ptr(), libc::O_RDWR) }; | ||
if master_fd < 0 { | ||
panic!("{}", std::io::Error::last_os_error()); | ||
} | ||
|
||
// Grant access to the slave PTY | ||
if unsafe { libc::grantpt(master_fd) } < 0 { | ||
panic!("{}", std::io::Error::last_os_error()); | ||
} | ||
|
||
// Unlock the slave PTY | ||
if unsafe { libc::unlockpt(master_fd) } < 0 { | ||
panic!("{}", std::io::Error::last_os_error()); | ||
} | ||
|
||
// Get the path to the slave PTY | ||
let slave_path_ptr = unsafe { libc::ptsname(master_fd) }; | ||
if slave_path_ptr.is_null() { | ||
panic!("{}", std::io::Error::last_os_error()); | ||
} | ||
|
||
// Open the slave PTY | ||
let slave_fd = unsafe { libc::open(slave_path_ptr, libc::O_RDWR) }; | ||
if slave_fd < 0 { | ||
panic!("{}", std::io::Error::last_os_error()); | ||
} | ||
|
||
unsafe { | ||
( | ||
guard, | ||
Stdio::from_raw_fd(master_fd), | ||
Stdio::from_raw_fd(slave_fd), | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the internet told me this is how to set up a TTY. it appears to work well as a stdout device, but not for stdin. It does work locally but that might be because of my shell? anyway on CI it does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the TTY stuff for now, the other changes are more important
76e6ab6
to
d6b2008
Compare
d6b2008
to
13b82f2
Compare
Co-authored-by: bjorn3 <[email protected]>
moves the tests around, and adds some additional coverage.
Codecov is not happy, but actuall if you look at it it's fine (the "uncovered lines" are comments...)