Skip to content

Commit

Permalink
Add descriptive error message when PCT rejects tests without concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
bkragl authored and jamesbornholt committed Jan 19, 2023
1 parent ea63f65 commit 2f52049
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/scheduler/pct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ impl Scheduler for PctScheduler {
self.steps = 0;

// On the first iteration, we run a simple oldest-task-first scheduler to determine a
// bound on the maximum number of steps. Once we have that, we can initialize PCT.
// lower bound on the maximum number of steps. Once we have that, we can initialize PCT.
// Note that we dynamically update the bound if we discover an execution with more steps.
if self.iterations > 0 {
assert!(self.max_steps > 0);
assert!(self.max_steps > 0, "test closure did not exercise any concurrency");

// Priorities are always distinct
debug_assert_eq!(
Expand Down
8 changes: 7 additions & 1 deletion tests/basic/pct.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use shuttle::scheduler::PctScheduler;
use shuttle::sync::Mutex;
use shuttle::{check_random, thread, Config, MaxSteps, Runner};
use shuttle::{check_pct, check_random, thread, Config, MaxSteps, Runner};
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::sync::Arc;
Expand Down Expand Up @@ -245,3 +245,9 @@ fn figure_1c() {
});
});
}

#[test]
#[should_panic(expected = "test closure did not exercise any concurrency")]
fn no_concurrency() {
check_pct(|| {}, 10, 2);
}

0 comments on commit 2f52049

Please sign in to comment.