Fix cross-tests on Mac. (#2655)
This commit is contained in:
@@ -2904,7 +2904,7 @@ kotlinNativeInterop {
|
||||
defFile 'interop/basics/ccallbacksAndVarargs.def'
|
||||
}
|
||||
|
||||
if (isMac()) {
|
||||
if (isAppleTarget(project)) {
|
||||
objcSmoke {
|
||||
defFile 'interop/objc/objcSmoke.def'
|
||||
headers "$projectDir/interop/objc/smoke.h"
|
||||
@@ -3012,34 +3012,29 @@ task interop_callbacksAndVarargs(type: RunInteropKonanTest) {
|
||||
|
||||
task interop_echo_server(type: RunInteropKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
if (!isMac()) {
|
||||
// Not supported or not tested.
|
||||
disabled = true
|
||||
}
|
||||
run = false
|
||||
source = "interop/basics/echo_server.kt"
|
||||
interop = 'sockets'
|
||||
}
|
||||
|
||||
if (isMac()) {
|
||||
task interop_opengl_teapot(type: RunStandaloneKonanTest) {
|
||||
dependsOnPlatformLibs(it as Task)
|
||||
disabled = (project.testTarget == 'wasm32') || // No interop for wasm yet.
|
||||
(project.testTarget == 'ios_x64') // No GLUT in iOS
|
||||
run = false
|
||||
source = "interop/basics/opengl_teapot.kt"
|
||||
}
|
||||
task interop_opengl_teapot(type: RunStandaloneKonanTest) {
|
||||
disabled = !isAppleTarget(project) || (project.testTarget == 'ios_x64') // No GLUT in iOS
|
||||
dependsOnPlatformLibs(it as Task)
|
||||
run = false
|
||||
source = "interop/basics/opengl_teapot.kt"
|
||||
}
|
||||
|
||||
task interop_objc_smoke(type: RunInteropKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
goldValue = "84\nFoo\nHello, World!\nKotlin says: Hello, everybody!\nHello from Kotlin\n2, 1\n" +
|
||||
"true\ntrue\n" +
|
||||
"Global string\nAnother global string\nnull\nglobal object\n" +
|
||||
"5\n" +
|
||||
"String macro\n" +
|
||||
"CFString macro\n" +
|
||||
"Deallocated\nDeallocated\n"
|
||||
task interop_objc_smoke(type: RunInteropKonanTest) {
|
||||
disabled = !isAppleTarget(project)
|
||||
goldValue = "84\nFoo\nHello, World!\nKotlin says: Hello, everybody!\nHello from Kotlin\n2, 1\n" +
|
||||
"true\ntrue\n" +
|
||||
"Global string\nAnother global string\nnull\nglobal object\n" +
|
||||
"5\n" +
|
||||
"String macro\n" +
|
||||
"CFString macro\n" +
|
||||
"Deallocated\nDeallocated\n"
|
||||
|
||||
if (isAppleTarget(project)) {
|
||||
source = "interop/objc/smoke.kt"
|
||||
interop = 'objcSmoke'
|
||||
|
||||
@@ -3138,7 +3133,7 @@ task library_mismatch(type: RunStandaloneKonanTest) {
|
||||
goldValue = isWindows() ? messages.replaceAll('\\/', '\\\\') : messages
|
||||
}
|
||||
|
||||
if (isMac() && project.testTarget != 'wasm32') {
|
||||
if (isAppleTarget(project)) {
|
||||
def target = ext.platformManager.targetByName(project.testTarget ?: 'host').name
|
||||
|
||||
task testValuesFramework(type: FrameworkTest) {
|
||||
|
||||
@@ -21,7 +21,7 @@ fun main(args: Array<String>) {
|
||||
val serverAddr = alloc<sockaddr_in>()
|
||||
|
||||
val listenFd = socket(AF_INET, SOCK_STREAM, 0)
|
||||
.ensureUnixCallResult { it >= 0 }
|
||||
.toInt().ensureUnixCallResult { it >= 0 }
|
||||
|
||||
with(serverAddr) {
|
||||
memset(this.ptr, 0, sockaddr_in.size.convert())
|
||||
@@ -31,24 +31,24 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
bind(listenFd, serverAddr.ptr.reinterpret(), sockaddr_in.size.toUInt())
|
||||
.ensureUnixCallResult { it == 0 }
|
||||
.toInt().ensureUnixCallResult { it == 0 }
|
||||
|
||||
listen(listenFd, 10)
|
||||
.ensureUnixCallResult { it == 0 }
|
||||
.toInt().ensureUnixCallResult { it == 0 }
|
||||
|
||||
val commFd = accept(listenFd, null, null)
|
||||
.ensureUnixCallResult { it >= 0 }
|
||||
.toInt().ensureUnixCallResult { it >= 0 }
|
||||
|
||||
while (true) {
|
||||
val length = read(commFd, buffer, bufferLength.convert())
|
||||
.ensureUnixCallResult { it >= 0 }
|
||||
.toInt().ensureUnixCallResult { it >= 0 }
|
||||
|
||||
if (length == 0L) {
|
||||
if (length == 0) {
|
||||
break
|
||||
}
|
||||
|
||||
write(commFd, buffer, length.convert())
|
||||
.ensureUnixCallResult { it >= 0 }
|
||||
.toInt().ensureUnixCallResult { it >= 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,10 +67,3 @@ inline fun Int.ensureUnixCallResult(predicate: (Int) -> Boolean): Int {
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
inline fun Long.ensureUnixCallResult(predicate: (Long) -> Boolean): Long {
|
||||
if (!predicate(this)) {
|
||||
throwUnixError()
|
||||
}
|
||||
return this
|
||||
}
|
||||
@@ -162,6 +162,13 @@ class PlatformInfo {
|
||||
return HostManager.hostIsLinux
|
||||
}
|
||||
|
||||
boolean isAppleTarget(Project project) {
|
||||
def platformManager = project.rootProject.platformManager
|
||||
def targetName = project.project.testTarget ?: 'host'
|
||||
def target = platformManager.targetManager(targetName).target
|
||||
return target.family == Family.IOS || target.family == Family.OSX
|
||||
}
|
||||
|
||||
Throwable unsupportedPlatformException() {
|
||||
return new TargetSupportException()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user