Implement the output dropping for windows, too

This commit is contained in:
Oli Scherer 2022-04-25 14:22:55 +00:00
parent 4d4855c762
commit 1d0fe1b6bb
2 changed files with 7 additions and 1 deletions

View File

@ -291,6 +291,9 @@ pub struct Evaluator<'mir, 'tcx> {
/// Failure rate of compare_exchange_weak, between 0.0 and 1.0
pub(crate) cmpxchg_weak_failure_rate: f64,
/// Corresponds to -Zmiri-drop-stdout-stderr and doesn't write the output but acts as if it succeeded.
pub(crate) drop_stdout_stderr: bool,
}
impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
@ -344,6 +347,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> {
tracked_alloc_ids: config.tracked_alloc_ids.clone(),
check_alignment: config.check_alignment,
cmpxchg_weak_failure_rate: config.cmpxchg_weak_failure_rate,
drop_stdout_stderr: config.drop_stdout_stderr,
}
}

View File

@ -75,7 +75,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
use std::io::{self, Write};
let buf_cont = this.read_bytes_ptr(buf, Size::from_bytes(u64::from(n)))?;
let res = if handle == -11 {
let res = if this.machine.drop_stdout_stderr {
Ok(buf_cont.len())
} else if handle == -11 {
io::stdout().write(buf_cont)
} else {
io::stderr().write(buf_cont)