Skip to content

Commit

Permalink
Run all run(-dep) tests natively, too
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Oct 7, 2024
1 parent d28fb80 commit de41d01
Show file tree
Hide file tree
Showing 56 changed files with 235 additions and 50 deletions.
1 change: 1 addition & 0 deletions tests/pass-dep/libc/libc-mem.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@only-miri: testing specific alignment shenanigans
#![feature(strict_provenance, pointer_is_aligned_to)]
use std::{mem, ptr, slice};

Expand Down
1 change: 1 addition & 0 deletions tests/pass-dep/num_cpus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@only-miri: fake cpu number

fn main() {
assert_eq!(num_cpus::get(), 1);
Expand Down
1 change: 1 addition & 0 deletions tests/pass-dep/page_size_override.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-force-page-size=8
//@only-miri: fake page size

fn main() {
let page_size = page_size::get();
Expand Down
1 change: 1 addition & 0 deletions tests/pass/adjacent-allocs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-permissive-provenance
//@only-miri: CI found nonadjacent stack variables

fn ensure_allocs_can_be_adjacent() {
for _ in 0..512 {
Expand Down
1 change: 1 addition & 0 deletions tests/pass/atomic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@compile-flags: -Zmiri-strict-provenance
//@only-miri: testing weak memory behaviour

#![feature(strict_provenance, strict_provenance_atomic_ptr)]
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
Expand Down
1 change: 1 addition & 0 deletions tests/pass/backtrace/backtrace-api-v0.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@normalize-stderr-test: "::<.*>" -> ""
//@only-miri: backtraces differ too much

#[inline(never)]
fn func_a() -> Box<[*mut ()]> {
Expand Down
10 changes: 5 additions & 5 deletions tests/pass/backtrace/backtrace-api-v0.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests/pass/backtrace/backtrace-api-v0.rs:24:14 (func_d)
tests/pass/backtrace/backtrace-api-v0.rs:14:9 (func_c)
tests/pass/backtrace/backtrace-api-v0.rs:9:5 (func_b::<u8>)
tests/pass/backtrace/backtrace-api-v0.rs:5:5 (func_a)
tests/pass/backtrace/backtrace-api-v0.rs:29:18 (main)
tests/pass/backtrace/backtrace-api-v0.rs:25:14 (func_d)
tests/pass/backtrace/backtrace-api-v0.rs:15:9 (func_c)
tests/pass/backtrace/backtrace-api-v0.rs:10:5 (func_b::<u8>)
tests/pass/backtrace/backtrace-api-v0.rs:6:5 (func_a)
tests/pass/backtrace/backtrace-api-v0.rs:30:18 (main)
1 change: 1 addition & 0 deletions tests/pass/backtrace/backtrace-api-v1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@normalize-stderr-test: "::<.*>" -> ""
//@only-miri: backtraces differ too much

#[inline(never)]
fn func_a() -> Box<[*mut ()]> {
Expand Down
10 changes: 5 additions & 5 deletions tests/pass/backtrace/backtrace-api-v1.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests/pass/backtrace/backtrace-api-v1.rs:27:9 (func_d)
tests/pass/backtrace/backtrace-api-v1.rs:14:9 (func_c)
tests/pass/backtrace/backtrace-api-v1.rs:9:5 (func_b::<u8>)
tests/pass/backtrace/backtrace-api-v1.rs:5:5 (func_a)
tests/pass/backtrace/backtrace-api-v1.rs:34:18 (main)
tests/pass/backtrace/backtrace-api-v1.rs:28:9 (func_d)
tests/pass/backtrace/backtrace-api-v1.rs:15:9 (func_c)
tests/pass/backtrace/backtrace-api-v1.rs:10:5 (func_b::<u8>)
tests/pass/backtrace/backtrace-api-v1.rs:6:5 (func_a)
tests/pass/backtrace/backtrace-api-v1.rs:35:18 (main)
1 change: 1 addition & 0 deletions tests/pass/backtrace/backtrace-global-alloc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@compile-flags: -Zmiri-disable-isolation
//@rustc-env: RUST_BACKTRACE=1
//@only-miri: backtraces differ too much

use std::alloc::System;
use std::backtrace::Backtrace;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/backtrace/backtrace-std.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@compile-flags: -Zmiri-disable-isolation
//@rustc-env: RUST_BACKTRACE=1
//@only-miri: backtraces differ too much

use std::backtrace::Backtrace;

Expand Down
2 changes: 2 additions & 0 deletions tests/pass/cfg_miri.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: cfg miri test

fn main() {
assert!(cfg!(miri));
}
1 change: 1 addition & 0 deletions tests/pass/concurrency/thread_park_isolated.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ignore-target: apple # park_timeout on macOS uses the system clock
//@only-miri: runtime has nondeterministic execution and may be slower than 210ms
use std::thread;
use std::time::{Duration, Instant};

Expand Down
1 change: 1 addition & 0 deletions tests/pass/const-addrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// stack frame, breaking this test.
//@compile-flags: -Zinline-mir=no
#![feature(strict_provenance)]
//@only-miri: expecting that pointer addresses have specific behaviour

const EVALS: usize = 256;

Expand Down
2 changes: 2 additions & 0 deletions tests/pass/dyn-traits.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: expecting that vtables are not deduplicated

fn ref_box_dyn() {
struct Struct(i32);

Expand Down
1 change: 1 addition & 0 deletions tests/pass/extern_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@[stack]only-miri: miri specific warning
#![feature(extern_types, strict_provenance)]

use std::ptr;
Expand Down
2 changes: 2 additions & 0 deletions tests/pass/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#![allow(arithmetic_overflow)]
#![allow(internal_features)]

//@only-miri: FIXME: linker errors due to some missing libc float functions

use std::any::type_name;
use std::cmp::min;
use std::fmt::{Debug, Display, LowerHex};
Expand Down
2 changes: 2 additions & 0 deletions tests/pass/float_nan.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: FIXME: did not get value that should be possible: 0x7fc00000 (NaN: Pos, Quiet, payload = 0x0)

#![feature(float_gamma, portable_simd, core_intrinsics)]
use std::collections::HashSet;
use std::fmt;
Expand Down
2 changes: 2 additions & 0 deletions tests/pass/function_pointers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: testing that function pointers are inequal

use std::mem;

trait Answer {
Expand Down
1 change: 1 addition & 0 deletions tests/pass/getpid.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: with_isolation without_isolation
//@[without_isolation] compile-flags: -Zmiri-disable-isolation
//@only-miri: miri isolation mode test

fn getpid() -> u32 {
std::process::id()
Expand Down
1 change: 1 addition & 0 deletions tests/pass/hide_stdout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-mute-stdout-stderr
//@only-miri: miri flag test

fn main() {
println!("print to stdout");
Expand Down
1 change: 1 addition & 0 deletions tests/pass/intptrcast.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-permissive-provenance
//@only-miri: FIXME: CI found a miscompile: `assert_eq!(2, 2)` failed in `should_be_ub`

use std::mem;

Expand Down
25 changes: 14 additions & 11 deletions tests/pass/intrinsics/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ fn main() {
assert_eq!(intrinsics::likely(false), false);
assert_eq!(intrinsics::unlikely(true), true);

let mut saw_true = false;
let mut saw_false = false;
#[cfg(miri)]
{
let mut saw_true = false;
let mut saw_false = false;

for _ in 0..50 {
if intrinsics::is_val_statically_known(0) {
saw_true = true;
} else {
saw_false = true;
for _ in 0..50 {
if intrinsics::is_val_statically_known(0) {
saw_true = true;
} else {
saw_false = true;
}
}
assert!(
saw_true && saw_false,
"`is_val_statically_known` failed to return both true and false. Congrats, you won the lottery!"
);
}
assert!(
saw_true && saw_false,
"`is_val_statically_known` failed to return both true and false. Congrats, you won the lottery!"
);

intrinsics::forget(Bomb);

Expand Down
1 change: 1 addition & 0 deletions tests/pass/miri_start.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Cpanic=abort
//@only-miri: using miri internal apis
#![no_main]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions tests/pass/no_std.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Cpanic=abort
//@only-miri: using miri internal apis
#![feature(start)]
#![no_std]

Expand Down
1 change: 1 addition & 0 deletions tests/pass/path.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@only-miri: using miri internal apis
use std::path::{Path, PathBuf, absolute};

#[path = "../utils/mod.rs"]
Expand Down
1 change: 1 addition & 0 deletions tests/pass/protector-gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// allocation is still live. If the provenance GC only knows about the BorTag that is protected,
// we can ICE. This test checks that we don't.
// See https://github.com/rust-lang/miri/issues/3228
//@only-miri: using miri internal apis

#[path = "../utils/mod.rs"]
mod utils;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/provenance.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@only-miri: FIXME compiler panic: assertion failed: matches!(scalar, Scalar::Int(..))
#![feature(strict_provenance)]
use std::{mem, ptr};

Expand Down
1 change: 1 addition & 0 deletions tests/pass/ptr_int_casts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either.
//@[tree]compile-flags: -Zmiri-tree-borrows
//@[stack]compile-flags: -Zmiri-permissive-provenance
//@[tree]only-miri: miri specific warnings
use std::{mem, ptr};

fn eq_ref<T>(x: &T, y: &T) -> bool {
Expand Down
1 change: 1 addition & 0 deletions tests/pass/ptr_int_from_exposed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Tree Borrows doesn't support int2ptr casts, but let's make sure we don't immediately crash either.
//@[tree]compile-flags: -Zmiri-tree-borrows
//@[stack]compile-flags: -Zmiri-permissive-provenance
//@[tree]only-miri: miri specific warnings
#![feature(strict_provenance, exposed_provenance)]

use std::ptr;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/available-parallelism-miri-num-cpus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-num-cpus=1024
//@only-miri: download more cores

use std::num::NonZero;
use std::thread::available_parallelism;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/available-parallelism.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@only-miri: real system can have different number of cores
fn main() {
assert_eq!(std::thread::available_parallelism().unwrap().get(), 1);
}
2 changes: 2 additions & 0 deletions tests/pass/shims/env/args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: the actual command changes between platforms with rustc

fn main() {
for arg in std::env::args() {
println!("{}", arg);
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/env/current_dir_with_isolation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@compile-flags: -Zmiri-isolation-error=warn-nobacktrace
//@normalize-stderr-test: "(getcwd|GetCurrentDirectoryW)" -> "$$GETCWD"
//@normalize-stderr-test: "(chdir|SetCurrentDirectoryW)" -> "$$SETCWD"
//@only-miri: testing miri specific warnings

use std::env;
use std::io::ErrorKind;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/time-with-isolation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::time::{Duration, Instant};
//@only-miri: sleeps for one hour

fn test_sleep() {
// We sleep a *long* time here -- but the clock is virtual so the test should still pass quickly.
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@only-miri: runs under 1ms on a real system

use std::time::{Duration, Instant, SystemTime};

Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-aes-vaes.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+aes,+vaes,+avx512f
//@only-miri: FIXME: stability warnings only with rustc and some assert failures

#![feature(avx512_target_feature, stdarch_x86_avx512)]

Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-avx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+avx
//@only-miri: FIXME: some assert failures with rustc

#[cfg(target_arch = "x86")]
use std::arch::x86::*;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-avx2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+avx2
//@only-miri: FIXME: some assert failures with rustc

#[cfg(target_arch = "x86")]
use std::arch::x86::*;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-avx512.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bitalg,+avx512vpopcntdq
//@only-miri: FIXME: stability warnings only with rustc and some assert failures

#![feature(avx512_target_feature)]
#![feature(stdarch_x86_avx512)]
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-gfni.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=+gfni,+avx512f
//@only-miri: FIXME: returns weird exit code

// The constants in the tests below are just bit patterns. They should not
// be interpreted as integers; signedness does not make sense for them, but
Expand Down
1 change: 1 addition & 0 deletions tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We're testing x86 target specific features
//@only-target: x86_64 i686
//@compile-flags: -C target-feature=-sse2
//@only-miri: FIXME: some assert failures with rustc

#[cfg(target_arch = "x86")]
use std::arch::x86::*;
Expand Down
2 changes: 2 additions & 0 deletions tests/pass/stacked-borrows/issue-miri-2389.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//@only-miri: emits miri-specific warnings

use std::cell::Cell;

fn main() {
Expand Down
1 change: 1 addition & 0 deletions tests/pass/stacked-borrows/stack-printing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// We disable the GC for this test because it would change what is printed. We are testing the
// printing, not how it interacts with the GC.
//@compile-flags: -Zmiri-permissive-provenance -Zmiri-provenance-gc=0
//@only-miri: using miri internal apis

#![feature(strict_provenance)]
use std::alloc::{self, Layout};
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tail_call.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(incomplete_features)]
#![feature(explicit_tail_calls)]
//@only-miri: FIXME: tail calls not supported by llvm backend yet

fn main() {
assert_eq!(factorial(10), 3_628_800);
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tls/tls_macro_drop.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@only-miri: FIXME: gets stuck somewhere on windows at least

use std::cell::RefCell;
use std::thread;
Expand Down
2 changes: 2 additions & 0 deletions tests/pass/tls/win_tls_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// that's not what this test is about.
//@compile-flags: -Zmiri-ignore-leaks

//@only-miri: FIXME: fatal runtime error: thread::set_current should only be called once per thread

#[link_section = ".CRT$XLB"]
#[used] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
pub static CALLBACK: unsafe extern "system" fn(*const (), u32, *const ()) = tls_callback;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tree_borrows/cell-alternate-writes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We disable the GC for this test because it would change what is printed.
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
//@only-miri: uses miri internal APIs
#[path = "../../utils/mod.rs"]
#[macro_use]
mod utils;
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tree_borrows/end-of-protector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We disable the GC for this test because it would change what is printed.
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
//@only-miri: uses miri internals

// Check that a protector goes back to normal behavior when the function
// returns.
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tree_borrows/formatting.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We disable the GC for this test because it would change what is printed.
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
//@only-miri: uses miri internals

#[path = "../../utils/mod.rs"]
#[macro_use]
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tree_borrows/reborrow-is-read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We disable the GC for this test because it would change what is printed.
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
//@only-miri: uses miri internal APIs

#[path = "../../utils/mod.rs"]
#[macro_use]
Expand Down
1 change: 1 addition & 0 deletions tests/pass/tree_borrows/reserved.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We disable the GC for this test because it would change what is printed.
//@compile-flags: -Zmiri-tree-borrows -Zmiri-provenance-gc=0
//@only-miri: uses miri internals

#[path = "../../utils/mod.rs"]
#[macro_use]
Expand Down
Loading

0 comments on commit de41d01

Please sign in to comment.