[K/N] Migrate some cinterop tests to new test infra
This commit is contained in:
committed by
Space Team
parent
22b2c1a587
commit
c5248fc5f4
@@ -3372,18 +3372,6 @@ createInterop("sockets") {
|
|||||||
it.defFile 'interop/basics/sockets.def'
|
it.defFile 'interop/basics/sockets.def'
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("bitfields") {
|
|
||||||
it.defFile 'interop/basics/bitfields.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("cglobals") {
|
|
||||||
it.defFile 'interop/basics/cglobals.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("cfunptr") {
|
|
||||||
it.defFile 'interop/basics/cfunptr.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("cmacros") {
|
createInterop("cmacros") {
|
||||||
it.defFile 'interop/basics/cmacros.def'
|
it.defFile 'interop/basics/cmacros.def'
|
||||||
}
|
}
|
||||||
@@ -3392,10 +3380,6 @@ createInterop("cunsupported") {
|
|||||||
it.defFile 'interop/basics/cunsupported.def'
|
it.defFile 'interop/basics/cunsupported.def'
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("ctoKString") {
|
|
||||||
it.defFile 'interop/basics/ctoKString.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("ctypes") {
|
createInterop("ctypes") {
|
||||||
it.defFile 'interop/basics/ctypes.def'
|
it.defFile 'interop/basics/ctypes.def'
|
||||||
}
|
}
|
||||||
@@ -3416,10 +3400,6 @@ createInterop("cstructs") {
|
|||||||
it.defFile 'interop/basics/cstructs.def'
|
it.defFile 'interop/basics/cstructs.def'
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("ccallbacksAndVarargs") {
|
|
||||||
it.defFile 'interop/basics/ccallbacksAndVarargs.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("cmangling") {
|
createInterop("cmangling") {
|
||||||
it.defFile 'interop/basics/mangling.def'
|
it.defFile 'interop/basics/mangling.def'
|
||||||
}
|
}
|
||||||
@@ -3440,22 +3420,6 @@ createInterop("cunion") {
|
|||||||
it.defFile 'interop/basics/cunion.def'
|
it.defFile 'interop/basics/cunion.def'
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("cenums") {
|
|
||||||
it.defFile 'interop/basics/cenums.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("carrayPointers") {
|
|
||||||
it.defFile 'interop/basics/carrayPointers.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("auxiliaryCppSources") {
|
|
||||||
// We need to provide empty def file to create correct `KonanInteropTask`.
|
|
||||||
it.defFile 'interop/auxiliary_sources/auxiliaryCppSources.def'
|
|
||||||
it.headers "$projectDir/interop/auxiliary_sources/name.h"
|
|
||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/auxiliary_sources/name.cpp"
|
|
||||||
it.extraOpts "-Xsource-compiler-option", "-std=c++17"
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("concurrentTerminate") {
|
createInterop("concurrentTerminate") {
|
||||||
it.defFile 'interop/concurrentTerminate/concurrentTerminate.def'
|
it.defFile 'interop/concurrentTerminate/concurrentTerminate.def'
|
||||||
it.headers "$projectDir/interop/concurrentTerminate/async.h"
|
it.headers "$projectDir/interop/concurrentTerminate/async.h"
|
||||||
@@ -3464,12 +3428,6 @@ createInterop("concurrentTerminate") {
|
|||||||
it.extraOpts "-Xsource-compiler-option", "-std=c++17"
|
it.extraOpts "-Xsource-compiler-option", "-std=c++17"
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("incomplete_types") {
|
|
||||||
it.defFile 'interop/incomplete_types/library.def'
|
|
||||||
it.headers "$projectDir/interop/incomplete_types/library.h"
|
|
||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/incomplete_types/library.cpp"
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("embedStaticLibraries") {
|
createInterop("embedStaticLibraries") {
|
||||||
it.defFile 'interop/embedStaticLibraries/embedStaticLibraries.def'
|
it.defFile 'interop/embedStaticLibraries/embedStaticLibraries.def'
|
||||||
it.headers "$projectDir/interop/embedStaticLibraries/embedStaticLibraries.h"
|
it.headers "$projectDir/interop/embedStaticLibraries/embedStaticLibraries.h"
|
||||||
@@ -3494,27 +3452,10 @@ createInterop("embedStaticLibraries") {
|
|||||||
it.extraOpts '-staticLibrary', "2.a"
|
it.extraOpts '-staticLibrary', "2.a"
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("kt43265") {
|
|
||||||
it.defFile 'interop/kt43265/kt43265.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("kt44283") {
|
|
||||||
it.defFile 'interop/kt44283/kt44283.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("kt51925") {
|
createInterop("kt51925") {
|
||||||
it.defFile 'interop/kt51925/kt51925.def'
|
it.defFile 'interop/kt51925/kt51925.def'
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("kt54284") {
|
|
||||||
it.defFile 'interop/kt54284/kt54284.def'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("kt54284_fmodules") {
|
|
||||||
it.defFile 'interop/kt54284/kt54284.def'
|
|
||||||
it.extraOpts '-compiler-option', '-fmodules'
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("kt43502") {
|
createInterop("kt43502") {
|
||||||
it.defFile 'interop/kt43502/kt43502.def'
|
it.defFile 'interop/kt43502/kt43502.def'
|
||||||
it.headers "$projectDir/interop/kt43502/kt43502.h"
|
it.headers "$projectDir/interop/kt43502/kt43502.h"
|
||||||
@@ -3566,10 +3507,6 @@ createInterop("workerSignals") {
|
|||||||
it.extraOpts "-Xcompile-source", "$projectDir/interop/workerSignals/workerSignals.cpp"
|
it.extraOpts "-Xcompile-source", "$projectDir/interop/workerSignals/workerSignals.cpp"
|
||||||
}
|
}
|
||||||
|
|
||||||
createInterop("cForwardDeclarations") {
|
|
||||||
it.defFile "interop/forwardDeclarations/cForwardDeclarations.def"
|
|
||||||
}
|
|
||||||
|
|
||||||
createInterop("cForwardDeclarationsTwoLibs1") {
|
createInterop("cForwardDeclarationsTwoLibs1") {
|
||||||
it.defFile "interop/forwardDeclarationsTwoLibs/cForwardDeclarationsTwoLibs1.def"
|
it.defFile "interop/forwardDeclarationsTwoLibs/cForwardDeclarationsTwoLibs1.def"
|
||||||
}
|
}
|
||||||
@@ -3836,23 +3773,6 @@ standaloneTest("interop5") {
|
|||||||
UtilsKt.dependsOnPlatformLibs(it)
|
UtilsKt.dependsOnPlatformLibs(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_bitfields") {
|
|
||||||
disabled = isAggressiveGC // TODO: Investigate why too slow
|
|
||||||
source = "interop/basics/bf.kt"
|
|
||||||
interop = 'bitfields'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_funptr") {
|
|
||||||
useGoldenData = true
|
|
||||||
source = "interop/basics/funptr.kt"
|
|
||||||
interop = 'cfunptr'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_globals") {
|
|
||||||
source = "interop/basics/globals.kt"
|
|
||||||
interop = 'cglobals'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_macros") {
|
interopTest("interop_macros") {
|
||||||
source = "interop/basics/macros.kt"
|
source = "interop/basics/macros.kt"
|
||||||
interop = 'cmacros'
|
interop = 'cmacros'
|
||||||
@@ -3863,11 +3783,6 @@ interopTest("interop_unsupported") {
|
|||||||
interop = 'cunsupported'
|
interop = 'cunsupported'
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_toKString") {
|
|
||||||
source = "interop/basics/toKString.kt"
|
|
||||||
interop = 'ctoKString'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_types") {
|
interopTest("interop_types") {
|
||||||
source = "interop/basics/types.kt"
|
source = "interop/basics/types.kt"
|
||||||
interop = 'ctypes'
|
interop = 'ctypes'
|
||||||
@@ -3903,11 +3818,6 @@ interopTest("interop_mangling_keywords2") {
|
|||||||
interop = 'cmangling_keywords2'
|
interop = 'cmangling_keywords2'
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_auxiliarySources") {
|
|
||||||
source = "interop/auxiliary_sources/main.kt"
|
|
||||||
interop = 'auxiliaryCppSources'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_concurrentTerminate") {
|
interopTest("interop_concurrentTerminate") {
|
||||||
source = "interop/concurrentTerminate/main.kt"
|
source = "interop/concurrentTerminate/main.kt"
|
||||||
interop = 'concurrentTerminate'
|
interop = 'concurrentTerminate'
|
||||||
@@ -3915,11 +3825,6 @@ interopTest("interop_concurrentTerminate") {
|
|||||||
expectedExitStatus = 99
|
expectedExitStatus = 99
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_incompleteTypes") {
|
|
||||||
source = "interop/incomplete_types/main.kt"
|
|
||||||
interop = 'incomplete_types'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_embedStaticLibraries") {
|
interopTest("interop_embedStaticLibraries") {
|
||||||
source = "interop/embedStaticLibraries/main.kt"
|
source = "interop/embedStaticLibraries/main.kt"
|
||||||
interop = 'embedStaticLibraries'
|
interop = 'embedStaticLibraries'
|
||||||
@@ -3935,11 +3840,6 @@ interopTest("interop_structs") {
|
|||||||
interop = 'cstructs'
|
interop = 'cstructs'
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_callbacksAndVarargs") {
|
|
||||||
source = "interop/basics/callbacksAndVarargs.kt"
|
|
||||||
interop = 'ccallbacksAndVarargs'
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_threadStates") {
|
interopTest("interop_threadStates") {
|
||||||
source = "interop/threadStates/threadStates.kt"
|
source = "interop/threadStates/threadStates.kt"
|
||||||
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||||
@@ -3982,39 +3882,6 @@ interopTest("interop_union") {
|
|||||||
source = "interop/basics/union.kt"
|
source = "interop/basics/union.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_enums") {
|
|
||||||
interop = 'cenums'
|
|
||||||
flags = ['-XXLanguage:+EnumEntries']
|
|
||||||
source = "interop/basics/enums.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_array_pointers") {
|
|
||||||
interop = 'carrayPointers'
|
|
||||||
source = "interop/basics/arrayPointers.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_kt43265") {
|
|
||||||
interop = 'kt43265'
|
|
||||||
source = "interop/kt43265/usage.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_kt44283") {
|
|
||||||
disabled = project.globalTestArgs.contains('-opt') // Incompatible with -g.
|
|
||||||
flags = ['-g']
|
|
||||||
interop = 'kt44283'
|
|
||||||
source = "interop/kt44283/main.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_kt54284") {
|
|
||||||
interop = 'kt54284'
|
|
||||||
source = "interop/kt54284/main.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_kt54284_fmodules") {
|
|
||||||
interop = 'kt54284_fmodules'
|
|
||||||
source = "interop/kt54284/main.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This test should be run with caches on.
|
// TODO: This test should be run with caches on.
|
||||||
interopTest("interop_kt51925") {
|
interopTest("interop_kt51925") {
|
||||||
interop = 'kt51925'
|
interop = 'kt51925'
|
||||||
@@ -4038,11 +3905,6 @@ dynamicTest("interop_kt43502") {
|
|||||||
useGoldenData = true
|
useGoldenData = true
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_leakMemoryWithRunningThreadUnchecked") {
|
|
||||||
interop = 'leakMemoryWithRunningThread'
|
|
||||||
source = "interop/leakMemoryWithRunningThread/unchecked.kt"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_leakMemoryWithRunningThreadChecked") {
|
interopTest("interop_leakMemoryWithRunningThreadChecked") {
|
||||||
interop = 'leakMemoryWithRunningThread'
|
interop = 'leakMemoryWithRunningThread'
|
||||||
source = "interop/leakMemoryWithRunningThread/checked.kt"
|
source = "interop/leakMemoryWithRunningThread/checked.kt"
|
||||||
@@ -4102,11 +3964,6 @@ interopTest("interop_workerSignals") {
|
|||||||
interop = "workerSignals"
|
interop = "workerSignals"
|
||||||
}
|
}
|
||||||
|
|
||||||
interopTest("interop_forwardDeclarations") {
|
|
||||||
source = "interop/forwardDeclarations/forwardDeclarations.kt"
|
|
||||||
interop = "cForwardDeclarations"
|
|
||||||
}
|
|
||||||
|
|
||||||
interopTest("interop_forwardDeclarationsTwoLibs") {
|
interopTest("interop_forwardDeclarationsTwoLibs") {
|
||||||
source = "interop/forwardDeclarationsTwoLibs/forwardDeclarationsTwoLibs.kt"
|
source = "interop/forwardDeclarationsTwoLibs/forwardDeclarationsTwoLibs.kt"
|
||||||
interop = "cForwardDeclarationsTwoLibs1"
|
interop = "cForwardDeclarationsTwoLibs1"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import carrayPointers.*
|
import arrayPointers.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "name.h"
|
#include "auxiliarySources.aux.h"
|
||||||
|
|
||||||
static std::string _name = "Hello from C++";
|
static std::string _name = "Hello from C++";
|
||||||
|
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
# The def file is empty intentianally
|
||||||
|
# `auxiliarySources.aux.h` is meant to be included via `-header` option of cinterop tool
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import auxiliaryCppSources.*
|
import auxiliarySources.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
|
|
||||||
+2
@@ -2,6 +2,8 @@
|
|||||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2023 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.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
// May need disabling when gcSchedulerType=aggressive . since it may be too slow
|
||||||
|
|
||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import bitfields.*
|
import bitfields.*
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import ccallbacksAndVarargs.*
|
import callbacksAndVarargs.*
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
testStructCallbacks()
|
testStructCallbacks()
|
||||||
+2
-1
@@ -2,9 +2,10 @@
|
|||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
// !LANGUAGE: +EnumEntries
|
||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import cenums.*
|
import enums.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// This test mostly checks frontend behaviour.
|
// This test mostly checks frontend behaviour.
|
||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import cForwardDeclarations.*
|
import forwardDeclarations.*
|
||||||
import cnames.structs.StructDeclared
|
import cnames.structs.StructDeclared
|
||||||
|
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
// OUT_DATA_FILE: funptr.out
|
||||||
/*
|
/*
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2023 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.
|
* that can be found in the LICENSE file.
|
||||||
@@ -5,7 +6,7 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import cfunptr.*
|
import funptr.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
typealias NotSoLongSignatureFunction = (
|
typealias NotSoLongSignatureFunction = (
|
||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import cglobals.*
|
import globals.*
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
assert(g1__ == 42)
|
assert(g1__ == 42)
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "library.h"
|
#include "incompleteTypes.aux.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
# The def file is empty intentianally
|
||||||
|
# `incompleteTypes.aux.h` is meant to be included via `-header` option of cinterop tool
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import library.*
|
import incompleteTypes.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
+1
@@ -1,6 +1,7 @@
|
|||||||
import kt43265.*
|
import kt43265.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@kotlinx.cinterop.ExperimentalForeignApi
|
||||||
fun main() {
|
fun main() {
|
||||||
assertEquals(bcm2835FunctionSelect.BCM2835_GPIO_FSEL_ALT3, bcm2835FunctionSelect.BCM2835_GPIO_FSEL_MASK)
|
assertEquals(bcm2835FunctionSelect.BCM2835_GPIO_FSEL_ALT3, bcm2835FunctionSelect.BCM2835_GPIO_FSEL_MASK)
|
||||||
}
|
}
|
||||||
+1
@@ -7,6 +7,7 @@ import kotlin.test.*
|
|||||||
|
|
||||||
val callbackCounter = AtomicInt(0)
|
val callbackCounter = AtomicInt(0)
|
||||||
|
|
||||||
|
@ExperimentalForeignApi
|
||||||
fun main() {
|
fun main() {
|
||||||
val func = staticCFunction<CValue<TestStruct>, Unit> {
|
val func = staticCFunction<CValue<TestStruct>, Unit> {
|
||||||
kotlin.native.runtime.GC.collect() // Helps to ensure that "runtime" is already initialized.
|
kotlin.native.runtime.GC.collect() // Helps to ensure that "runtime" is already initialized.
|
||||||
+1
@@ -2,6 +2,7 @@ import kotlinx.cinterop.*
|
|||||||
import kt54284.*
|
import kt54284.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@ExperimentalForeignApi
|
||||||
fun main() {
|
fun main() {
|
||||||
assertEquals("FILE:__FILE__", KFILE)
|
assertEquals("FILE:__FILE__", KFILE)
|
||||||
assertEquals("LINE:__LINE__", KLINE)
|
assertEquals("LINE:__LINE__", KLINE)
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
compilerOpts = -fmodules
|
||||||
|
---
|
||||||
|
#define KFILE "FILE:" __FILE__
|
||||||
|
#define KLINE "LINE:" __LINE__
|
||||||
|
#define KTIME "TIME:" __TIME__
|
||||||
|
#define KDATE "DATE:" __DATE__
|
||||||
|
#define KFILENAME "NAME:" __FILE_NAME__
|
||||||
|
#define KBASEFILE "BASE:" __BASE_FILE__
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
import kotlinx.cinterop.*
|
||||||
|
import kt54284_fmodules.*
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
@ExperimentalForeignApi
|
||||||
|
fun main() {
|
||||||
|
assertEquals("FILE:__FILE__", KFILE)
|
||||||
|
assertEquals("LINE:__LINE__", KLINE)
|
||||||
|
assertEquals("TIME:__TIME__", KTIME)
|
||||||
|
assertEquals("DATE:__DATE__", KDATE)
|
||||||
|
assertEquals("NAME:__FILE_NAME__", KFILENAME)
|
||||||
|
assertEquals("BASE:__BASE_FILE__", KBASEFILE)
|
||||||
|
}
|
||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
language = Objective-C
|
language = Objective-C
|
||||||
headers = library.h
|
headers = kt63048.h
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalObjCName::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalObjCName::class)
|
||||||
|
|
||||||
import library.*
|
import kt63048.*
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
@ObjCName("KotlinImplWithCompanionPropertyOverride")
|
@ObjCName("KotlinImplWithCompanionPropertyOverride")
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#import "library.h"
|
#import "kt63048.h"
|
||||||
|
|
||||||
@implementation WithClassProperty : NSObject
|
@implementation WithClassProperty : NSObject
|
||||||
-(instancetype) init {}
|
-(instancetype) init {}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#include "leakMemoryWithRunningThreadUnchecked.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
extern "C" void test_RunInNewThread(void (*f)()) {
|
||||||
|
std::atomic<bool> haveRun(false);
|
||||||
|
std::thread t([f, &haveRun]() {
|
||||||
|
f();
|
||||||
|
haveRun = true;
|
||||||
|
while (true) {}
|
||||||
|
});
|
||||||
|
t.detach();
|
||||||
|
while (!haveRun) {}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package leakMemoryWithRunningThreadUnchecked
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
void test_RunInNewThread(void (*)());
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void test_RunInNewThread(void (*)());
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
+6
-2
@@ -1,6 +1,10 @@
|
|||||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
@file:OptIn(
|
||||||
|
kotlin.experimental.ExperimentalNativeApi::class,
|
||||||
|
kotlin.native.runtime.NativeRuntimeApi::class,
|
||||||
|
kotlinx.cinterop.ExperimentalForeignApi::class
|
||||||
|
)
|
||||||
|
|
||||||
import leakMemory.*
|
import leakMemoryWithRunningThreadUnchecked.*
|
||||||
import kotlin.concurrent.AtomicInt
|
import kotlin.concurrent.AtomicInt
|
||||||
import kotlin.native.concurrent.*
|
import kotlin.native.concurrent.*
|
||||||
import kotlin.native.Platform
|
import kotlin.native.Platform
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
|
||||||
|
|
||||||
import ctoKString.*
|
import toKString.*
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import kotlin.native.*
|
import kotlin.native.*
|
||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
+93
-3
@@ -25,8 +25,98 @@ public class ClassicNativeCInteropExecutableTest extends AbstractNativeCInteropE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("KT-63048")
|
@TestMetadata("arrayPointers")
|
||||||
public void testKT_63048() throws Exception {
|
public void testArrayPointers() throws Exception {
|
||||||
runTest("native/native.tests/testData/CInterop/executable/KT-63048/");
|
runTest("native/native.tests/testData/CInterop/executable/arrayPointers/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("auxiliarySources")
|
||||||
|
public void testAuxiliarySources() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/auxiliarySources/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("bitfields")
|
||||||
|
public void testBitfields() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/bitfields/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callbacksAndVarargs")
|
||||||
|
public void testCallbacksAndVarargs() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/callbacksAndVarargs/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enums")
|
||||||
|
public void testEnums() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/enums/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("forwardDeclarations")
|
||||||
|
public void testForwardDeclarations() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/forwardDeclarations/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("funptr")
|
||||||
|
public void testFunptr() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/funptr/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("globals")
|
||||||
|
public void testGlobals() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/globals/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteTypes")
|
||||||
|
public void testIncompleteTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/incompleteTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt43265")
|
||||||
|
public void testKt43265() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt43265/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt44283")
|
||||||
|
public void testKt44283() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt44283/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54284")
|
||||||
|
public void testKt54284() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt54284/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54284_fmodules")
|
||||||
|
public void testKt54284_fmodules() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt54284_fmodules/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt63048")
|
||||||
|
public void testKt63048() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt63048/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("leakMemoryWithRunningThreadUnchecked")
|
||||||
|
public void testLeakMemoryWithRunningThreadUnchecked() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/leakMemoryWithRunningThreadUnchecked/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("toKString")
|
||||||
|
public void testToKString() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/toKString/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+93
-3
@@ -29,8 +29,98 @@ public class FirNativeCInteropExecutableTest extends AbstractNativeCInteropExecu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("KT-63048")
|
@TestMetadata("arrayPointers")
|
||||||
public void testKT_63048() throws Exception {
|
public void testArrayPointers() throws Exception {
|
||||||
runTest("native/native.tests/testData/CInterop/executable/KT-63048/");
|
runTest("native/native.tests/testData/CInterop/executable/arrayPointers/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("auxiliarySources")
|
||||||
|
public void testAuxiliarySources() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/auxiliarySources/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("bitfields")
|
||||||
|
public void testBitfields() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/bitfields/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callbacksAndVarargs")
|
||||||
|
public void testCallbacksAndVarargs() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/callbacksAndVarargs/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enums")
|
||||||
|
public void testEnums() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/enums/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("forwardDeclarations")
|
||||||
|
public void testForwardDeclarations() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/forwardDeclarations/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("funptr")
|
||||||
|
public void testFunptr() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/funptr/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("globals")
|
||||||
|
public void testGlobals() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/globals/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("incompleteTypes")
|
||||||
|
public void testIncompleteTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/incompleteTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt43265")
|
||||||
|
public void testKt43265() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt43265/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt44283")
|
||||||
|
public void testKt44283() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt44283/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54284")
|
||||||
|
public void testKt54284() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt54284/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt54284_fmodules")
|
||||||
|
public void testKt54284_fmodules() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt54284_fmodules/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt63048")
|
||||||
|
public void testKt63048() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/kt63048/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("leakMemoryWithRunningThreadUnchecked")
|
||||||
|
public void testLeakMemoryWithRunningThreadUnchecked() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/leakMemoryWithRunningThreadUnchecked/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("toKString")
|
||||||
|
public void testToKString() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CInterop/executable/toKString/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-11
@@ -20,24 +20,41 @@ import java.io.File
|
|||||||
abstract class AbstractNativeCInteropExecutableTest : AbstractNativeSimpleTest() {
|
abstract class AbstractNativeCInteropExecutableTest : AbstractNativeSimpleTest() {
|
||||||
|
|
||||||
protected fun runTest(@TestDataFile testDataDir: String) {
|
protected fun runTest(@TestDataFile testDataDir: String) {
|
||||||
val defFile = File(testDataDir, "library.def")
|
val testName = File(testDataDir).name
|
||||||
|
val defFile = File(testDataDir, "$testName.def")
|
||||||
muteCInteropTestIfNecessary(defFile, targets.testTarget)
|
muteCInteropTestIfNecessary(defFile, targets.testTarget)
|
||||||
|
|
||||||
val mFile = File(testDataDir, "library.m")
|
val interopSourceFileM = File(testDataDir, "$testName.m")
|
||||||
val ktFile = File(testDataDir, "usage.kt")
|
val interopSourceFileCPP = File(testDataDir, "$testName.cpp")
|
||||||
|
val interopSourceFile = when {
|
||||||
|
interopSourceFileM.exists() -> interopSourceFileM
|
||||||
|
interopSourceFileCPP.exists() -> interopSourceFileCPP
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
val ktFile = File(testDataDir, "$testName.kt")
|
||||||
|
|
||||||
|
val compilerArgs = buildList {
|
||||||
|
add("-compiler-option")
|
||||||
|
add("-I$testDataDir")
|
||||||
|
val auxHeader = File(testDataDir, "$testName.aux.h")
|
||||||
|
if (auxHeader.exists()) {
|
||||||
|
add("-header")
|
||||||
|
add(auxHeader.absolutePath)
|
||||||
|
}
|
||||||
|
interopSourceFile?.let {
|
||||||
|
add("-Xcompile-source")
|
||||||
|
add(it.absolutePath)
|
||||||
|
add("-Xsource-compiler-option")
|
||||||
|
add("-fobjc-arc")
|
||||||
|
add("-Xsource-compiler-option")
|
||||||
|
add("-DNS_FORMAT_ARGUMENT(A)=")
|
||||||
|
}
|
||||||
|
}
|
||||||
val library = cinteropToLibrary(
|
val library = cinteropToLibrary(
|
||||||
targets = targets,
|
targets = targets,
|
||||||
defFile = defFile,
|
defFile = defFile,
|
||||||
outputDir = buildDir,
|
outputDir = buildDir,
|
||||||
freeCompilerArgs = TestCompilerArgs(
|
freeCompilerArgs = TestCompilerArgs(compilerArgs)
|
||||||
listOf(
|
|
||||||
"-compiler-option", "-I$testDataDir",
|
|
||||||
"-Xcompile-source", mFile.absolutePath,
|
|
||||||
"-Xsource-compiler-option", "-fobjc-arc",
|
|
||||||
"-Xsource-compiler-option", "-DNS_FORMAT_ARGUMENT(A)=",
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).assertSuccess().resultingArtifact
|
).assertSuccess().resultingArtifact
|
||||||
|
|
||||||
val testCase = generateTestCaseWithSingleFile(
|
val testCase = generateTestCaseWithSingleFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user