Skip to content

Commit 9ec55eb

Browse files
committed
fix tests
1 parent 1df484c commit 9ec55eb

6 files changed

+51
-11
lines changed

tests/fail-dep/concurrency/libc_pthread_mutex_move.init.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | libc::pthread_mutex_lock(&mut m2 as *mut _);
1111
note: inside `main`
1212
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
1313
|
14-
LL | check();
15-
| ^^^^^^^
14+
LL | check();
15+
| ^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

tests/fail-dep/concurrency/libc_pthread_mutex_move.lock.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | libc::pthread_mutex_lock(&mut m2 as *mut _);
1111
note: inside `main`
1212
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
1313
|
14-
LL | check();
15-
| ^^^^^^^
14+
LL | check();
15+
| ^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

tests/fail-dep/concurrency/libc_pthread_mutex_move.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ignore-target-windows: No pthreads on Windows
2-
//@revisions: lock trylock unlock init
2+
//@[unlock_register]only-target-linux: recursive initializers are non-standard.
3+
//@revisions: lock trylock unlock_register unlock_detect init
34

45
fn main() {
56
check();
@@ -40,13 +41,32 @@ fn check() {
4041
}
4142
}
4243

43-
#[cfg(unlock)]
44+
#[cfg(unlock_register)]
4445
fn check() {
4546
unsafe {
4647
let mut m: libc::pthread_mutex_t = libc::PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
4748
libc::pthread_mutex_unlock(&mut m as *mut _);
4849

4950
let mut m2 = m;
50-
libc::pthread_mutex_unlock(&mut m2 as *mut _); //~[unlock] ERROR: pthread_mutex_t can't be moved after first use
51+
libc::pthread_mutex_unlock(&mut m2 as *mut _); //~[unlock_register] ERROR: pthread_mutex_t can't be moved after first use
52+
}
53+
}
54+
55+
#[cfg(unlock_detect)]
56+
fn check() {
57+
unsafe {
58+
let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
59+
assert_eq!(
60+
libc::pthread_mutexattr_settype(
61+
&mut mutexattr as *mut _,
62+
libc::PTHREAD_MUTEX_RECURSIVE
63+
),
64+
0,
65+
);
66+
let mut m: libc::pthread_mutex_t = std::mem::zeroed();
67+
assert_eq!(libc::pthread_mutex_init(&mut m as *mut _, &mutexattr as *const _), 0);
68+
69+
let mut m2 = m;
70+
libc::pthread_mutex_unlock(&mut m2 as *mut _); //~[unlock_detect] ERROR: pthread_mutex_t can't be moved after first use
5171
}
5272
}

tests/fail-dep/concurrency/libc_pthread_mutex_move.trylock.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | libc::pthread_mutex_trylock(&mut m2 as *mut _);
1111
note: inside `main`
1212
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
1313
|
14-
LL | check();
15-
| ^^^^^^^
14+
LL | check();
15+
| ^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

tests/fail-dep/concurrency/libc_pthread_mutex_move.unlock.stderr renamed to tests/fail-dep/concurrency/libc_pthread_mutex_move.unlock_detect.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | libc::pthread_mutex_unlock(&mut m2 as *mut _);
1111
note: inside `main`
1212
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
1313
|
14-
LL | check();
15-
| ^^^^^^^
14+
LL | check();
15+
| ^^^^^^^
1616

1717
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1818

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: Undefined Behavior: pthread_mutex_t can't be moved after first use
2+
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
3+
|
4+
LL | libc::pthread_mutex_unlock(&mut m2 as *mut _);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pthread_mutex_t can't be moved after first use
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `check` at $DIR/libc_pthread_mutex_move.rs:LL:CC
11+
note: inside `main`
12+
--> $DIR/libc_pthread_mutex_move.rs:LL:CC
13+
|
14+
LL | check();
15+
| ^^^^^^^
16+
17+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
18+
19+
error: aborting due to 1 previous error
20+

0 commit comments

Comments
 (0)