52 lines
1.9 KiB
Plaintext
52 lines
1.9 KiB
Plaintext
Test parameters. You can specify various parameters for test.
|
|
rl::test_params p;
|
|
p.search_type = rl::fair_context_bound_scheduler_type;
|
|
p.context_bound = 1;
|
|
p.execution_depth_limit = 1000;
|
|
rl::simulate<test_t>(p);
|
|
|
|
The main parameter is scheduler type used for simulation. There is 3 types of scheduler:
|
|
random_scheduler_type - random exploration of state space
|
|
fair_full_search_scheduler_type - exhaustive systematic exploration of state space
|
|
fair_context_bound_scheduler_type - systematic exploration of state space with limit on context switches.
|
|
|
|
For random_scheduler_type you can specify 'iteration_count' parameter - number of explored executions.
|
|
For fair_context_bound_scheduler_type you can specify 'context_bound' parameter - limit on context switches.
|
|
|
|
Also you can specify 'execution_depth_limit' parameter - used for livelock detection. All executions with trace longer than execution_depth_limit will be treated as livelocked (or non-terminating).
|
|
|
|
Also from test_params structure you can receive output parameters from simulation. Main output parameter is 'test_result' which describes cause of test failure.
|
|
|
|
If you use fair_full_search_scheduler_type or fair_context_bound_scheduler_type, in order to ensure fairness of scheduler, you must use 'yield' calls in all 'spin-loops', otherwise simulation will report non-terminating execution. Example:
|
|
|
|
struct race_seq_ld_ld_test : rl::test_suite<race_seq_ld_ld_test, 2>
|
|
{
|
|
std::atomic<int> a;
|
|
rl::var<int> x;
|
|
|
|
void before()
|
|
{
|
|
a($) = 0;
|
|
x($) = 0;
|
|
}
|
|
|
|
void thread(unsigned index)
|
|
{
|
|
if (index)
|
|
{
|
|
x($).load();
|
|
a($).store(1, std::memory_order_relaxed);
|
|
}
|
|
else
|
|
{
|
|
rl::backoff b;
|
|
while (0 == a($).load(rl::memory_order_relaxed))
|
|
b.yield($);
|
|
x($).load();
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
|