Skip to content

Commit 2f34354

Browse files
committed
test direct usage of io::{stdout,stderr,stdin}
1 parent 49482ca commit 2f34354

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

src/tools/miri/tests/fail-dep/libc/fs/isolated_stdin.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ignore-target: windows # FIXME: stdin does not work on Windows
2+
//@error-in-other-file: `read` from stdin not available when isolation is enabled
3+
//@normalize-stderr-test: "src/sys/.*\.rs" -> "$$FILE"
4+
//@normalize-stderr-test: "\nLL \| .*" -> ""
5+
//@normalize-stderr-test: "\| +[|_^]+" -> "| ^"
6+
//@normalize-stderr-test: "\n *= note:.*" -> ""
7+
use std::io::{self, Read};
8+
9+
fn main() {
10+
let mut bytes = [0u8; 512];
11+
io::stdin().read(&mut bytes).unwrap();
12+
}

src/tools/miri/tests/fail-dep/libc/fs/isolated_stdin.stderr renamed to src/tools/miri/tests/fail/shims/isolated_stdin.stderr

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
error: unsupported operation: `read` from stdin not available when isolation is enabled
2-
--> tests/fail-dep/libc/fs/isolated_stdin.rs:LL:CC
2+
--> RUSTLIB/std/$FILE:LL:CC
33
|
4-
LL | libc::read(0, bytes.as_mut_ptr() as *mut libc::c_void, 512);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `read` from stdin not available when isolation is enabled
4+
| ^ `read` from stdin not available when isolation is enabled
65
|
76
= help: set `MIRIFLAGS=-Zmiri-disable-isolation` to disable isolation;
87
= 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
9-
= note: BACKTRACE:
10-
= note: inside `main` at tests/fail-dep/libc/fs/isolated_stdin.rs:LL:CC
8+
note: inside `main`
9+
--> tests/fail/shims/isolated_stdin.rs:LL:CC
10+
|
11+
| ^
1112

1213
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1314

src/tools/miri/tests/pass/shims/io.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use std::io::{self, IsTerminal};
1+
use std::io::{self, IsTerminal, Write};
22

33
fn main() {
4-
// We can't really assume that this is truly a terminal, and anyway on Windows Miri will always
5-
// return `false` here, but we can check that the call succeeds.
4+
io::stdout().write_all(b"stdout\n").unwrap();
5+
io::stderr().write_all(b"stderr\n").unwrap();
6+
7+
// We can't assume that this is truly a terminal, but we can check that the call succeeds.
68
io::stdout().is_terminal();
79

810
// Ensure we can format `io::Error` created from OS errors
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stderr
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stdout

0 commit comments

Comments
 (0)