Configuring a testing strategy
Lincheck supports various configuration options for testing strategies, including scenario generation, detection of stalled execution, verification, and others.
How to enable options
To enable an option for a testing strategy, set it in the strategy class:
Scenario minimization
By default, Lincheck tries to minimize the failed scenario by removing the operations that do not change the behavior of the test.
Set the minimizeFailedScenario option to false to see the full failed scenario.
Scenario generation
Option | Default value | Description |
|---|---|---|
|
| The number of generated concurrent scenarios. |
|
| The number of invocations for each concurrent scenario. |
|
| The number of threads in each scenario. |
|
| The number of operations called before the parallel section of a scenario. |
|
| The number of operations in each thread in the parallel section of a scenario. |
|
| The number of operations called after the parallel section of a scenario. |
| – | A list of custom concurrent scenarios. The custom scenarios are executed before the randomly generated ones. |
Defining a custom scenario
Lincheck uses a domain-specific language for defining custom scenarios:
Each scenario consists of three optional sections:
initial– operations executed before the parallel part.parallel– thread definitions. Threads are defined using thethreadblock. The parallel section might contain multiplethreadblocks.post– operations executed after the parallel part.
Operations are defined using the actor(function, arg1, arg2, ...) function. Operations within a single block are executed sequentially.
Stalled execution detection
Option | Default value | Description |
|---|---|---|
|
| Invocation timeout in milliseconds after which Lincheck reports a stalled execution. |
|
| The number of loop iterations after which Lincheck reports a stalled execution. |
|
| The number of recursive calls after which Lincheck reports a stalled execution. |
Thread switching in loops
Option | Default value | Description |
|---|---|---|
|
| The number of loop iterations a thread can perform before trying to switch to another thread. |
Verification
Option | Default value | Description |
|---|---|---|
|
| The verifier class used during the verification process:
|
| Same as the tested data structure. | The sequential version of the tested data structure. This structure is used during the verification process. |
Progress guarantees
Option | Default value | Description |
|---|---|---|
|
| Set this option to |
Library analysis
Option | Default value | Description |
|---|---|---|
|
| By default, Lincheck does not verify the behavior of the operations from the standard library, treating them as thread-safe. Set this option to |
| – | Define guarantees for thread-safe or irrelevant to analysis methods using the |
Defining a guarantee
To define a guarantee, use a builder chain: select classes, then methods, then the guarantee type.
Select classes using one of the
forClassesoverloads:forClasses(vararg fullClassNames: String)— matches classes if their full name is present in thefullClassNamesstring.forClasses(vararg classes: KClass<*>)— matches classes by reference.forClasses(classPredicate: (fullClassName: String) -> Boolean)— match classes using a predicate on full class names.
Select methods to apply the guarantee to:
methods(methodNames: String)– matches methods if their name is present in themethodNamesstring.methods(methodPredicate: (methodName: String) -> Boolean)– matches methods using a predicate.allMethods()– match all methods of the selected classes.
Choose the guarantee type:
treatAsAtomic()— treat each method as an atomic operation. Lincheck will not insert switch points inside the method call, but might add them before or after the call.Use
treatAsAtomic()for methods that are known to be thread-safe.ignore()— exclude the methods from analysis. Lincheck will not insert switch points inside, before, or after the method calls.Use
ignore()for methods that are irrelevant to analysis, such as logging or debugging utilities.
What’s next
Learn how to configure argument generation for operations used in Lincheck's execution scenarios.