Skip to content

Commit

Permalink
crux-mir: Use simpler #[crux::test] attribute for symbolic tests
Browse files Browse the repository at this point in the history
There's not much of a point in checking for the `crux` configuration attribute,
since one wouldn't be able to compile these tests with bare `rustc` anyway due
to their use of the `crucible` crate.
  • Loading branch information
RyanGlScott committed Jul 13, 2023
1 parent e8ac077 commit 0515e64
Show file tree
Hide file tree
Showing 104 changed files with 122 additions and 122 deletions.
2 changes: 1 addition & 1 deletion crux-mir/test/concurrency/atomic/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::thread;
use std::sync::{Arc,atomic};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_nofail() {
let N = 3;

Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/concurrency/atomic/atomic_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::thread;
use std::sync::{Arc,atomic};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_nofail() {
let N = 3;

Expand Down
4 changes: 2 additions & 2 deletions crux-mir/test/concurrency/mutex/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::thread;
use std::sync::{Arc,Mutex};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_nofail() {
let data = Arc::new(Mutex::new(0 as u32));
let N = 3;
Expand Down Expand Up @@ -37,7 +37,7 @@ fn crux_test_nofail() {
data.crucible_TEMP_unlock();
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_fail() {
let data = Arc::new(Mutex::new(0 as u32));
let N = 2;
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/concurrency/mutex/mutex_atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::atomic::AtomicU16;
use std::sync::atomic::Ordering::SeqCst;

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_nofail() {
let data = Arc::new(Mutex::new(()));
let ctr = Arc::new(AtomicU16::new(0));
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/concurrency/mutex/thread_retval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::thread;
use std::sync::{Arc,Mutex};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() {
let N = 2;
let V = 3;
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/concurrency/mutex/thread_retval_mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::thread;
use std::sync::{Arc,Mutex};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() {
let data = Arc::new(Mutex::new(0 as u32));
let N = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn find_entries(tid:usize,
count.crucible_TEMP_unlock();
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn pthread_finding_k_matches()
{
let mut vals = vec![];
Expand Down
6 changes: 3 additions & 3 deletions crux-mir/test/concurrency/sv-benchmarks/c/pthread/bigshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::thread;
use std::sync::{Arc,Mutex};

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn bigshot_p() {
let v = Arc::new(Mutex::new(None));

Expand Down Expand Up @@ -35,7 +35,7 @@ fn bigshot_p() {
}

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn bigshot_s() {
let v = Arc::new(Mutex::new(None));

Expand Down Expand Up @@ -65,7 +65,7 @@ fn bigshot_s() {
}

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn bigshot_s2() {
let v = Arc::new(Mutex::new(None));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn calc_fib() -> i32 {
j
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_fail() {
let data = Arc::new(Mutex::new((1 as i32, 1 as i32)));

Expand All @@ -59,7 +59,7 @@ fn crux_test_fail() {
data.crucible_TEMP_unlock();
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() {
let data = Arc::new(Mutex::new((1 as i32, 1 as i32)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn cas(tab:&Arc<Vec<Mutex<i32>>>, h:usize, val:i32, new_val:i32) -> i32
}

#[cfg(not(with_main))]
#[cfg_attr(crux, crux::test)]
#[crux::test]
fn indexer() {
let mut tab = vec![];
let mut ts = vec![];
Expand Down
4 changes: 2 additions & 2 deletions crux-mir/test/concurrency/sv-benchmarks/c/pthread/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn t2_bad(m : Arc<Mutex<Queue>>) {
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_fails() {
let mut q = Queue::new();
q.enqueue_flag = true;
Expand All @@ -149,7 +149,7 @@ fn crux_test_fails() {
h2.join();
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test_succeeds() {
let mut q = Queue::new();
q.enqueue_flag = true;
Expand Down
4 changes: 2 additions & 2 deletions crux-mir/test/concurrency/sv-benchmarks/c/pthread/reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ fn run_test(numSet: usize, numCheck: usize) {
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn reorder2() {
run_test(2,2);
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn reorder5() {
run_test(4,1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn thread0(v: Arc<Mutex<Option<i32>>>) {
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn singleton() {
let v = Arc::new(Mutex::new(None));
let vv = v.clone();
Expand Down
4 changes: 2 additions & 2 deletions crux-mir/test/concurrency/sv-benchmarks/c/pthread/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn t2(stack: Arc<Mutex<Stack>>, with_flag: bool)
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn stack_1()
{
let stk = Arc::new(Mutex::new(Stack::new()));
Expand All @@ -100,7 +100,7 @@ fn stack_1()
h2.join();
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn stack_2()
{
let stk = Arc::new(Mutex::new(Stack::new()));
Expand Down
4 changes: 2 additions & 2 deletions crux-mir/test/concurrency/sv-benchmarks/c/pthread/stateful.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ fn run_threads() -> (i32, i32)
return r
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn stateful01_1()
{
let (d1, d2) = run_threads();
crucible_assert!( !(d1 == 16 && d2 == 5) );
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn stateful01_2()
{
let (d1, d2) = run_threads();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn t2(i:Arc<AtomicI32>, j:Arc<AtomicI32>, m:Arc<Mutex<()>>)
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn triangular_1()
{
let i = Arc::new(AtomicI32::new(3));
Expand All @@ -58,7 +58,7 @@ fn triangular_1()
crucible_assert!(! (condI || condJ) );
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn triangular_2()
{
let i = Arc::new(AtomicI32::new(3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn t2(m:Arc<Mutex<()>>)
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn triangular_1()
{
let m = Arc::new(Mutex::new(()));
Expand All @@ -54,7 +54,7 @@ fn triangular_1()
crucible_assert!(! (condI || condJ) );
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn triangular_2()
{
let m = Arc::new(Mutex::new(()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn twostage_test(t_threads: usize, r_threads: usize) {
}
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn twostage_3() {
twostage_test(2,1);
}
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate crucible;
use crucible::*;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let x = u8::symbolic("x");
crucible_assume!(x < 2);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn g(cond: bool) -> u8 {
if !cond { 10 } else { 20 }
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> u8 {
f(true) + g(true)
}
4 changes: 2 additions & 2 deletions crux-mir/test/coverage/coverage_dual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ fn f(c: bool, t: i32, e: i32) -> i32 {
if c { t } else { e }
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test1() -> i32 {
f(false, 1, 2)
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test2() -> i32 {
f(true, 10, 20)
}
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_loop.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate crucible;
use crucible::*;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let mut y = 1;
for i in 0..10 {
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn f() -> Option<u8> {
Some(1)
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> u8 {
f().unwrap_or(0)
}
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enum E {
C = 30,
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let x = u8::symbolic("x");
crucible_assume!(x != 1);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn f<T>(c: bool, t: T, e: T) -> T {
if c { t } else { e }
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
f::<u8>(false, 1_u8, 2_u8) as i32 + f::<i32>(true, 10, 20)
}
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_shortcircuit.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate crucible;
use crucible::*;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let x = u8::symbolic("x");
crucible_assume!(x < 1);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/coverage/coverage_try.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn f() -> Option<u8> {
x.checked_add(y)
}

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> u8 {
f().unwrap_or(0)
}
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/alloc/out_of_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate crucible;
use crucible::*;
use crucible::alloc::allocate;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
unsafe {
let ptr = allocate::<i32>(10);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/alloc/uninit_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate crucible;
use crucible::*;
use crucible::alloc::allocate;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
unsafe {
let ptr = allocate::<i32>(10);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/alloc/valid_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate crucible;
use crucible::*;
use crucible::alloc::allocate;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
unsafe {
let ptr = allocate::<i32>(10);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/alloc/zero_length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate crucible;
use crucible::*;
use crucible::alloc::allocate;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() {
unsafe {
// Make sure the CustomOp succeeds in creating a pointer to the first element of an empty
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/any/conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate crucible;
use crucible::*;
use crucible::any::Any;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() {
let mut x = bool::symbolic("x");
if x {
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/any/downcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
extern crate crucible;
use crucible::any::Any;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let x: i32 = 1;
let a = Any::new(x);
Expand Down
2 changes: 1 addition & 1 deletion crux-mir/test/symb_eval/any/downcast_fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
extern crate crucible;
use crucible::any::Any;

#[cfg_attr(crux, crux::test)]
#[crux::test]
fn crux_test() -> i32 {
let x: () = ();
let a = Any::new(x);
Expand Down
Loading

0 comments on commit 0515e64

Please sign in to comment.