[Native][tests] Gradle property: GCType
This commit is contained in:
@@ -51,6 +51,7 @@ enum class TestProperty(shortName: String) {
|
|||||||
OPTIMIZATION_MODE("optimizationMode"),
|
OPTIMIZATION_MODE("optimizationMode"),
|
||||||
MEMORY_MODEL("memoryModel"),
|
MEMORY_MODEL("memoryModel"),
|
||||||
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
USE_THREAD_STATE_CHECKER("useThreadStateChecker"),
|
||||||
|
GC_TYPE("gcType"),
|
||||||
USE_CACHE("useCache"),
|
USE_CACHE("useCache"),
|
||||||
EXECUTION_TIMEOUT("executionTimeout");
|
EXECUTION_TIMEOUT("executionTimeout");
|
||||||
|
|
||||||
|
|||||||
+11
@@ -64,6 +64,13 @@ class NativeBlackBoxTestSupport : BeforeEachCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val gcType = computeGCType()
|
||||||
|
if (gcType != GCType.UNSPECIFIED) {
|
||||||
|
assertEquals(MemoryModel.EXPERIMENTAL, memoryModel) {
|
||||||
|
"GC type can be specified only with experimental memory model"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return root.getStore(NAMESPACE).getOrComputeIfAbsent(TestProcessSettings::class.java.name) {
|
return root.getStore(NAMESPACE).getOrComputeIfAbsent(TestProcessSettings::class.java.name) {
|
||||||
TestProcessSettings(
|
TestProcessSettings(
|
||||||
computeNativeTargets(),
|
computeNativeTargets(),
|
||||||
@@ -73,6 +80,7 @@ class NativeBlackBoxTestSupport : BeforeEachCallback {
|
|||||||
optimizationMode,
|
optimizationMode,
|
||||||
memoryModel,
|
memoryModel,
|
||||||
threadStateChecker,
|
threadStateChecker,
|
||||||
|
gcType,
|
||||||
CacheKind::class to computeCacheKind(),
|
CacheKind::class to computeCacheKind(),
|
||||||
computeBaseDirs(),
|
computeBaseDirs(),
|
||||||
computeTimeouts()
|
computeTimeouts()
|
||||||
@@ -111,6 +119,8 @@ class NativeBlackBoxTestSupport : BeforeEachCallback {
|
|||||||
return if (useThreadStateChecker) ThreadStateChecker.ENABLED else ThreadStateChecker.DISABLED
|
return if (useThreadStateChecker) ThreadStateChecker.ENABLED else ThreadStateChecker.DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun computeGCType(): GCType = enumSystemProperty(GC_TYPE, GCType.values(), default = GCType.UNSPECIFIED)
|
||||||
|
|
||||||
private fun computeCacheKind(): CacheKind {
|
private fun computeCacheKind(): CacheKind {
|
||||||
val useCache = systemProperty(USE_CACHE, String::toBooleanStrictOrNull, default = true)
|
val useCache = systemProperty(USE_CACHE, String::toBooleanStrictOrNull, default = true)
|
||||||
return if (useCache) CacheKind.WithStaticCache else CacheKind.WithoutCache
|
return if (useCache) CacheKind.WithStaticCache else CacheKind.WithoutCache
|
||||||
@@ -159,6 +169,7 @@ class NativeBlackBoxTestSupport : BeforeEachCallback {
|
|||||||
private const val OPTIMIZATION_MODE = "kotlin.internal.native.test.optimizationMode"
|
private const val OPTIMIZATION_MODE = "kotlin.internal.native.test.optimizationMode"
|
||||||
private const val MEMORY_MODEL = "kotlin.internal.native.test.memoryModel"
|
private const val MEMORY_MODEL = "kotlin.internal.native.test.memoryModel"
|
||||||
private const val USE_THREAD_STATE_CHECKER = "kotlin.internal.native.test.useThreadStateChecker"
|
private const val USE_THREAD_STATE_CHECKER = "kotlin.internal.native.test.useThreadStateChecker"
|
||||||
|
private const val GC_TYPE = "kotlin.internal.native.test.gcType"
|
||||||
private const val USE_CACHE = "kotlin.internal.native.test.useCache"
|
private const val USE_CACHE = "kotlin.internal.native.test.useCache"
|
||||||
private const val EXECUTION_TIMEOUT = "kotlin.internal.native.test.executionTimeout"
|
private const val EXECUTION_TIMEOUT = "kotlin.internal.native.test.executionTimeout"
|
||||||
private const val PROJECT_BUILD_DIR = "PROJECT_BUILD_DIR"
|
private const val PROJECT_BUILD_DIR = "PROJECT_BUILD_DIR"
|
||||||
|
|||||||
+4
@@ -53,6 +53,7 @@ internal class TestCompilationFactory {
|
|||||||
optimizationMode = settings.get(),
|
optimizationMode = settings.get(),
|
||||||
memoryModel = settings.get(),
|
memoryModel = settings.get(),
|
||||||
threadStateChecker = settings.get(),
|
threadStateChecker = settings.get(),
|
||||||
|
gcType = settings.get(),
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
sourceModules = rootModules,
|
sourceModules = rootModules,
|
||||||
dependencies = TestCompilationDependencies(libraries = libraries, friends = friends),
|
dependencies = TestCompilationDependencies(libraries = libraries, friends = friends),
|
||||||
@@ -97,6 +98,7 @@ internal class TestCompilationFactory {
|
|||||||
optimizationMode = settings.get(),
|
optimizationMode = settings.get(),
|
||||||
memoryModel = settings.get(),
|
memoryModel = settings.get(),
|
||||||
threadStateChecker = settings.get(),
|
threadStateChecker = settings.get(),
|
||||||
|
gcType = settings.get(),
|
||||||
freeCompilerArgs = freeCompilerArgs,
|
freeCompilerArgs = freeCompilerArgs,
|
||||||
sourceModules = sourceModules,
|
sourceModules = sourceModules,
|
||||||
dependencies = TestCompilationDependencies(libraries = libraries, friends = friends),
|
dependencies = TestCompilationDependencies(libraries = libraries, friends = friends),
|
||||||
@@ -248,6 +250,7 @@ private class TestCompilationImpl(
|
|||||||
private val optimizationMode: OptimizationMode,
|
private val optimizationMode: OptimizationMode,
|
||||||
private val memoryModel: MemoryModel,
|
private val memoryModel: MemoryModel,
|
||||||
private val threadStateChecker: ThreadStateChecker,
|
private val threadStateChecker: ThreadStateChecker,
|
||||||
|
private val gcType: GCType,
|
||||||
private val freeCompilerArgs: TestCompilerArgs,
|
private val freeCompilerArgs: TestCompilerArgs,
|
||||||
private val sourceModules: Collection<TestModule>,
|
private val sourceModules: Collection<TestModule>,
|
||||||
private val dependencies: TestCompilationDependencies,
|
private val dependencies: TestCompilationDependencies,
|
||||||
@@ -276,6 +279,7 @@ private class TestCompilationImpl(
|
|||||||
optimizationMode.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
|
optimizationMode.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
|
||||||
memoryModel.compilerFlags?.let { compilerFlags -> add(compilerFlags) }
|
memoryModel.compilerFlags?.let { compilerFlags -> add(compilerFlags) }
|
||||||
threadStateChecker.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
|
threadStateChecker.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
|
||||||
|
gcType.compilerFlag?.let { compilerFlag -> add(compilerFlag) }
|
||||||
|
|
||||||
addFlattened(dependencies.libraries) { library -> listOf("-l", library.resultingArtifactPath) }
|
addFlattened(dependencies.libraries) { library -> listOf("-l", library.resultingArtifactPath) }
|
||||||
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
dependencies.friends.takeIf(Collection<*>::isNotEmpty)?.let { friends ->
|
||||||
|
|||||||
+12
-1
@@ -104,7 +104,13 @@ internal class TestCompilerArgs(val compilerArgs: List<String>) {
|
|||||||
companion object {
|
companion object {
|
||||||
val EMPTY = TestCompilerArgs(emptyList())
|
val EMPTY = TestCompilerArgs(emptyList())
|
||||||
|
|
||||||
fun findForbiddenArgs(compilerArgs: Iterable<String>): Set<String> = compilerArgs intersect EXPLICITLY_FORBIDDEN_COMPILER_ARGS
|
fun findForbiddenArgs(compilerArgs: Iterable<String>): Set<String> = buildSet {
|
||||||
|
addAll(compilerArgs)
|
||||||
|
retainAll(EXPLICITLY_FORBIDDEN_COMPILER_ARGS)
|
||||||
|
compilerArgs.mapNotNullTo(this) { arg ->
|
||||||
|
if (EXPLICITLY_FORBIDDEN_COMPILER_ARG_PREFIXES.any { prefix -> arg.startsWith(prefix) }) arg else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The set of compiler args that are not permitted to be explicitly specified using [FREE_COMPILER_ARGS]. */
|
/** The set of compiler args that are not permitted to be explicitly specified using [FREE_COMPILER_ARGS]. */
|
||||||
private val EXPLICITLY_FORBIDDEN_COMPILER_ARGS = setOf(
|
private val EXPLICITLY_FORBIDDEN_COMPILER_ARGS = setOf(
|
||||||
@@ -122,6 +128,11 @@ internal class TestCompilerArgs(val compilerArgs: List<String>) {
|
|||||||
"-memory-model",
|
"-memory-model",
|
||||||
"-Xcheck-state-at-external-calls"
|
"-Xcheck-state-at-external-calls"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/** The set of compiler arg prefixes that are not permitted to be explicitly specified using [FREE_COMPILER_ARGS]. */
|
||||||
|
private val EXPLICITLY_FORBIDDEN_COMPILER_ARG_PREFIXES = setOf(
|
||||||
|
"-Xgc="
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
@@ -45,6 +45,9 @@ internal enum class TestMode(private val description: String) {
|
|||||||
override fun toString() = description
|
override fun toString() = description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimization mode to be applied.
|
||||||
|
*/
|
||||||
internal enum class OptimizationMode(private val description: String, val compilerFlag: String?) {
|
internal enum class OptimizationMode(private val description: String, val compilerFlag: String?) {
|
||||||
DEBUG("Build with debug information", "-g"),
|
DEBUG("Build with debug information", "-g"),
|
||||||
OPT("Build with optimizations applied", "-opt"),
|
OPT("Build with optimizations applied", "-opt"),
|
||||||
@@ -53,6 +56,9 @@ internal enum class OptimizationMode(private val description: String, val compil
|
|||||||
override fun toString() = description + compilerFlag?.let { " ($it)" }.orEmpty()
|
override fun toString() = description + compilerFlag?.let { " ($it)" }.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Kotlin/Native memoty model.
|
||||||
|
*/
|
||||||
internal enum class MemoryModel(val compilerFlags: List<String>?) {
|
internal enum class MemoryModel(val compilerFlags: List<String>?) {
|
||||||
DEFAULT(null),
|
DEFAULT(null),
|
||||||
EXPERIMENTAL(listOf("-memory-model", "experimental"));
|
EXPERIMENTAL(listOf("-memory-model", "experimental"));
|
||||||
@@ -60,6 +66,9 @@ internal enum class MemoryModel(val compilerFlags: List<String>?) {
|
|||||||
override fun toString() = compilerFlags?.joinToString(prefix = "(", separator = " ", postfix = ")").orEmpty()
|
override fun toString() = compilerFlags?.joinToString(prefix = "(", separator = " ", postfix = ")").orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread state checked. Can be applied only with [MemoryModel.EXPERIMENTAL] and [OptimizationMode.DEBUG].
|
||||||
|
*/
|
||||||
internal enum class ThreadStateChecker(val compilerFlag: String?) {
|
internal enum class ThreadStateChecker(val compilerFlag: String?) {
|
||||||
DISABLED(null),
|
DISABLED(null),
|
||||||
ENABLED("-Xcheck-state-at-external-calls");
|
ENABLED("-Xcheck-state-at-external-calls");
|
||||||
@@ -67,6 +76,17 @@ internal enum class ThreadStateChecker(val compilerFlag: String?) {
|
|||||||
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Garbage collector type. Can be applied only with [MemoryModel.EXPERIMENTAL].
|
||||||
|
*/
|
||||||
|
internal enum class GCType(val compilerFlag: String?) {
|
||||||
|
UNSPECIFIED(null),
|
||||||
|
NOOP("-Xgc=noop"),
|
||||||
|
STMS("-Xgc=stms");
|
||||||
|
|
||||||
|
override fun toString() = compilerFlag?.let { "($it)" }.orEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current project's directories.
|
* Current project's directories.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user