about summary refs log tree commit diff
path: root/src/tools/miri/tests/pass/shims/io.rs
blob: a96b98c022746b31ff2d9215712038b59d4d1cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::io::{self, IsTerminal, Write};

fn main() {
    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
    // (calls OS-specific error formatting functions).
    let raw_os_error = if cfg!(unix) {
        22 // EINVAL (on most Unixes, anyway)
    } else if cfg!(windows) {
        87 // ERROR_INVALID_PARAMETER
    } else {
        panic!("unsupported OS")
    };
    let err = io::Error::from_raw_os_error(raw_os_error);
    let _ = format!("{err}: {err:?}");
}