Auto merge of #3579 - RalfJung:libc, r=RalfJung

organize libc tests into a proper folder, and run some of them on Windows
This commit is contained in:
bors 2024-05-06 09:28:51 +00:00
commit 4d6d9a95f6
109 changed files with 215 additions and 212 deletions

View file

@ -143,10 +143,10 @@ case $HOST_TARGET in
# Partially supported targets (tier 2)
VERY_BASIC="integer vec string btreemap" # common things we test on all of them (if they have std), requires no target-specific shims
BASIC="$VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-misc libc-random libc-time fs env num_cpus
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-misc libc-random libc-time fs env num_cpus
MIRI_TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-misc libc-random
MIRI_TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-misc libc-random
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
MIRI_TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
MIRI_TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal $VERY_BASIC wasm
MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
/// Test that destroying a pthread_cond twice fails, even without a check for number validity

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@ignore-target-apple: Our macOS condattr don't have any fields so we do not notice this.
/// Test that destroying a pthread_condattr twice fails, even without a check for number validity

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@error-in-other-file: the main thread terminated without waiting for all remaining threads
// Check that we terminate the program when the main thread terminates.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//! The thread function must have exactly one argument.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//! The thread function must have exactly one argument.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
// Joining a detached thread is undefined behavior.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
// Joining an already joined thread is undefined behavior.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
// Joining the main thread is undefined behavior.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
// Joining the same thread from multiple threads is undefined behavior.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
// We are making scheduler assumptions here.
//@compile-flags: -Zmiri-preemption-rate=0

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//
// Check that if we pass NULL attribute, then we get the default mutex type.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@error-in-other-file: deadlock
use std::cell::UnsafeCell;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//
// Check that if we do not set the mutex type, it is the default.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
unsafe {

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
/// Test that destroying a pthread_mutex twice fails, even without a check for number validity

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
unsafe {

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
unsafe {

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
use std::cell::UnsafeCell;
use std::sync::Arc;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
/// Test that destroying a pthread_mutexattr twice fails, even without a check for number validity

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
/// Test that destroying a pthread_rwlock twice fails, even without a check for number validity

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
use std::cell::UnsafeCell;
use std::sync::Arc;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@error-in-other-file: deadlock
use std::cell::UnsafeCell;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@error-in-other-file: deadlock
use std::cell::UnsafeCell;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
fn main() {
let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
use std::cell::UnsafeCell;
use std::sync::Arc;

View file

@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc env support on Windows
use std::env;
use std::thread;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc IO on Windows
//@compile-flags: -Zmiri-disable-isolation
// FIXME: standard handles cannot be closed (https://github.com/rust-lang/rust/issues/40032)

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc IO on Windows
fn main() -> std::io::Result<()> {
let mut bytes = [0u8; 512];

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No mkstemp on Windows
//@compile-flags: -Zmiri-disable-isolation
fn main() {

View file

@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc IO on Windows
fn main() -> std::io::Result<()> {
let mut bytes = [0u8; 512];

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc IO on Windows
//@compile-flags: -Zmiri-disable-isolation
fn main() {

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc IO on Windows
fn main() -> std::io::Result<()> {
let bytes = b"hello";

View file

@ -1,5 +1,3 @@
//@ignore-target-windows: No libc on Windows
use std::ptr;
// null is explicitly called out as UB in the C docs.

View file

@ -1,5 +1,3 @@
//@ignore-target-windows: No libc on Windows
use std::ptr;
// null is explicitly called out as UB in the C docs.

View file

@ -1,4 +1,3 @@
//@ignore-target-windows: No libc on Windows
//@compile-flags: -Zmiri-permissive-provenance
// C says that passing "invalid" pointers is UB for all string functions.

View file

@ -1,4 +1,3 @@
//@ignore-target-windows: No libc on Windows
//@compile-flags: -Zmiri-permissive-provenance
// C's memcpy is 0 bytes is UB for some pointers that are allowed in Rust's `copy_nonoverlapping`.

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No `memrchr` on Windows
//@ignore-target-apple: No `memrchr` on some apple targets
use std::ptr;

View file

@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No mmap on Windows
#![feature(rustc_private)]

View file

@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No mmap on Windows
#![feature(rustc_private)]

View file

@ -1,7 +1,7 @@
//! The man pages for mmap/munmap suggest that it is possible to partly unmap a previously-mapped
//! region of address space, but to LLVM that would be partial deallocation, which LLVM does not
//! support. So even though the man pages say this sort of use is possible, we must report UB.
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No mmap on Windows
//@normalize-stderr-test: "size [0-9]+ and alignment" -> "size SIZE and alignment"
fn main() {

View file

@ -1,5 +1,3 @@
//@ignore-target-windows: No libc on Windows
fn main() {
unsafe {
let p1 = libc::malloc(20);

View file

@ -1,6 +1,6 @@
//! `signal()` is special on Linux and macOS that it's only supported within libstd.
//! The implementation is not complete enough to permit user code to call it.
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No `libc::signal` on Windows
//@normalize-stderr-test: "OS `.*`" -> "$$OS"
fn main() {

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: no `syscall` on Windows
//@ignore-target-apple: `syscall` is not supported on macOS
//@compile-flags: -Zmiri-panic-on-unsupported

View file

@ -1,22 +0,0 @@
//@ignore-target-windows: No libc on Windows
use core::slice;
fn main() {
unsafe {
let p1 = libc::calloc(0, 0);
assert!(p1.is_null());
let p2 = libc::calloc(20, 0);
assert!(p2.is_null());
let p3 = libc::calloc(0, 20);
assert!(p3.is_null());
let p4 = libc::calloc(4, 8);
assert!(!p4.is_null());
let slice = slice::from_raw_parts(p4 as *const u8, 4 * 8);
assert_eq!(&slice, &[0_u8; 4 * 8]);
libc::free(p4);
}
}

View file

@ -1,5 +1,5 @@
//@compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No libc env support on Windows
use std::ffi::CStr;
use std::thread;

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@ignore-target-apple: pthread_condattr_setclock is not supported on MacOS.
//@compile-flags: -Zmiri-disable-isolation

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//@ignore-target-apple: pthread_condattr_setclock is not supported on MacOS.
/// Test that conditional variable timeouts are working properly

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No pthreads on Windows
//! Test that pthread_key destructors are run in the right order.
//! Note that these are *not* used by actual `thread_local!` on Linux! Those use
//! `thread_local_dtor::register_dtor` from the stdlib instead. In Miri this hits the fallback path

View file

@ -1,4 +1,4 @@
//@ignore-target-windows: No libc on Windows
//@ignore-target-windows: No `dlsym` on Windows
//@compile-flags: -Zmiri-permissive-provenance
#[path = "../utils/mod.rs"]

Some files were not shown because too many files have changed in this diff Show more