xref: /aosp_15_r20/libnativehelper/tests_mts/README.md (revision 0797b24ee566c78eb48500180cb4bf71f81c8aab)
1*0797b24eSAndroid Build Coastguard Worker# libnativehelper MTS tests
2*0797b24eSAndroid Build Coastguard Worker
3*0797b24eSAndroid Build Coastguard WorkerThese tests cover the API surface of libnativehelper that is applicable once
4*0797b24eSAndroid Build Coastguard Workerthe runtime is initialized.
5*0797b24eSAndroid Build Coastguard Worker
6*0797b24eSAndroid Build Coastguard WorkerThese tests do not cover the API surface relating to the binding of the ART
7*0797b24eSAndroid Build Coastguard Workerruntime (DalvikVM), that preclude the initialization of the runtime, nor do
8*0797b24eSAndroid Build Coastguard Workerthey cover JNI_CreateJavaVM(). These APIs have been invoked before the test
9*0797b24eSAndroid Build Coastguard Workerharness runs these tests.
10*0797b24eSAndroid Build Coastguard Worker
11*0797b24eSAndroid Build Coastguard WorkerAPI surface not directly covered here are:
12*0797b24eSAndroid Build Coastguard Worker
13*0797b24eSAndroid Build Coastguard Worker```
14*0797b24eSAndroid Build Coastguard Worker    JNI_GetCreatedJavaVMs
15*0797b24eSAndroid Build Coastguard Worker
16*0797b24eSAndroid Build Coastguard Worker    JniInvocationCreate
17*0797b24eSAndroid Build Coastguard Worker    JniInvocationDestroy
18*0797b24eSAndroid Build Coastguard Worker    JniInvocationInit
19*0797b24eSAndroid Build Coastguard Worker    JniInvocationGetLibrary
20*0797b24eSAndroid Build Coastguard Worker
21*0797b24eSAndroid Build Coastguard Worker    jniUninitializeConstants
22*0797b24eSAndroid Build Coastguard Worker```
23*0797b24eSAndroid Build Coastguard Worker
24*0797b24eSAndroid Build Coastguard Worker`JniInvocationInit()` is responsible for binding the ART runtime and
25*0797b24eSAndroid Build Coastguard Workerspecifically the following methods:
26*0797b24eSAndroid Build Coastguard Worker
27*0797b24eSAndroid Build Coastguard Worker```
28*0797b24eSAndroid Build Coastguard Worker    JNI_CreateJavaVM
29*0797b24eSAndroid Build Coastguard Worker    JNI_GetCreatedJavaVMs
30*0797b24eSAndroid Build Coastguard Worker    JNI_GetDefaultJavaVMInitArgs
31*0797b24eSAndroid Build Coastguard Worker```
32*0797b24eSAndroid Build Coastguard Worker
33*0797b24eSAndroid Build Coastguard WorkerThese tests do check that `JNI_GetCreatedJavaVMs()` and
34*0797b24eSAndroid Build Coastguard Worker`JNI_GetDefaultJavaVMInitArgs()` behave as expected and are thus asserted to
35*0797b24eSAndroid Build Coastguard Workerbe correctly bound. `JNI_CreateJavaVM()` cannot be called in these tests
36*0797b24eSAndroid Build Coastguard Workerbecause Android only supports a single runtime per process.
37*0797b24eSAndroid Build Coastguard Worker
38*0797b24eSAndroid Build Coastguard Worker`JniInvocationInit()` uses `JniInvocationGetLibrary()` to determine which
39*0797b24eSAndroid Build Coastguard Workerruntime to load (release, debug, or custom). The code responsible for that
40*0797b24eSAndroid Build Coastguard Workerdecision is tested comprehensively in `libnativehelper_gtests`.
41*0797b24eSAndroid Build Coastguard Worker
42*0797b24eSAndroid Build Coastguard Worker`jniUninitializeConstants` is only intended to be called when the runtime is
43*0797b24eSAndroid Build Coastguard Workershutting down and unloading the managed core libraries.
44*0797b24eSAndroid Build Coastguard Worker
45*0797b24eSAndroid Build Coastguard Worker## Potential Issues
46*0797b24eSAndroid Build Coastguard Worker
47*0797b24eSAndroid Build Coastguard WorkerThe test harness depends on libnativehelper_compat_libc++ and the tests
48*0797b24eSAndroid Build Coastguard Workerdepend on libnativehelper. The former library is a subset of libnativehelper.
49*0797b24eSAndroid Build Coastguard WorkerThere are potential ODR problems if the two libraries having overlapping
50*0797b24eSAndroid Build Coastguard Workerglobal state. It would be better to have two separate test suites for these
51*0797b24eSAndroid Build Coastguard Workertwo libraries.
52