diff options
author | Colin Cross <ccross@android.com> | 2019-03-26 10:51:39 -0700 |
---|---|---|
committer | Jaewoong Jung <jungjw@google.com> | 2019-03-27 15:09:52 +0000 |
commit | 47fa9d3d83fbafd56723907b23e45ed026ea7a10 (patch) | |
tree | 9cbffe576842d90d59d32fd9ed64638215a77826 /java/app_test.go | |
parent | c7dd408f890cd03f3f0bfdf2df8002fc7497ccf8 (diff) | |
download | android_build_soong-47fa9d3d83fbafd56723907b23e45ed026ea7a10.tar.gz android_build_soong-47fa9d3d83fbafd56723907b23e45ed026ea7a10.tar.bz2 android_build_soong-47fa9d3d83fbafd56723907b23e45ed026ea7a10.zip |
Always package JNI libs into android_test modules
android_test modules should always have native libraries packaged
into the APK even when use_embedded_native_libs: false is set.
Fixes: 129298278
Test: TestJNIPackaging
Change-Id: Idfcc630f7c6579c1280a920b5d71808b0a502e06
Diffstat (limited to 'java/app_test.go')
-rw-r--r-- | java/app_test.go | 132 |
1 files changed, 88 insertions, 44 deletions
diff --git a/java/app_test.go b/java/app_test.go index d2662426..781fdfff 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -16,6 +16,8 @@ package java import ( "android/soong/android" + "android/soong/cc" + "fmt" "path/filepath" "reflect" @@ -537,43 +539,8 @@ func TestAppSdkVersion(t *testing.T) { } } -func TestJNI(t *testing.T) { - ctx := testJava(t, ` - toolchain_library { - name: "libcompiler_rt-extras", - src: "", - } - - toolchain_library { - name: "libatomic", - src: "", - } - - toolchain_library { - name: "libgcc", - src: "", - } - - toolchain_library { - name: "libclang_rt.builtins-aarch64-android", - src: "", - } - - toolchain_library { - name: "libclang_rt.builtins-arm-android", - src: "", - } - - cc_object { - name: "crtbegin_so", - stl: "none", - } - - cc_object { - name: "crtend_so", - stl: "none", - } - +func TestJNIABI(t *testing.T) { + ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` cc_library { name: "libjni", system_shared_libs: [], @@ -615,13 +582,6 @@ func TestJNI(t *testing.T) { } `) - // check the existence of the internal modules - ctx.ModuleForTests("test", "android_common") - ctx.ModuleForTests("test_first", "android_common") - ctx.ModuleForTests("test_both", "android_common") - ctx.ModuleForTests("test_32", "android_common") - ctx.ModuleForTests("test_64", "android_common") - testCases := []struct { name string abis []string @@ -652,6 +612,90 @@ func TestJNI(t *testing.T) { } } +func TestJNIPackaging(t *testing.T) { + ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` + cc_library { + name: "libjni", + system_shared_libs: [], + stl: "none", + } + + android_app { + name: "app", + jni_libs: ["libjni"], + } + + android_app { + name: "app_noembed", + jni_libs: ["libjni"], + use_embedded_native_libs: false, + } + + android_app { + name: "app_embed", + jni_libs: ["libjni"], + use_embedded_native_libs: true, + } + + android_test { + name: "test", + no_framework_libs: true, + jni_libs: ["libjni"], + } + + android_test { + name: "test_noembed", + no_framework_libs: true, + jni_libs: ["libjni"], + use_embedded_native_libs: false, + } + + android_test_helper_app { + name: "test_helper", + no_framework_libs: true, + jni_libs: ["libjni"], + } + + android_test_helper_app { + name: "test_helper_noembed", + no_framework_libs: true, + jni_libs: ["libjni"], + use_embedded_native_libs: false, + } + `) + + testCases := []struct { + name string + packaged bool + compressed bool + }{ + {"app", false, false}, + {"app_noembed", false, false}, + {"app_embed", true, false}, + {"test", true, false}, + {"test_noembed", true, true}, + {"test_helper", true, false}, + {"test_helper_noembed", true, true}, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + app := ctx.ModuleForTests(test.name, "android_common") + jniLibZip := app.MaybeOutput("jnilibs.zip") + if g, w := (jniLibZip.Rule != nil), test.packaged; g != w { + t.Errorf("expected jni packaged %v, got %v", w, g) + } + + if jniLibZip.Rule != nil { + if g, w := !strings.Contains(jniLibZip.Args["jarArgs"], "-L 0"), test.compressed; g != w { + t.Errorf("expected jni compressed %v, got %v", w, g) + } + } + }) + } + +} + func TestCertificates(t *testing.T) { testCases := []struct { name string |