diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-08-13 14:11:33 -0700 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
commit | e9b9ddc1ee5619502da7b7cffe20a4950d73e788 (patch) | |
tree | 44f851a23afa96cd5ca4397401cf6404c5597504 /java/app_test.go | |
parent | ba18ee4726de96c98183968173f1c83918a72a52 (diff) | |
download | android_build_soong-e9b9ddc1ee5619502da7b7cffe20a4950d73e788.tar.gz android_build_soong-e9b9ddc1ee5619502da7b7cffe20a4950d73e788.tar.bz2 android_build_soong-e9b9ddc1ee5619502da7b7cffe20a4950d73e788.zip |
Add arch variant support to android_app_import.
Bug: 128610294
Fixes: 138792623
Test: app_test.go
Change-Id: I47c80ec283ce58a0ce9b7d0af40844bd73e9d3f1
Diffstat (limited to 'java/app_test.go')
-rw-r--r-- | java/app_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index 8b254ad0..a5c4fbc7 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -1362,3 +1362,66 @@ func TestAndroidAppImport_Filename(t *testing.T) { } } } + +func TestAndroidAppImport_ArchVariants(t *testing.T) { + // The test config's target arch is ARM64. + testCases := []struct { + name string + bp string + expected string + }{ + { + name: "matching arch", + bp: ` + android_app_import { + name: "foo", + apk: "prebuilts/apk/app.apk", + arch: { + arm64: { + apk: "prebuilts/apk/app_arm64.apk", + }, + }, + certificate: "PRESIGNED", + dex_preopt: { + enabled: true, + }, + } + `, + expected: "prebuilts/apk/app_arm64.apk", + }, + { + name: "no matching arch", + bp: ` + android_app_import { + name: "foo", + apk: "prebuilts/apk/app.apk", + arch: { + arm: { + apk: "prebuilts/apk/app_arm.apk", + }, + }, + certificate: "PRESIGNED", + dex_preopt: { + enabled: true, + }, + } + `, + expected: "prebuilts/apk/app.apk", + }, + } + + jniRuleRe := regexp.MustCompile("^if \\(zipinfo (\\S+)") + for _, test := range testCases { + ctx := testJava(t, test.bp) + + variant := ctx.ModuleForTests("foo", "android_common") + jniRuleCommand := variant.Output("jnis-uncompressed/foo.apk").RuleParams.Command + matches := jniRuleRe.FindStringSubmatch(jniRuleCommand) + if len(matches) != 2 { + t.Errorf("failed to extract the src apk path from %q", jniRuleCommand) + } + if test.expected != matches[1] { + t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1]) + } + } +} |