-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #2997 - RalfJung:test-utils, r=RalfJung
refactor tests/utils a bit, and move some FS functions there
- Loading branch information
Showing
16 changed files
with
77 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/tools/miri/tests/fail/tree_borrows/reserved/int-protected-write.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/tools/miri/tests/pass/tree_borrows/cell-alternate-writes.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::ffi::OsString; | ||
use std::path::PathBuf; | ||
|
||
use super::miri_extern; | ||
|
||
pub fn host_to_target_path(path: OsString) -> PathBuf { | ||
use std::ffi::{CStr, CString}; | ||
|
||
// Once into_os_str_bytes is stable we can use it here. | ||
// (Unstable features would need feature flags in each test...) | ||
let path = CString::new(path.into_string().unwrap()).unwrap(); | ||
let mut out = Vec::with_capacity(1024); | ||
|
||
unsafe { | ||
let ret = | ||
miri_extern::miri_host_to_target_path(path.as_ptr(), out.as_mut_ptr(), out.capacity()); | ||
assert_eq!(ret, 0); | ||
// Here we panic if it's not UTF-8... but that is hard to avoid with OsStr APIs. | ||
let out = CStr::from_ptr(out.as_ptr()).to_str().unwrap(); | ||
PathBuf::from(out) | ||
} | ||
} | ||
|
||
pub fn tmp() -> PathBuf { | ||
let path = | ||
std::env::var_os("MIRI_TEMP").unwrap_or_else(|| std::env::temp_dir().into_os_string()); | ||
// These are host paths. We need to convert them to the target. | ||
host_to_target_path(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.