[Native][Tests] Add tests for -Xbinary=cInterfaceMode=none
This commit is contained in:
committed by
Space Team
parent
dd25130464
commit
4f9c1860b1
@@ -0,0 +1,59 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
#undef NDEBUG // Make sure that asserts are enabled.
|
||||||
|
#include <assert.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#define DECLARE_ADDER(T) \
|
||||||
|
T add_##T(T a, T b)
|
||||||
|
|
||||||
|
DECLARE_ADDER(int8_t);
|
||||||
|
DECLARE_ADDER(int16_t);
|
||||||
|
DECLARE_ADDER(int32_t);
|
||||||
|
DECLARE_ADDER(int64_t);
|
||||||
|
|
||||||
|
DECLARE_ADDER(uint8_t);
|
||||||
|
DECLARE_ADDER(uint16_t);
|
||||||
|
DECLARE_ADDER(uint32_t);
|
||||||
|
DECLARE_ADDER(uint64_t);
|
||||||
|
|
||||||
|
DECLARE_ADDER(float);
|
||||||
|
DECLARE_ADDER(double);
|
||||||
|
|
||||||
|
float float_nan();
|
||||||
|
double double_nan();
|
||||||
|
|
||||||
|
_Bool logical_or(_Bool a, _Bool b);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
assert(add_int8_t(1, 1) == 2);
|
||||||
|
assert(add_int16_t(1, 1) == 2);
|
||||||
|
assert(add_int32_t(1, 1) == 2);
|
||||||
|
assert(add_int32_t(1, 1) == 2);
|
||||||
|
|
||||||
|
assert(add_uint8_t(1, 1) == 2);
|
||||||
|
assert(add_uint16_t(1, 1) == 2);
|
||||||
|
assert(add_uint32_t(1, 1) == 2);
|
||||||
|
assert(add_uint32_t(1, 1) == 2);
|
||||||
|
|
||||||
|
assert(add_int8_t(INT8_MAX, 1) == INT8_MIN);
|
||||||
|
assert(add_int16_t(INT16_MAX, 1) == INT16_MIN);
|
||||||
|
assert(add_int32_t(INT32_MAX, 1) == INT32_MIN);
|
||||||
|
assert(add_int64_t(INT64_MAX, 1) == INT64_MIN);
|
||||||
|
|
||||||
|
assert(add_uint8_t(UINT8_MAX, 1) == 0);
|
||||||
|
assert(add_uint16_t(UINT16_MAX, 1) == 0);
|
||||||
|
assert(add_uint32_t(UINT32_MAX, 1) == 0);
|
||||||
|
assert(add_uint64_t(UINT64_MAX, 1) == 0);
|
||||||
|
|
||||||
|
assert(logical_or(1, 1) == 1);
|
||||||
|
assert(logical_or(0, 1) == 1);
|
||||||
|
|
||||||
|
assert(add_float(3.0, -3.0) == 0.0);
|
||||||
|
assert(add_double(3.0, -3.0) == 0.0);
|
||||||
|
|
||||||
|
assert(add_float(3.0, -3.0) == 0.0);
|
||||||
|
assert(add_double(3.0, -3.0) == 0.0);
|
||||||
|
|
||||||
|
assert(isnan(float_nan()));
|
||||||
|
assert(isnan(double_nan()));
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package org.lab.mat
|
||||||
|
|
||||||
|
import kotlin.native.internal.ExportedBridge
|
||||||
|
|
||||||
|
@ExportedBridge("add_int8_t")
|
||||||
|
fun add(a: Byte, b: Byte): Int = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_int16_t")
|
||||||
|
fun add(a: Short, b: Short): Int = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_int32_t")
|
||||||
|
fun add(a: Int, b: Int): Int = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_int64_t")
|
||||||
|
fun add(a: Long, b: Long): Long = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_uint8_t")
|
||||||
|
fun add(a: UByte, b: UByte): UInt = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_uint16_t")
|
||||||
|
fun add(a: UShort, b: UShort): UInt = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_uint32_t")
|
||||||
|
fun add(a: UInt, b: UInt): UInt = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_uint64_t")
|
||||||
|
fun add(a: ULong, b: ULong): ULong = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_float")
|
||||||
|
fun add(a: Float, b: Float): Float = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("add_double")
|
||||||
|
fun add(a: Double, b: Double): Double = a + b
|
||||||
|
|
||||||
|
@ExportedBridge("logical_or")
|
||||||
|
fun or(a: Boolean, b: Boolean): Boolean = a || b
|
||||||
|
|
||||||
|
@ExportedBridge("float_nan")
|
||||||
|
fun floatNaN(): Float = Float.NaN
|
||||||
|
|
||||||
|
@ExportedBridge("double_nan")
|
||||||
|
fun doubleNaN(): Double = Double.NaN
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int32_t my_function(int32_t);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
if (my_function(5) != 5) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import kotlin.native.internal.ExportedBridge
|
||||||
|
|
||||||
|
@ExportedBridge("my_function")
|
||||||
|
fun myFunction(value: Int): Int = value
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.test.blackbox;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceNone")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "NONE")
|
||||||
|
public class CExportDynamicInterfaceNoneTestGenerated extends AbstractNativeCExportTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInInterfaceNone() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceNone"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primitiveTypes")
|
||||||
|
public void testPrimitiveTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/primitiveTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smoke0")
|
||||||
|
public void testSmoke0() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/smoke0/");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -21,7 +21,8 @@ import java.util.regex.Pattern;
|
|||||||
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
public class CExportDynamicTestGenerated extends AbstractNativeCExportTest {
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "V1")
|
||||||
|
public class CExportDynamicInterfaceV1TestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInInterfaceV1() {
|
public void testAllFilesPresentInInterfaceV1() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.test.blackbox;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceNone")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "NONE")
|
||||||
|
public class CExportStaticInterfaceNoneTestGenerated extends AbstractNativeCExportTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInInterfaceNone() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceNone"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primitiveTypes")
|
||||||
|
public void testPrimitiveTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/primitiveTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smoke0")
|
||||||
|
public void testSmoke0() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/smoke0/");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -21,7 +21,8 @@ import java.util.regex.Pattern;
|
|||||||
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
||||||
public class CExportStaticTestGenerated extends AbstractNativeCExportTest {
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "V1")
|
||||||
|
public class CExportStaticInterfaceV1TestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInInterfaceV1() {
|
public void testAllFilesPresentInInterfaceV1() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.test.blackbox;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceNone")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "NONE")
|
||||||
|
@Tag("frontend-fir")
|
||||||
|
@FirPipeline()
|
||||||
|
public class FirCExportDynamicInterfaceNoneTestGenerated extends AbstractNativeCExportTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInInterfaceNone() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceNone"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primitiveTypes")
|
||||||
|
public void testPrimitiveTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/primitiveTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smoke0")
|
||||||
|
public void testSmoke0() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/smoke0/");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -23,9 +23,10 @@ import java.util.regex.Pattern;
|
|||||||
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "DYNAMIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "V1")
|
||||||
@Tag("frontend-fir")
|
@Tag("frontend-fir")
|
||||||
@FirPipeline()
|
@FirPipeline()
|
||||||
public class FirCExportDynamicTestGenerated extends AbstractNativeCExportTest {
|
public class FirCExportDynamicInterfaceV1TestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInInterfaceV1() {
|
public void testAllFilesPresentInInterfaceV1() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.test.blackbox;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedProperty;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.ClassLevelProperty;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
import org.jetbrains.kotlin.konan.test.blackbox.support.group.FirPipeline;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceNone")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "NONE")
|
||||||
|
@Tag("frontend-fir")
|
||||||
|
@FirPipeline()
|
||||||
|
public class FirCExportStaticInterfaceNoneTestGenerated extends AbstractNativeCExportTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInInterfaceNone() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceNone"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("primitiveTypes")
|
||||||
|
public void testPrimitiveTypes() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/primitiveTypes/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smoke0")
|
||||||
|
public void testSmoke0() throws Exception {
|
||||||
|
runTest("native/native.tests/testData/CExport/InterfaceNone/smoke0/");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-1
@@ -23,9 +23,10 @@ import java.util.regex.Pattern;
|
|||||||
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
@TestMetadata("native/native.tests/testData/CExport/InterfaceV1")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
@EnforcedProperty(property = ClassLevelProperty.BINARY_LIBRARY_KIND, propertyValue = "STATIC")
|
||||||
|
@EnforcedProperty(property = ClassLevelProperty.C_INTERFACE_MODE, propertyValue = "V1")
|
||||||
@Tag("frontend-fir")
|
@Tag("frontend-fir")
|
||||||
@FirPipeline()
|
@FirPipeline()
|
||||||
public class FirCExportStaticTestGenerated extends AbstractNativeCExportTest {
|
public class FirCExportStaticInterfaceV1TestGenerated extends AbstractNativeCExportTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllFilesPresentInInterfaceV1() {
|
public void testAllFilesPresentInInterfaceV1() {
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("native/native.tests/testData/CExport/InterfaceV1"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
+22
-10
@@ -469,18 +469,25 @@ fun main() {
|
|||||||
)
|
)
|
||||||
// C Export
|
// C Export
|
||||||
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
testGroup("native/native.tests/tests-gen", "native/native.tests/testData") {
|
||||||
|
val cinterfaceModes = mapOf(
|
||||||
|
"InterfaceV1" to cinterfaceMode("V1"),
|
||||||
|
"InterfaceNone" to cinterfaceMode("NONE")
|
||||||
|
)
|
||||||
binaryLibraryKinds.forEach { binaryKind ->
|
binaryLibraryKinds.forEach { binaryKind ->
|
||||||
frontendFlags.forEach { frontend ->
|
frontendFlags.forEach { frontend ->
|
||||||
val frontendKey = if (frontend.key == "Classic") "" else frontend.key
|
cinterfaceModes.forEach { cinterfaceMode ->
|
||||||
val suiteTestClassName = "${frontendKey}CExport${binaryKind.key}TestGenerated"
|
val frontendKey = if (frontend.key == "Classic") "" else frontend.key
|
||||||
testClass<AbstractNativeCExportTest>(
|
val suiteTestClassName = "${frontendKey}CExport${binaryKind.key}${cinterfaceMode.key}TestGenerated"
|
||||||
suiteTestClassName,
|
testClass<AbstractNativeCExportTest>(
|
||||||
annotations = listOf(
|
suiteTestClassName,
|
||||||
binaryKind.value,
|
annotations = listOf(
|
||||||
*frontend.value
|
binaryKind.value,
|
||||||
)
|
cinterfaceMode.value,
|
||||||
) {
|
*frontend.value
|
||||||
model("CExport/InterfaceV1", pattern = "^([^_](.+))$", recursive = false)
|
)
|
||||||
|
) {
|
||||||
|
model("CExport/${cinterfaceMode.key}", pattern = "^([^_](.+))$", recursive = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,3 +573,8 @@ private fun binaryLibraryKind(kind: String = "DYNAMIC") = annotation(
|
|||||||
"property" to ClassLevelProperty.BINARY_LIBRARY_KIND,
|
"property" to ClassLevelProperty.BINARY_LIBRARY_KIND,
|
||||||
"propertyValue" to kind
|
"propertyValue" to kind
|
||||||
)
|
)
|
||||||
|
private fun cinterfaceMode(mode: String = "V1") = annotation(
|
||||||
|
EnforcedProperty::class.java,
|
||||||
|
"property" to ClassLevelProperty.C_INTERFACE_MODE,
|
||||||
|
"propertyValue" to mode
|
||||||
|
)
|
||||||
|
|||||||
+4
-1
@@ -122,7 +122,10 @@ abstract class AbstractNativeCExportTest() : AbstractNativeSimpleTest() {
|
|||||||
id = TestCaseId.Named(moduleName),
|
id = TestCaseId.Named(moduleName),
|
||||||
kind = TestKind.STANDALONE_NO_TR,
|
kind = TestKind.STANDALONE_NO_TR,
|
||||||
modules = setOf(module),
|
modules = setOf(module),
|
||||||
freeCompilerArgs = TestCompilerArgs(listOf()),
|
freeCompilerArgs = TestCompilerArgs(listOf(
|
||||||
|
"-opt-in", "kotlin.experimental.ExperimentalNativeApi",
|
||||||
|
"-opt-in", "kotlinx.cinterop.ExperimentalForeignApi",
|
||||||
|
)),
|
||||||
nominalPackageName = PackageName(moduleName),
|
nominalPackageName = PackageName(moduleName),
|
||||||
checks = TestRunChecks(
|
checks = TestRunChecks(
|
||||||
executionTimeoutCheck = TestRunCheck.ExecutionTimeout.ShouldNotExceed(testRunSettings.get<Timeouts>().executionTimeout),
|
executionTimeoutCheck = TestRunCheck.ExecutionTimeout.ShouldNotExceed(testRunSettings.get<Timeouts>().executionTimeout),
|
||||||
|
|||||||
+1
@@ -73,6 +73,7 @@ internal enum class ClassLevelProperty(val shortName: String) {
|
|||||||
PIPELINE_TYPE("pipelineType"),
|
PIPELINE_TYPE("pipelineType"),
|
||||||
SHARED_TEST_EXECUTION("sharedTestExecution"),
|
SHARED_TEST_EXECUTION("sharedTestExecution"),
|
||||||
BINARY_LIBRARY_KIND("binaryLibraryKind"),
|
BINARY_LIBRARY_KIND("binaryLibraryKind"),
|
||||||
|
C_INTERFACE_MODE("cInterfaceMode"),
|
||||||
;
|
;
|
||||||
|
|
||||||
internal val propertyName = fullPropertyName(shortName)
|
internal val propertyName = fullPropertyName(shortName)
|
||||||
|
|||||||
+5
@@ -210,6 +210,7 @@ internal object NativeTestSupport {
|
|||||||
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
output += computeUsedPartialLinkageConfig(enclosingTestClass)
|
||||||
output += computeCompilerOutputInterceptor(enforcedProperties)
|
output += computeCompilerOutputInterceptor(enforcedProperties)
|
||||||
output += computeBinaryLibraryKind(enforcedProperties)
|
output += computeBinaryLibraryKind(enforcedProperties)
|
||||||
|
output += computeCInterfaceMode(enforcedProperties)
|
||||||
|
|
||||||
return nativeTargets
|
return nativeTargets
|
||||||
}
|
}
|
||||||
@@ -508,6 +509,10 @@ internal object NativeTestSupport {
|
|||||||
|
|
||||||
private fun computeBinaryLibraryKind(enforcedProperties: EnforcedProperties): BinaryLibraryKind =
|
private fun computeBinaryLibraryKind(enforcedProperties: EnforcedProperties): BinaryLibraryKind =
|
||||||
ClassLevelProperty.BINARY_LIBRARY_KIND.readValue(enforcedProperties, BinaryLibraryKind.values(), BinaryLibraryKind.STATIC)
|
ClassLevelProperty.BINARY_LIBRARY_KIND.readValue(enforcedProperties, BinaryLibraryKind.values(), BinaryLibraryKind.STATIC)
|
||||||
|
|
||||||
|
private fun computeCInterfaceMode(enforcedProperties: EnforcedProperties): CInterfaceMode =
|
||||||
|
ClassLevelProperty.C_INTERFACE_MODE.readValue(enforcedProperties, CInterfaceMode.values(), CInterfaceMode.NONE)
|
||||||
|
|
||||||
/*************** Test class settings (simplified) ***************/
|
/*************** Test class settings (simplified) ***************/
|
||||||
|
|
||||||
private fun ExtensionContext.getOrCreateSimpleTestClassSettings(): SimpleTestClassSettings =
|
private fun ExtensionContext.getOrCreateSimpleTestClassSettings(): SimpleTestClassSettings =
|
||||||
|
|||||||
+3
-1
@@ -351,6 +351,7 @@ internal class BinaryLibraryCompilation(
|
|||||||
dependencies = CategorizedDependencies(dependencies),
|
dependencies = CategorizedDependencies(dependencies),
|
||||||
expectedArtifact = expectedArtifact
|
expectedArtifact = expectedArtifact
|
||||||
) {
|
) {
|
||||||
|
private val cinterfaceMode = settings.get<CInterfaceMode>().compilerFlag
|
||||||
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
override val binaryOptions get() = BinaryOptions.RuntimeAssertionsMode.defaultForTesting(optimizationMode, freeCompilerArgs.assertionsMode)
|
||||||
|
|
||||||
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
override fun applySpecificArgs(argsBuilder: ArgsBuilder) = with(argsBuilder) {
|
||||||
@@ -360,7 +361,8 @@ internal class BinaryLibraryCompilation(
|
|||||||
}
|
}
|
||||||
add(
|
add(
|
||||||
"-produce", libraryKind,
|
"-produce", libraryKind,
|
||||||
"-output", expectedArtifact.libraryFile.absolutePath
|
"-output", expectedArtifact.libraryFile.absolutePath,
|
||||||
|
cinterfaceMode
|
||||||
)
|
)
|
||||||
super.applySpecificArgs(argsBuilder)
|
super.applySpecificArgs(argsBuilder)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -299,3 +299,8 @@ internal enum class CompilerOutputInterceptor {
|
|||||||
internal enum class BinaryLibraryKind {
|
internal enum class BinaryLibraryKind {
|
||||||
STATIC, DYNAMIC
|
STATIC, DYNAMIC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum class CInterfaceMode(val compilerFlag: String) {
|
||||||
|
V1("-Xbinary=cInterfaceMode=v1"),
|
||||||
|
NONE("-Xbinary=cInterfaceMode=none")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user