From eefdeacdb1aa2515359ba3cedfb04c81d74e783a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 17 Jul 2022 21:13:59 -0400 Subject: [PATCH] Test that isatty doesn't crash --- tests/pass/libc.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/pass/libc.rs b/tests/pass/libc.rs index 53c85d2b07d1..6da527927071 100644 --- a/tests/pass/libc.rs +++ b/tests/pass/libc.rs @@ -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(); @@ -335,4 +346,6 @@ fn main() { #[cfg(any(target_os = "linux"))] test_clocks(); + + test_isatty(); }