@@ -6,29 +6,8 @@ use std::fs::{remove_file, File};
66use std:: os:: unix:: io:: AsRawFd ;
77use std:: path:: PathBuf ;
88
9- fn tmp ( ) -> PathBuf {
10- use std:: ffi:: { c_char, CStr , CString } ;
11-
12- let path = std:: env:: var ( "MIRI_TEMP" )
13- . unwrap_or_else ( |_| std:: env:: temp_dir ( ) . into_os_string ( ) . into_string ( ) . unwrap ( ) ) ;
14- // These are host paths. We need to convert them to the target.
15- let path = CString :: new ( path) . unwrap ( ) ;
16- let mut out = Vec :: with_capacity ( 1024 ) ;
17-
18- unsafe {
19- extern "Rust" {
20- fn miri_host_to_target_path (
21- path : * const c_char ,
22- out : * mut c_char ,
23- out_size : usize ,
24- ) -> usize ;
25- }
26- let ret = miri_host_to_target_path ( path. as_ptr ( ) , out. as_mut_ptr ( ) , out. capacity ( ) ) ;
27- assert_eq ! ( ret, 0 ) ;
28- let out = CStr :: from_ptr ( out. as_ptr ( ) ) . to_str ( ) . unwrap ( ) ;
29- PathBuf :: from ( out)
30- }
31- }
9+ #[ path = "../../utils/mod.rs" ]
10+ mod utils;
3211
3312/// Test allocating variant of `realpath`.
3413fn test_posix_realpath_alloc ( ) {
@@ -38,7 +17,7 @@ fn test_posix_realpath_alloc() {
3817 use std:: os:: unix:: ffi:: OsStringExt ;
3918
4019 let buf;
41- let path = tmp ( ) . join ( "miri_test_libc_posix_realpath_alloc" ) ;
20+ let path = utils :: tmp ( ) . join ( "miri_test_libc_posix_realpath_alloc" ) ;
4221 let c_path = CString :: new ( path. as_os_str ( ) . as_bytes ( ) ) . expect ( "CString::new failed" ) ;
4322
4423 // Cleanup before test.
@@ -63,7 +42,7 @@ fn test_posix_realpath_noalloc() {
6342 use std:: ffi:: { CStr , CString } ;
6443 use std:: os:: unix:: ffi:: OsStrExt ;
6544
66- let path = tmp ( ) . join ( "miri_test_libc_posix_realpath_noalloc" ) ;
45+ let path = utils :: tmp ( ) . join ( "miri_test_libc_posix_realpath_noalloc" ) ;
6746 let c_path = CString :: new ( path. as_os_str ( ) . as_bytes ( ) ) . expect ( "CString::new failed" ) ;
6847
6948 let mut v = vec ! [ 0 ; libc:: PATH_MAX as usize ] ;
@@ -103,7 +82,7 @@ fn test_posix_realpath_errors() {
10382fn test_posix_fadvise ( ) {
10483 use std:: io:: Write ;
10584
106- let path = tmp ( ) . join ( "miri_test_libc_posix_fadvise.txt" ) ;
85+ let path = utils :: tmp ( ) . join ( "miri_test_libc_posix_fadvise.txt" ) ;
10786 // Cleanup before test
10887 remove_file ( & path) . ok ( ) ;
10988
@@ -130,7 +109,7 @@ fn test_posix_fadvise() {
130109fn test_sync_file_range ( ) {
131110 use std:: io:: Write ;
132111
133- let path = tmp ( ) . join ( "miri_test_libc_sync_file_range.txt" ) ;
112+ let path = utils :: tmp ( ) . join ( "miri_test_libc_sync_file_range.txt" ) ;
134113 // Cleanup before test.
135114 remove_file ( & path) . ok ( ) ;
136115
@@ -243,7 +222,7 @@ fn test_isatty() {
243222 libc:: isatty ( libc:: STDERR_FILENO ) ;
244223
245224 // But when we open a file, it is definitely not a TTY.
246- let path = tmp ( ) . join ( "notatty.txt" ) ;
225+ let path = utils :: tmp ( ) . join ( "notatty.txt" ) ;
247226 // Cleanup before test.
248227 remove_file ( & path) . ok ( ) ;
249228 let file = File :: create ( & path) . unwrap ( ) ;
0 commit comments