Skip to content

Commit b508450

Browse files
committed
ensure we do not see the inconsistent execution from Figure 8
1 parent 4c7b0ba commit b508450

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

tests/pass/0weak_memory_consistency.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fn spin_until_bool(loc: &AtomicBool, ord: Ordering, val: bool) -> bool {
4949
val
5050
}
5151

52-
/// Test matching https://www.doc.ic.ac.uk/~afd/homepages/papers/pdfs/2017/POPL.pdf, Figure 7
52+
/// Test matching https://www.doc.ic.ac.uk/~afd/homepages/papers/pdfs/2017/POPL.pdf, Figure 7.
53+
/// (The Figure 8 test is in `weak_memory/weak.rs`.)
5354
fn test_corr() {
5455
let x = static_atomic(0);
5556
let y = static_atomic(0);

tests/pass/weak_memory/weak.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ fn seq_cst() -> bool {
6969
j2.join().unwrap();
7070
let r3 = j3.join().unwrap();
7171

72+
// Even though we force t3 to run last, it can still see the value 1.
73+
// And it can *never* see the value 2!
74+
assert!(r3 == 1 || r3 == 3);
7275
r3 == 1
7376
}
7477

@@ -148,4 +151,9 @@ pub fn main() {
148151
assert_once(|| initialization_write(false));
149152
assert_once(|| initialization_write(true));
150153
assert_once(faa_replaced_by_load);
154+
155+
// Run seq_cst a few more times since it has an assertion we want to ensure holds always.
156+
for _ in 0..50 {
157+
seq_cst();
158+
}
151159
}

0 commit comments

Comments
 (0)