summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
author Jeongik Cha <jeongik@google.com> 2021-07-08 01:13:11 +0900
committer Jeongik Cha <jeongik@google.com> 2021-07-13 13:54:03 +0000
commitd5fe8782e089ec1539a133f270aa62f5d3ead61a (patch)
tree958cc2cb03abcabd87196c7d943d0d0cb9957b3a /apex/apex_test.go
parent49e0e811556dc82a3457783b3bf5a690af447183 (diff)
SdkLibraryImport's DexJarInstallPath uses installPath from source module
Even though actual installed module path is the same as source module, it uses impl's one. Bug: 188179858 Bug: 193082464 Test: compare dexpreopt_config.zip files from 1. TARGET_BUILD_UNBUNDLED_IMAGE=true m dexpreopt_config_zip 2. m dexpreopt_config_zip (note that m clean should run between steps) Test: build aosp_cf_x86_64_phone, launch_cvd, and then adb wait-for-device \ && adb root \ && adb logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' -C 1 and then check if there is no message. Change-Id: I34ffd9a2d214a6614c2befc35b2beec003cfcd25
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index b5b1d4401..422e46c4d 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4687,16 +4687,26 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
dexJarBuildPath := p.DexJarBuildPath()
stem := android.RemoveOptionalPrebuiltPrefix(name)
- if expected, actual := ".intermediates/myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar", android.NormalizePathForTesting(dexJarBuildPath); actual != expected {
- t.Errorf("Incorrect DexJarBuildPath value '%s', expected '%s'", actual, expected)
- }
+ android.AssertStringEquals(t, "DexJarBuildPath should be apex-related path.",
+ ".intermediates/myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar",
+ android.NormalizePathForTesting(dexJarBuildPath))
+ }
+
+ checkDexJarInstallPath := func(t *testing.T, ctx *android.TestContext, name string) {
+ // Make sure the import has been given the correct path to the dex jar.
+ p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency)
+ dexJarBuildPath := p.DexJarInstallPath()
+ stem := android.RemoveOptionalPrebuiltPrefix(name)
+ android.AssertStringEquals(t, "DexJarInstallPath should be apex-related path.",
+ "target/product/test_device/apex/myapex/javalib/"+stem+".jar",
+ android.NormalizePathForTesting(dexJarBuildPath))
}
ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext, name string) {
// Make sure that an apex variant is not created for the source module.
- if expected, actual := []string{"android_common"}, ctx.ModuleVariantsForTests(name); !reflect.DeepEqual(expected, actual) {
- t.Errorf("invalid set of variants for %q: expected %q, found %q", "libfoo", expected, actual)
- }
+ android.AssertArrayString(t, "Check if there is no source variant",
+ []string{"android_common"},
+ ctx.ModuleVariantsForTests(name))
}
t.Run("prebuilt only", func(t *testing.T) {
@@ -4745,8 +4755,10 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
}
checkDexJarBuildPath(t, ctx, "libfoo")
+ checkDexJarInstallPath(t, ctx, "libfoo")
checkDexJarBuildPath(t, ctx, "libbar")
+ checkDexJarInstallPath(t, ctx, "libbar")
})
t.Run("prebuilt with source preferred", func(t *testing.T) {
@@ -4792,9 +4804,11 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
ctx := testDexpreoptWithApexes(t, bp, "", transform)
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
+ checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
ensureNoSourceVariant(t, ctx, "libfoo")
checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
+ checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
ensureNoSourceVariant(t, ctx, "libbar")
})
@@ -4842,9 +4856,11 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
ctx := testDexpreoptWithApexes(t, bp, "", transform)
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
+ checkDexJarInstallPath(t, ctx, "prebuilt_libfoo")
ensureNoSourceVariant(t, ctx, "libfoo")
checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
+ checkDexJarInstallPath(t, ctx, "prebuilt_libbar")
ensureNoSourceVariant(t, ctx, "libbar")
})
}