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