[K/N][test] Improve available processors test

Pass expected number of processors as arguments. Don't check it on
linux-arm32/64 which run remotely
This commit is contained in:
Pavel Punegov
2022-01-14 17:53:44 +03:00
committed by Space
parent 1274e2b90a
commit 6dac9fd2a3
2 changed files with 12 additions and 6 deletions
@@ -4423,10 +4423,8 @@ standaloneTest("interop_objc_allocException") {
interopTest("interop_available_processors") {
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
source = 'interop/basics/available_processors.kt'
arguments = [Runtime.getRuntime().availableProcessors().toString()]
interop = 'cstdlib'
outputChecker = {
s -> Integer.parseInt(s.trim()) == Runtime.getRuntime().availableProcessors()
}
}
interopTest("interop0") {
@@ -10,10 +10,18 @@ import kotlinx.cinterop.*
@OptIn(kotlin.ExperimentalStdlibApi::class)
fun main() {
val x = Platform.getAvailableProcessors()
println(x)
fun main(args: Array<String>) {
require(args.size == 1) {
"An expected anount of processors should be specified as program argument"
}
val x: Int = Platform.getAvailableProcessors()
println("Got available processors: $x")
assertTrue(x > 0)
if (!(Platform.osFamily == OsFamily.LINUX && (Platform.cpuArchitecture == CpuArchitecture.ARM32 ||
Platform.cpuArchitecture == CpuArchitecture.ARM64))) {
assertEquals(args[0].trim().toInt(), x)
}
setenv("KOTLIN_NATIVE_AVAILABLE_PROCESSORS", "12345", 1)
assertEquals(Platform.getAvailableProcessors(), 12345)
setenv("KOTLIN_NATIVE_AVAILABLE_PROCESSORS", Long.MAX_VALUE.toString(), 1)