channels do ptr-int transmutes so move them to non-check-number-validity test
This commit is contained in:
parent
552b77e3b9
commit
5d7c495de5
57
tests/run-pass/concurrency/channels.rs
Normal file
57
tests/run-pass/concurrency/channels.rs
Normal file
@ -0,0 +1,57 @@
|
||||
// ignore-windows: Concurrency on Windows is not supported yet.
|
||||
// compile-flags: -Zmiri-disable-isolation
|
||||
|
||||
use std::sync::mpsc::{channel, sync_channel};
|
||||
use std::thread;
|
||||
|
||||
// Check if channels are working.
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn simple_send() {
|
||||
let (tx, rx) = channel();
|
||||
thread::spawn(move || {
|
||||
tx.send(10).unwrap();
|
||||
});
|
||||
assert_eq!(rx.recv().unwrap(), 10);
|
||||
}
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn multiple_send() {
|
||||
let (tx, rx) = channel();
|
||||
for i in 0..10 {
|
||||
let tx = tx.clone();
|
||||
thread::spawn(move || {
|
||||
tx.send(i).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
let mut sum = 0;
|
||||
for _ in 0..10 {
|
||||
let j = rx.recv().unwrap();
|
||||
assert!(0 <= j && j < 10);
|
||||
sum += j;
|
||||
}
|
||||
assert_eq!(sum, 45);
|
||||
}
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn send_on_sync() {
|
||||
let (sender, receiver) = sync_channel(1);
|
||||
|
||||
// this returns immediately
|
||||
sender.send(1).unwrap();
|
||||
|
||||
thread::spawn(move || {
|
||||
// this will block until the previous message has been received
|
||||
sender.send(2).unwrap();
|
||||
});
|
||||
|
||||
assert_eq!(receiver.recv().unwrap(), 1);
|
||||
assert_eq!(receiver.recv().unwrap(), 2);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
simple_send();
|
||||
multiple_send();
|
||||
send_on_sync();
|
||||
}
|
2
tests/run-pass/concurrency/channels.stderr
Normal file
2
tests/run-pass/concurrency/channels.stderr
Normal file
@ -0,0 +1,2 @@
|
||||
warning: thread support is experimental and incomplete: weak memory effects are not emulated.
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ignore-windows: Concurrency on Windows is not supported yet.
|
||||
// compile-flags: -Zmiri-check-number-validity
|
||||
|
||||
use std::thread;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: thread support is experimental and incomplete: weak memory effects are not emulated.
|
||||
|
||||
thread '<unnamed>' panicked at 'Hello!', $DIR/simple.rs:54:9
|
||||
thread '<unnamed>' panicked at 'Hello!', $DIR/simple.rs:55:9
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:64:9
|
||||
thread 'childthread' panicked at 'Hello, world!', $DIR/simple.rs:65:9
|
||||
|
@ -1,7 +1,6 @@
|
||||
// ignore-windows: Concurrency on Windows is not supported yet.
|
||||
// compile-flags: -Zmiri-disable-isolation -Zmiri-check-number-validity
|
||||
|
||||
use std::sync::mpsc::{channel, sync_channel};
|
||||
use std::sync::{Arc, Barrier, Condvar, Mutex, Once, RwLock};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
@ -181,52 +180,6 @@ fn check_rwlock_read_no_deadlock() {
|
||||
handle.join().unwrap();
|
||||
}
|
||||
|
||||
// Check if channels are working.
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn simple_send() {
|
||||
let (tx, rx) = channel();
|
||||
thread::spawn(move || {
|
||||
tx.send(10).unwrap();
|
||||
});
|
||||
assert_eq!(rx.recv().unwrap(), 10);
|
||||
}
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn multiple_send() {
|
||||
let (tx, rx) = channel();
|
||||
for i in 0..10 {
|
||||
let tx = tx.clone();
|
||||
thread::spawn(move || {
|
||||
tx.send(i).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
let mut sum = 0;
|
||||
for _ in 0..10 {
|
||||
let j = rx.recv().unwrap();
|
||||
assert!(0 <= j && j < 10);
|
||||
sum += j;
|
||||
}
|
||||
assert_eq!(sum, 45);
|
||||
}
|
||||
|
||||
/// The test taken from the Rust documentation.
|
||||
fn send_on_sync() {
|
||||
let (sender, receiver) = sync_channel(1);
|
||||
|
||||
// this returns immediately
|
||||
sender.send(1).unwrap();
|
||||
|
||||
thread::spawn(move || {
|
||||
// this will block until the previous message has been received
|
||||
sender.send(2).unwrap();
|
||||
});
|
||||
|
||||
assert_eq!(receiver.recv().unwrap(), 1);
|
||||
assert_eq!(receiver.recv().unwrap(), 2);
|
||||
}
|
||||
|
||||
// Check if Rust once statics are working.
|
||||
|
||||
static mut VAL: usize = 0;
|
||||
@ -353,9 +306,6 @@ fn main() {
|
||||
check_mutex();
|
||||
check_rwlock_write();
|
||||
check_rwlock_read_no_deadlock();
|
||||
simple_send();
|
||||
multiple_send();
|
||||
send_on_sync();
|
||||
check_once();
|
||||
check_rwlock_unlock_bug1();
|
||||
check_rwlock_unlock_bug2();
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ignore-windows: Concurrency on Windows is not supported yet.
|
||||
// compile-flags: -Zmiri-check-number-validity
|
||||
|
||||
//! The main purpose of this test is to check that if we take a pointer to
|
||||
//! thread's `t1` thread-local `A` and send it to another thread `t2`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user