Added test on workers with invalid transfer attempt
This commit is contained in:
@@ -502,6 +502,12 @@ task worker2(type: RunKonanTest) {
|
||||
source = "runtime/workers/worker2.kt"
|
||||
}
|
||||
|
||||
task worker3(type: RunKonanTest) {
|
||||
disabled = (project.testTarget == 'wasm32') // Workers need pthreads.
|
||||
goldValue = "OK\n"
|
||||
source = "runtime/workers/worker3.kt"
|
||||
}
|
||||
|
||||
task superFunCall(type: RunKonanTest) {
|
||||
goldValue = "<fun:C><fun:C1>\n<fun:C><fun:C3>\n"
|
||||
source = "codegen/basics/superFunCall.kt"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import konan.worker.*
|
||||
|
||||
data class WorkerArgument(val intParam: Int, val stringParam: String)
|
||||
data class WorkerResult(val intResult: Int, val stringResult: String)
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val worker = startWorker()
|
||||
val s = "zzz${args.size.toString()}"
|
||||
|
||||
val future = try {
|
||||
worker.schedule(TransferMode.CHECKED,
|
||||
{ WorkerArgument(42, s) },
|
||||
{ input -> WorkerResult(input.intParam, input.stringParam + " result") }
|
||||
)
|
||||
} catch (e: IllegalStateException) {
|
||||
null
|
||||
}
|
||||
if (future != null)
|
||||
println("Fail 1")
|
||||
if (s != "zzz0") println("Fail 2")
|
||||
worker.requestTermination().consume { _ -> }
|
||||
println("OK")
|
||||
}
|
||||
Reference in New Issue
Block a user