@@ -9,7 +9,7 @@ fn miri_path() -> PathBuf {
9
9
}
10
10
11
11
// Build the shared object file for testing external C function calls.
12
- fn build_so_for_c_ffi_tests ( ) {
12
+ fn build_so_for_c_ffi_tests ( ) -> PathBuf {
13
13
let cc = option_env ! ( "CC" ) . unwrap_or ( "cc" ) ;
14
14
// Target directory that we can write to.
15
15
let so_target_dir = Path :: new ( & env:: var_os ( "CARGO_TARGET_DIR" ) . unwrap ( ) ) . join ( "miri-extern-so" ) ;
@@ -34,6 +34,7 @@ fn build_so_for_c_ffi_tests() {
34
34
if !cc_output. status . success ( ) {
35
35
panic ! ( "error in generating shared object file for testing external C function calls" ) ;
36
36
}
37
+ so_file_path
37
38
}
38
39
39
40
fn run_tests ( mode : Mode , path : & str , target : Option < String > ) -> Result < ( ) > {
@@ -63,9 +64,14 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
63
64
flags. push ( target. into ( ) ) ;
64
65
}
65
66
66
- // If we're on linux, then build the shared object file for testing external C function calls.
67
- if cfg ! ( target_os = "linux" ) {
68
- build_so_for_c_ffi_tests ( ) ;
67
+ // If we're on linux, and we're testing the extern-so functionality,
68
+ // then build the shared object file for testing external C function calls
69
+ // and push the relevant compiler flag.
70
+ if cfg ! ( target_os = "linux" ) && path. starts_with ( "tests/extern-so/" ) {
71
+ let so_file_path = build_so_for_c_ffi_tests ( ) ;
72
+ let mut flag = std:: ffi:: OsString :: from ( "-Zmiri-extern-so-file=" ) ;
73
+ flag. push ( so_file_path. into_os_string ( ) ) ;
74
+ flags. push ( flag) ;
69
75
}
70
76
71
77
let skip_ui_checks = env:: var_os ( "MIRI_SKIP_UI_CHECKS" ) . is_some ( ) ;
@@ -192,6 +198,10 @@ fn main() -> Result<()> {
192
198
ui ( Mode :: Pass , "tests/pass" ) ?;
193
199
ui ( Mode :: Panic , "tests/panic" ) ?;
194
200
ui ( Mode :: Fail , "tests/fail" ) ?;
201
+ if cfg ! ( target_os = "linux" ) {
202
+ ui ( Mode :: Pass , "tests/extern-so/pass" ) ?;
203
+ ui ( Mode :: Fail , "tests/extern-so/fail" ) ?;
204
+ }
195
205
196
206
Ok ( ( ) )
197
207
}
0 commit comments