Disable running checkers by default (#4644)

* Make checkers be disabled by default

* Allow running checkers in test launcher
This commit is contained in:
Alexander Shabalin
2021-01-22 12:23:53 +03:00
committed by Nikolay Krasko
parent 71f44dce0f
commit 77e2b9f9a0
22 changed files with 82 additions and 76 deletions
@@ -1,5 +1,7 @@
package knlibrary
import kotlin.native.Platform
// The following 2 singletons are unused. However, since we are generating C bindings for them,
// they should be marked as used, so that the code generator emits their deinitialization.
@@ -8,3 +10,7 @@ object A {}
class B {
companion object {}
}
fun enableMemoryChecker() {
Platform.isMemoryLeakCheckerActive = true
}
@@ -6,6 +6,8 @@ int main() {
auto t = std::thread([] {
auto lib = testlib_symbols();
lib->kotlin.root.knlibrary.enableMemoryChecker();
// Initialize A and B.Companion and get their stable pointers.
auto a = lib->kotlin.root.knlibrary.A._instance();
auto bCompanion = lib->kotlin.root.knlibrary.B.Companion._instance();
@@ -1,5 +1,6 @@
import leakMemory.*
import kotlin.native.concurrent.*
import kotlin.native.Platform
import kotlin.test.*
import kotlinx.cinterop.*
@@ -13,6 +14,7 @@ fun ensureInititalized() {
}
fun main() {
Platform.isMemoryLeakCheckerActive = true
kotlin.native.internal.Debugging.forceCheckedShutdown = true
assertTrue(global.value == 0)
// Created a thread, made sure Kotlin is initialized there.
@@ -1,5 +1,6 @@
import leakMemory.*
import kotlin.native.concurrent.*
import kotlin.native.Platform
import kotlin.test.*
import kotlinx.cinterop.*
@@ -13,6 +14,7 @@ fun ensureInititalized() {
}
fun main() {
Platform.isMemoryLeakCheckerActive = true
kotlin.native.internal.Debugging.forceCheckedShutdown = false
assertTrue(global.value == 0)
// Created a thread, made sure Kotlin is initialized there.
@@ -4,6 +4,11 @@
*/
import kotlinx.cinterop.*
import kotlin.native.Platform
fun enableMemoryChecker() {
Platform.isMemoryLeakCheckerActive = true
}
fun leakMemory() {
StableRef.create(Any())
@@ -9,6 +9,7 @@
int main() {
std::thread t([]() {
testlib_symbols()->kotlin.root.enableMemoryChecker();
testlib_symbols()->kotlin.root.leakMemory();
});
t.join();
@@ -1,7 +1,9 @@
import objc_misc.*
import kotlin.native.Platform
val a = B.giveC()!! as C
fun main() {
Platform.isMemoryLeakCheckerActive = true
println("OK")
}
}