Revert "[K/N][Tests] Migrate test override_konan_properties0"

This reverts commit 9ef051dbc5.
This commit is contained in:
Alexander Shabalin
2024-02-21 23:41:15 +01:00
committed by Space Team
parent 8518c3f54f
commit 4765cfda53
6 changed files with 30 additions and 81 deletions
@@ -912,6 +912,21 @@ standaloneTest("testing_stacktrace") {
}
}
// Just check that the driver is able to produce runnable binaries.
tasks.register("driver0", KonanDriverTest) {
disabled = isAggressiveGC // No need to test with different GC schedulers
useGoldenData = true
source = "runtime/basic/driver0.kt"
}
tasks.register("driver_opt", KonanDriverTest) {
disabled = (cacheTesting != null) // Cache is not compatible with -opt.
|| isAggressiveGC // No need to test with different GC schedulers
useGoldenData = true
source = "runtime/basic/driver_opt.kt"
flags = ["-opt"]
}
// A helper method to create interop artifacts
void createInterop(String name, Closure conf) {
konanArtifacts {
@@ -0,0 +1 @@
Hello, world!
+1
View File
@@ -0,0 +1 @@
fun main() = println("hello")
@@ -9,11 +9,6 @@ import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.konan.test.blackbox.AbstractNativeSimpleTest
import org.jetbrains.kotlin.konan.test.blackbox.support.NativeSimpleTestSupport
import org.jetbrains.kotlin.konan.test.blackbox.support.TestCase
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.compilation.ExecutableCompilation
import org.jetbrains.kotlin.konan.test.blackbox.support.compilation.TestCompilationArtifact
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.KotlinNativeHome
@@ -26,8 +21,6 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
import java.io.File
import kotlin.test.assertFalse
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlin.time.Duration
@Tag("driver")
@@ -39,16 +32,16 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
private val konanc get() = konanHome.resolve("bin").resolve(if (HostManager.hostIsMingw) "konanc.bat" else "konanc")
private val testSuiteDir = File("native/native.tests/testData/driver")
private val source = testSuiteDir.resolve("driver0.kt")
@Test
fun testLLVMVariantDev() {
// We use clang from Xcode on macOS for apple targets,
// so it is hard to reliably detect LLVM variant for these targets.
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
Assumptions.assumeFalse(testRunSettings.get<GCScheduler>() == GCScheduler.AGGRESSIVE)
val source = testSuiteDir.resolve("hello.kt")
val flags = listOf("-Xllvm-variant=dev", "-Xverbose-phases=ObjectFiles")
val args = mutableListOf("-output", buildDir.resolve("kexe.kexe").absolutePath).apply {
add("-target")
@@ -59,71 +52,12 @@ class KonanDriverTest : AbstractNativeSimpleTest() {
add("-Xpartial-linkage-loglevel=error")
}
val compilationResult: RunProcessResult = runProcess(konanc.absolutePath, source.absolutePath, *args.toTypedArray()) {
val result: RunProcessResult = runProcess(konanc.absolutePath, source.absolutePath, *args.toTypedArray()) {
timeout = Duration.parse("5m")
}
assertFalse(
compilationResult.stdout.contains("-essentials"),
"`-essentials` must not be in stdout of dev LLVM.\nSTDOUT: ${compilationResult.stdout}\nSTDERR: ${compilationResult.stderr}\n---"
)
}
@Test
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 kexe = buildDir.resolve("kexe.kexe")
val compilation = ExecutableCompilation(
settings = testRunSettings,
freeCompilerArgs = TestCompilerArgs.EMPTY,
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")
}
val runResult: RunProcessResult = runProcess(kexe.absolutePath) {
timeout = Duration.parse("5m")
}
assertEquals("Hello, world!", runResult.stdout)
}
@Test
fun testOverrideKonanProperties() {
// 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")
val compilation = ExecutableCompilation(
settings = testRunSettings,
freeCompilerArgs = TestCompilerArgs(
listOf(
"-opt",
"-Xverbose-phases=MandatoryBitcodeLLVMPostprocessingPhase",
if (HostManager.hostIsMingw)
"-Xoverride-konan-properties=\"llvmInlineThreshold=76\""
else "-Xoverride-konan-properties=llvmInlineThreshold=76"
)),
sourceModules = listOf(module),
extras = TestCase.NoTestRunnerExtras("main"),
dependencies = emptyList(),
expectedArtifact = TestCompilationArtifact.Executable(kexe),
tryPassSystemCacheDirectory = true
)
val compilationResult = runProcess(konanc.absolutePath, source.absolutePath, *compilation.getCompilerArgs()) {
timeout = Duration.parse("5m")
}
val expected = "inline_threshold: 76"
assertTrue(
compilationResult.stdout.contains(expected),
"Compiler's stdout must contain string: $expected\n" +
"STDOUT:\n${compilationResult.stdout}\nSTDERR:${compilationResult.stderr}"
result.stdout.contains("-essentials"),
"`-essentials` must not be in stdout of dev LLVM.\nSTDOUT: ${result.stdout}\nSTDERR: ${result.stderr}\n---"
)
}
}
@@ -125,7 +125,14 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
protected open fun postCompileCheck() = Unit
private fun doCompile(): TestCompilationResult.ImmediateResult<out A> {
val compilerArgs = getCompilerArgs()
val compilerArgs = buildArgs {
applyCommonArgs()
applySpecificArgs(this)
applyDependencies(this)
applyFreeArgs()
applyCompilerPlugins()
applySources()
}
val loggedCompilerInput = LoggedData.CompilerInput(sourceModules)
val loggedCompilerParameters = LoggedData.CompilerParameters(home, compilerArgs)
@@ -173,15 +180,6 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
return result
}
fun getCompilerArgs() = buildArgs {
applyCommonArgs()
applySpecificArgs(this)
applyDependencies(this)
applyFreeArgs()
applyCompilerPlugins()
applySources()
}
}
internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(