test harness informs tests about suitable temp dir
This commit is contained in:
parent
3ba588db49
commit
8817397828
3 changed files with 16 additions and 7 deletions
|
|
@ -110,6 +110,8 @@ fn get_target() -> String {
|
|||
fn test_runner(_tests: &[&()]) {
|
||||
// Add a test env var to do environment communication tests.
|
||||
std::env::set_var("MIRI_ENV_VAR_TEST", "0");
|
||||
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
|
||||
std::env::set_var("MIRI_TEMP", std::env::temp_dir());
|
||||
|
||||
let target = get_target();
|
||||
miri_pass("tests/run-pass", &target);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,13 @@ fn main() {
|
|||
test_directory();
|
||||
}
|
||||
|
||||
fn tmp() -> PathBuf {
|
||||
std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
|
||||
}
|
||||
|
||||
/// Prepare: compute filename and make sure the file does not exist.
|
||||
fn prepare(filename: &str) -> PathBuf {
|
||||
let tmp = std::env::temp_dir();
|
||||
let path = tmp.join(filename);
|
||||
let path = tmp().join(filename);
|
||||
// Clean the paths for robustness.
|
||||
remove_file(&path).ok();
|
||||
path
|
||||
|
|
@ -27,8 +30,7 @@ fn prepare(filename: &str) -> PathBuf {
|
|||
|
||||
/// Prepare directory: compute directory name and make sure it does not exist.
|
||||
fn prepare_dir(dirname: &str) -> PathBuf {
|
||||
let tmp = std::env::temp_dir();
|
||||
let path = tmp.join(&dirname);
|
||||
let path = tmp().join(&dirname);
|
||||
// Clean the directory for robustness.
|
||||
remove_dir_all(&path).ok();
|
||||
path
|
||||
|
|
|
|||
|
|
@ -2,19 +2,24 @@
|
|||
// compile-flags: -Zmiri-disable-isolation
|
||||
|
||||
#![feature(rustc_private)]
|
||||
#![allow(unused)] // necessary on macos due to conditional compilation
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[allow(unused)] // necessary on macos due to conditional compilation
|
||||
extern crate libc;
|
||||
|
||||
fn tmp() -> PathBuf {
|
||||
std::env::var("MIRI_TEMP").map(PathBuf::from).unwrap_or_else(|_| std::env::temp_dir())
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn test_posix_fadvise() {
|
||||
use std::convert::TryInto;
|
||||
use std::env::temp_dir;
|
||||
use std::fs::{File, remove_file};
|
||||
use std::io::Write;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
let path = temp_dir().join("miri_test_libc.txt");
|
||||
let path = tmp().join("miri_test_libc.txt");
|
||||
// Cleanup before test
|
||||
remove_file(&path).ok();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue