Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit eefdeac

Browse files
committed
Test that isatty doesn't crash
1 parent 2f84cb3 commit eefdeac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/pass/libc.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,17 @@ fn test_posix_gettimeofday() {
311311
assert_eq!(is_error, -1);
312312
}
313313

314+
fn test_isatty() {
315+
// Testing whether our isatty shim returns the right value would require controlling whether
316+
// these streams are actually TTYs, which is hard.
317+
// For now, we just check that these calls are supported at all.
318+
unsafe {
319+
libc::isatty(libc::STDIN_FILENO);
320+
libc::isatty(libc::STDOUT_FILENO);
321+
libc::isatty(libc::STDERR_FILENO);
322+
}
323+
}
324+
314325
fn main() {
315326
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
316327
test_posix_fadvise();
@@ -335,4 +346,6 @@ fn main() {
335346

336347
#[cfg(any(target_os = "linux"))]
337348
test_clocks();
349+
350+
test_isatty();
338351
}

0 commit comments

Comments
 (0)