Skip to content

Commit

Permalink
Test that isatty doesn't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Jul 18, 2022
1 parent 2f84cb3 commit eefdeac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/pass/libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ fn test_posix_gettimeofday() {
assert_eq!(is_error, -1);
}

fn test_isatty() {
// Testing whether our isatty shim returns the right value would require controlling whether
// these streams are actually TTYs, which is hard.
// For now, we just check that these calls are supported at all.
unsafe {
libc::isatty(libc::STDIN_FILENO);
libc::isatty(libc::STDOUT_FILENO);
libc::isatty(libc::STDERR_FILENO);
}
}

fn main() {
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
test_posix_fadvise();
Expand All @@ -335,4 +346,6 @@ fn main() {

#[cfg(any(target_os = "linux"))]
test_clocks();

test_isatty();
}

0 comments on commit eefdeac

Please sign in to comment.