about summary refs log tree commit diff
path: root/src/tools/miri/tests/pass/getpid.rs
blob: f350fafff4a261e5b8948d81b132347da68d7737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//@revisions: with_isolation without_isolation
//@[without_isolation] compile-flags: -Zmiri-disable-isolation

fn getpid() -> u32 {
    std::process::id()
}

fn main() {
    let pid = getpid();

    std::thread::spawn(move || {
        assert_eq!(getpid(), pid);
    });

    // Test that in isolation mode a deterministic value will be returned.
    // The value 1000 is not important, we only care that whatever the value
    // is, won't change from execution to execution.
    #[cfg(with_isolation)]
    assert_eq!(pid, 1000);
}