-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathDynamicAttachDebugJpmsTest.kt
54 lines (49 loc) · 1.87 KB
/
DynamicAttachDebugJpmsTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@file:OptIn(ExperimentalCoroutinesApi::class)
import org.junit.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.*
import org.junit.Ignore
import org.junit.Test
import java.io.*
import java.lang.IllegalStateException
import kotlin.test.*
class DynamicAttachDebugJpmsTest {
/**
* This test is disabled because:
* Dynamic Attach with JPMS is not yet supported.
*
* Here is the state of experiments:
* When launching this test with additional workarounds like
* ```
* jvmArgs("--add-exports=kotlinx.coroutines.debug/kotlinx.coroutines.repackaged.net.bytebuddy=com.sun.jna")
* jvmArgs("--add-exports=kotlinx.coroutines.debug/kotlinx.coroutines.repackaged.net.bytebuddy.agent=com.sun.jna")
*```
*
* Then we see issues like
*
* ```
* Caused by: java.lang.IllegalStateException: The Byte Buddy agent is not loaded or this method is not called via the system class loader
* at kotlinx.coroutines.debug/kotlinx.coroutines.repackaged.net.bytebuddy.agent.Installer.getInstrumentation(Installer.java:61)
* ... 54 more
* ```
*/
@Ignore("shaded byte-buddy does not work with JPMS")
@Test
fun testAgentDumpsCoroutines() =
DebugProbes.withDebugProbes {
runBlocking {
val baos = ByteArrayOutputStream()
DebugProbes.dumpCoroutines(PrintStream(baos))
// if the agent works, then dumps should contain something,
// at least the fact that this test is running.
Assert.assertTrue(baos.toString().contains("testAgentDumpsCoroutines"))
}
}
@Test
fun testAgentIsNotInstalled() {
assertEquals(false, DebugProbes.isInstalled)
assertFailsWith<IllegalStateException> {
DebugProbes.dumpCoroutines(PrintStream(ByteArrayOutputStream()))
}
}
}