From 490b737f5bea4645895fa17a8514c409e2259317 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sun, 10 Sep 2023 05:24:34 -0700 Subject: [PATCH] Fix the `test_ttyname_ok` test when /dev/stdin is inaccessable. (#821) /dev/stdin may be inaccessible in some sandboxed configurations, so just gracefully return if opening it fails. --- tests/termios/ttyname.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/termios/ttyname.rs b/tests/termios/ttyname.rs index 636178c31..b3f8d4843 100644 --- a/tests/termios/ttyname.rs +++ b/tests/termios/ttyname.rs @@ -4,7 +4,11 @@ use std::fs::File; #[test] fn test_ttyname_ok() { - let file = File::open("/dev/stdin").unwrap(); + let file = match File::open("/dev/stdin") { + Ok(file) => file, + Err(err) if err.kind() == std::io::ErrorKind::PermissionDenied => return, + Err(err) => Err(err).unwrap(), + }; if isatty(&file) { assert!(ttyname(&file, Vec::new()) .unwrap()