-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
partly rollback old API (not compiling)
Signed-off-by: Evgenii Moiseenko <[email protected]>
- Loading branch information
Showing
16 changed files
with
675 additions
and
330 deletions.
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
src/jvm/main/org/jetbrains/kotlinx/lincheck/CTestConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*- | ||
* #%L | ||
* Lincheck | ||
* %% | ||
* Copyright (C) 2019 - 2020 JetBrains s.r.o. | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.jetbrains.kotlinx.lincheck | ||
|
||
import org.jetbrains.kotlinx.lincheck.execution.* | ||
import org.jetbrains.kotlinx.lincheck.strategy.* | ||
import org.jetbrains.kotlinx.lincheck.strategy.managed.* | ||
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* | ||
import org.jetbrains.kotlinx.lincheck.strategy.stress.* | ||
import org.jetbrains.kotlinx.lincheck.verifier.* | ||
import org.jetbrains.kotlinx.lincheck.verifier.linearizability.* | ||
import java.lang.reflect.* | ||
|
||
/** | ||
* Abstract configuration for different lincheck modes. | ||
*/ | ||
@Deprecated( | ||
message="Please use class LincheckOptions instead, which implements automated strategy selection", | ||
level=DeprecationLevel.ERROR, | ||
) | ||
abstract class CTestConfiguration( | ||
val testClass: Class<*>, | ||
val iterations: Int, | ||
val threads: Int, | ||
val actorsPerThread: Int, | ||
val actorsBefore: Int, | ||
val actorsAfter: Int, | ||
val generatorClass: Class<out ExecutionGenerator>, | ||
val verifierClass: Class<out Verifier>, | ||
val requireStateEquivalenceImplCheck: Boolean, | ||
val minimizeFailedScenario: Boolean, | ||
val sequentialSpecification: Class<*>, | ||
val timeoutMs: Long, | ||
val customScenarios: List<ExecutionScenario>, | ||
val invocationsPerIteration: Int = DEFAULT_INVOCATIONS, | ||
) { | ||
abstract fun createStrategy(testClass: Class<*>, scenario: ExecutionScenario, | ||
validationFunctions: List<Method>, stateRepresentationMethod: Method?): Strategy | ||
|
||
companion object { | ||
const val DEFAULT_ITERATIONS = 100 | ||
const val DEFAULT_INVOCATIONS = 10000 | ||
const val DEFAULT_THREADS = 2 | ||
const val DEFAULT_ACTORS_PER_THREAD = 5 | ||
const val DEFAULT_ACTORS_BEFORE = 5 | ||
const val DEFAULT_ACTORS_AFTER = 5 | ||
val DEFAULT_EXECUTION_GENERATOR: Class<out ExecutionGenerator?> = RandomExecutionGenerator::class.java | ||
val DEFAULT_VERIFIER: Class<out Verifier> = LinearizabilityVerifier::class.java | ||
const val DEFAULT_MINIMIZE_ERROR = true | ||
const val DEFAULT_TIMEOUT_MS: Long = 10000 | ||
} | ||
} | ||
|
||
@Suppress("DEPRECATION_ERROR") | ||
internal fun createFromTestClassAnnotations(testClass: Class<*>): List<CTestConfiguration> { | ||
val stressConfigurations: List<CTestConfiguration> = testClass.getAnnotationsByType(StressCTest::class.java) | ||
.map { ann: StressCTest -> | ||
StressCTestConfiguration(testClass, ann.iterations, | ||
ann.threads, ann.actorsPerThread, ann.actorsBefore, ann.actorsAfter, | ||
ann.generator.java, ann.verifier.java, ann.invocationsPerIteration, | ||
ann.requireStateEquivalenceImplCheck, ann.minimizeFailedScenario, | ||
chooseSequentialSpecification(ann.sequentialSpecification.java, testClass), | ||
CTestConfiguration.DEFAULT_TIMEOUT_MS, | ||
emptyList() | ||
) | ||
} | ||
val modelCheckingConfigurations: List<CTestConfiguration> = testClass.getAnnotationsByType(ModelCheckingCTest::class.java) | ||
.map { ann: ModelCheckingCTest -> | ||
ModelCheckingCTestConfiguration(testClass, ann.iterations, | ||
ann.threads, ann.actorsPerThread, ann.actorsBefore, ann.actorsAfter, | ||
ann.generator.java, ann.verifier.java, ann.checkObstructionFreedom, ann.hangingDetectionThreshold, | ||
ann.invocationsPerIteration, ManagedCTestConfiguration.DEFAULT_GUARANTEES, ann.requireStateEquivalenceImplCheck, | ||
ann.minimizeFailedScenario, chooseSequentialSpecification(ann.sequentialSpecification.java, testClass), | ||
CTestConfiguration.DEFAULT_TIMEOUT_MS, | ||
ManagedCTestConfiguration.DEFAULT_ELIMINATE_LOCAL_OBJECTS, | ||
ManagedCTestConfiguration.DEFAULT_VERBOSE_TRACE, | ||
emptyList() | ||
) | ||
} | ||
return stressConfigurations + modelCheckingConfigurations | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.