[K/N][Tests] Migrate test override_konan_properties0 and add testDriverVersion
^KT-61259
This commit is contained in:
committed by
Space Team
parent
9ef051dbc5
commit
fbe8db4b45
@@ -1695,26 +1695,6 @@ standaloneTest("split_compilation_pipeline") {
|
|||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("override_konan_properties0", KonanDriverTest) {
|
|
||||||
disabled = isAggressiveGC // No need to test with different GC schedulers
|
|
||||||
def overrides = PlatformInfo.isWindows()
|
|
||||||
? '-Xoverride-konan-properties="llvmInlineThreshold=76"'
|
|
||||||
: '-Xoverride-konan-properties=llvmInlineThreshold=76'
|
|
||||||
flags = [
|
|
||||||
"-opt",
|
|
||||||
"-Xverbose-phases=MandatoryBitcodeLLVMPostprocessingPhase",
|
|
||||||
overrides
|
|
||||||
]
|
|
||||||
compilerMessages = true
|
|
||||||
source = "link/ir_providers/hello.kt"
|
|
||||||
def messages = "inline_threshold: 76\nhello\n"
|
|
||||||
outputChecker = { out ->
|
|
||||||
messages.split("\n")
|
|
||||||
.collect { line -> out.contains(line) }
|
|
||||||
.every { it == true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds tests into a single binary with TestRunner
|
* Builds tests into a single binary with TestRunner
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
||||||
* that can be found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO: remove kotlin_native.io once overrides are in place.
|
|
||||||
fun main(args : Array<String>) {
|
|
||||||
println("Hello, world!")
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Hello, world!
|
|
||||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.konan.test.blackbox.support.TestCompilerArgs
|
|||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.TestModule
|
import org.jetbrains.kotlin.konan.test.blackbox.support.TestModule
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.ExecutableCompilation
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact
|
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.executor
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Binaries
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.Binaries
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.GCScheduler
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.GCScheduler
|
||||||
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeHome
|
import org.jetbrains.kotlin.konan.test.blackbox.support.settings.KotlinNativeHome
|
||||||
@@ -43,14 +44,29 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testLLVMVariantDev() {
|
fun testLLVMVariantDev() {
|
||||||
// We use clang from Xcode on macOS for apple targets,
|
// On macOS for apple targets, clang++ from Xcode is used, which is not switchable as `dev/user`,
|
||||||
// so it is hard to reliably detect LLVM variant for these targets.
|
// so the test cannot detect LLVM variant for apple targets on macOS host.
|
||||||
Assumptions.assumeFalse(targets.hostTarget.family.isAppleFamily && targets.testTarget.family.isAppleFamily)
|
Assumptions.assumeFalse(targets.hostTarget.family.isAppleFamily && targets.testTarget.family.isAppleFamily)
|
||||||
// No need to test with different GC schedulers
|
// No need to test with different GC schedulers
|
||||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||||
|
|
||||||
val flags = listOf("-Xllvm-variant=dev", "-Xverbose-phases=ObjectFiles")
|
compileSimpleFile(listOf("-Xllvm-variant=dev", "-Xverbose-phases=ObjectFiles")).let {
|
||||||
val args = mutableListOf("-output", buildDir.resolve("kexe.kexe").absolutePath).apply {
|
assertFalse(
|
||||||
|
it.stdout.contains("-essentials"),
|
||||||
|
"`-essentials` must not be in stdout of dev LLVM.\nSTDOUT: ${it.stdout}\nSTDERR: ${it.stderr}\n---"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
compileSimpleFile(listOf("-Xllvm-variant=user", "-Xverbose-phases=ObjectFiles")).let {
|
||||||
|
assertTrue(
|
||||||
|
it.stdout.contains("-essentials"),
|
||||||
|
"`-essentials` must be in stdout of user LLVM.\nSTDOUT: ${it.stdout}\nSTDERR: ${it.stderr}\n---"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileSimpleFile(flags: List<String>): RunProcessResult {
|
||||||
|
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||||
|
val args = mutableListOf("-output", kexe.absolutePath).apply {
|
||||||
add("-target")
|
add("-target")
|
||||||
add(targets.testTarget.visibleName)
|
add(targets.testTarget.visibleName)
|
||||||
addAll(flags)
|
addAll(flags)
|
||||||
@@ -59,22 +75,17 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
|
|||||||
add("-Xpartial-linkage-loglevel=error")
|
add("-Xpartial-linkage-loglevel=error")
|
||||||
}
|
}
|
||||||
|
|
||||||
val compilationResult: RunProcessResult = runProcess(konanc.absolutePath, source.absolutePath, *args.toTypedArray()) {
|
val compilationResult = runProcess(konanc.absolutePath, source.absolutePath, *args.toTypedArray<String>()) {
|
||||||
timeout = Duration.parse("5m")
|
timeout = Duration.parse("5m")
|
||||||
}
|
}
|
||||||
assertFalse(
|
testRunSettings.executor.runProcess(kexe.absolutePath) // run generated executable just to check its sanity
|
||||||
compilationResult.stdout.contains("-essentials"),
|
return compilationResult
|
||||||
"`-essentials` must not be in stdout of dev LLVM.\nSTDOUT: ${compilationResult.stdout}\nSTDERR: ${compilationResult.stderr}\n---"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDriverProducesRunnableBinaries() {
|
fun testDriverProducesRunnableBinaries() {
|
||||||
// No need to test with different GC schedulers
|
|
||||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
|
||||||
|
|
||||||
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||||
val kexe = buildDir.resolve("kexe.kexe")
|
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||||
val compilation = ExecutableCompilation(
|
val compilation = ExecutableCompilation(
|
||||||
settings = testRunSettings,
|
settings = testRunSettings,
|
||||||
freeCompilerArgs = TestCompilerArgs.EMPTY,
|
freeCompilerArgs = TestCompilerArgs.EMPTY,
|
||||||
@@ -87,19 +98,43 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
|
|||||||
runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
||||||
timeout = Duration.parse("5m")
|
timeout = Duration.parse("5m")
|
||||||
}
|
}
|
||||||
val runResult: RunProcessResult = runProcess(kexe.absolutePath) {
|
val runResult: RunProcessResult = with(testRunSettings) {
|
||||||
timeout = Duration.parse("5m")
|
executor.runProcess(kexe.absolutePath) {
|
||||||
|
timeout = Duration.parse("1m")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertEquals("Hello, world!", runResult.stdout)
|
assertEquals("Hello, world!", runResult.stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testDriverVersion() {
|
||||||
|
// No need to test with different GC schedulers
|
||||||
|
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||||
|
|
||||||
|
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||||
|
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||||
|
val compilation = ExecutableCompilation(
|
||||||
|
settings = testRunSettings,
|
||||||
|
freeCompilerArgs = TestCompilerArgs(listOf("-version")),
|
||||||
|
sourceModules = listOf(module),
|
||||||
|
extras = TestCase.NoTestRunnerExtras("main"),
|
||||||
|
dependencies = emptyList(),
|
||||||
|
expectedArtifact = TestCompilationArtifact.Executable(kexe),
|
||||||
|
tryPassSystemCacheDirectory = true
|
||||||
|
)
|
||||||
|
runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
|
||||||
|
timeout = Duration.parse("5m")
|
||||||
|
}
|
||||||
|
assertFalse(kexe.exists())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOverrideKonanProperties() {
|
fun testOverrideKonanProperties() {
|
||||||
// No need to test with different GC schedulers
|
// No need to test with different GC schedulers
|
||||||
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
|
||||||
|
|
||||||
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
val module = TestModule.Exclusive("moduleName", emptySet(), emptySet(), emptySet())
|
||||||
val kexe = buildDir.resolve("kexe.kexe")
|
val kexe = buildDir.resolve("kexe.kexe").also { it.delete() }
|
||||||
val compilation = ExecutableCompilation(
|
val compilation = ExecutableCompilation(
|
||||||
settings = testRunSettings,
|
settings = testRunSettings,
|
||||||
freeCompilerArgs = TestCompilerArgs(
|
freeCompilerArgs = TestCompilerArgs(
|
||||||
@@ -125,5 +160,6 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
|
|||||||
"Compiler's stdout must contain string: $expected\n" +
|
"Compiler's stdout must contain string: $expected\n" +
|
||||||
"STDOUT:\n${compilationResult.stdout}\nSTDERR:${compilationResult.stderr}"
|
"STDOUT:\n${compilationResult.stdout}\nSTDERR:${compilationResult.stderr}"
|
||||||
)
|
)
|
||||||
|
testRunSettings.executor.runProcess(kexe.absolutePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user