1
1
//@ignore-windows: No libc on Windows
2
2
//@compile-flags: -Zmiri-disable-isolation
3
-
4
3
#![ feature( rustc_private) ]
5
4
5
+ use std:: fs:: { remove_file, File } ;
6
+ use std:: os:: unix:: io:: AsRawFd ;
7
+
6
8
extern crate libc;
7
9
8
- #[ cfg( any( target_os = "linux" , target_os = "freebsd" ) ) ]
9
10
fn tmp ( ) -> std:: path:: PathBuf {
10
11
std:: env:: var ( "MIRI_TEMP" )
11
12
. map ( std:: path:: PathBuf :: from)
@@ -15,9 +16,7 @@ fn tmp() -> std::path::PathBuf {
15
16
#[ cfg( any( target_os = "linux" , target_os = "freebsd" ) ) ]
16
17
fn test_posix_fadvise ( ) {
17
18
use std:: convert:: TryInto ;
18
- use std:: fs:: { remove_file, File } ;
19
19
use std:: io:: Write ;
20
- use std:: os:: unix:: io:: AsRawFd ;
21
20
22
21
let path = tmp ( ) . join ( "miri_test_libc_posix_fadvise.txt" ) ;
23
22
// Cleanup before test
@@ -44,9 +43,7 @@ fn test_posix_fadvise() {
44
43
45
44
#[ cfg( any( target_os = "linux" ) ) ]
46
45
fn test_sync_file_range ( ) {
47
- use std:: fs:: { remove_file, File } ;
48
46
use std:: io:: Write ;
49
- use std:: os:: unix:: io:: AsRawFd ;
50
47
51
48
let path = tmp ( ) . join ( "miri_test_libc_sync_file_range.txt" ) ;
52
49
// Cleanup before test.
@@ -319,6 +316,19 @@ fn test_isatty() {
319
316
libc:: isatty ( libc:: STDIN_FILENO ) ;
320
317
libc:: isatty ( libc:: STDOUT_FILENO ) ;
321
318
libc:: isatty ( libc:: STDERR_FILENO ) ;
319
+
320
+ // But when we open a file, it is definitely not a TTY.
321
+ let path = tmp ( ) . join ( "notatty.txt" ) ;
322
+ // Cleanup before test.
323
+ remove_file ( & path) . ok ( ) ;
324
+ let file = File :: create ( & path) . unwrap ( ) ;
325
+
326
+ assert_eq ! ( libc:: isatty( file. as_raw_fd( ) ) , 0 ) ;
327
+ assert_eq ! ( std:: io:: Error :: last_os_error( ) . raw_os_error( ) . unwrap( ) , libc:: ENOTTY ) ;
328
+
329
+ // Cleanup after test.
330
+ drop ( file) ;
331
+ remove_file ( & path) . unwrap ( ) ;
322
332
}
323
333
}
324
334
0 commit comments