test direct usage of io::{stdout,stderr,stdin}
This commit is contained in:
parent
49482caad2
commit
2f34354e66
6 changed files with 25 additions and 17 deletions
|
|
@ -1,9 +0,0 @@
|
|||
//@ignore-target: windows # No libc IO on Windows
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let mut bytes = [0u8; 512];
|
||||
unsafe {
|
||||
libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512); //~ ERROR: `read` from stdin not available when isolation is enabled
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
12
src/tools/miri/tests/fail/shims/isolated_stdin.rs
Normal file
12
src/tools/miri/tests/fail/shims/isolated_stdin.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//@ignore-target: windows # FIXME: stdin does not work on Windows
|
||||
//@error-in-other-file: `read` from stdin not available when isolation is enabled
|
||||
//@normalize-stderr-test: "src/sys/.*\.rs" -> "$$FILE"
|
||||
//@normalize-stderr-test: "\nLL \| .*" -> ""
|
||||
//@normalize-stderr-test: "\| +[|_^]+" -> "| ^"
|
||||
//@normalize-stderr-test: "\n *= note:.*" -> ""
|
||||
use std::io::{self, Read};
|
||||
|
||||
fn main() {
|
||||
let mut bytes = [0u8; 512];
|
||||
io::stdin().read(&mut bytes).unwrap();
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
error: unsupported operation: `read` from stdin not available when isolation is enabled
|
||||
--> tests/fail-dep/libc/fs/isolated_stdin.rs:LL:CC
|
||||
--> RUSTLIB/std/$FILE:LL:CC
|
||||
|
|
||||
LL | libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `read` from stdin not available when isolation is enabled
|
||||
| ^ `read` from stdin not available when isolation is enabled
|
||||
|
|
||||
= help: set `MIRIFLAGS=-Zmiri-disable-isolation` to disable isolation;
|
||||
= help: or set `MIRIFLAGS=-Zmiri-isolation-error=warn` to make Miri return an error code from isolated operations (if supported for that operation) and continue with a warning
|
||||
= note: BACKTRACE:
|
||||
= note: inside `main` at tests/fail-dep/libc/fs/isolated_stdin.rs:LL:CC
|
||||
note: inside `main`
|
||||
--> tests/fail/shims/isolated_stdin.rs:LL:CC
|
||||
|
|
||||
| ^
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
use std::io::{self, IsTerminal};
|
||||
use std::io::{self, IsTerminal, Write};
|
||||
|
||||
fn main() {
|
||||
// We can't really assume that this is truly a terminal, and anyway on Windows Miri will always
|
||||
// return `false` here, but we can check that the call succeeds.
|
||||
io::stdout().write_all(b"stdout\n").unwrap();
|
||||
io::stderr().write_all(b"stderr\n").unwrap();
|
||||
|
||||
// We can't assume that this is truly a terminal, but we can check that the call succeeds.
|
||||
io::stdout().is_terminal();
|
||||
|
||||
// Ensure we can format `io::Error` created from OS errors
|
||||
|
|
|
|||
1
src/tools/miri/tests/pass/shims/io.stderr
Normal file
1
src/tools/miri/tests/pass/shims/io.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
stderr
|
||||
1
src/tools/miri/tests/pass/shims/io.stdout
Normal file
1
src/tools/miri/tests/pass/shims/io.stdout
Normal file
|
|
@ -0,0 +1 @@
|
|||
stdout
|
||||
Loading…
Add table
Add a link
Reference in a new issue