diff options
| author | 2022-07-25 00:34:18 +0000 | |
|---|---|---|
| committer | 2022-08-04 21:23:14 +0000 | |
| commit | 9f7ae7f565928af0f9867d826d4539852123fce2 (patch) | |
| tree | a97a333ef7ce9a18113cbbe05d5f3e46d81d9ccd /java/app_test.go | |
| parent | 3a0355f99c60dca76817c1eb9e8c7b61ae3481f6 (diff) | |
Set targetSdkVersion to 10000 for MTS tests targeting current
MTS tests built on unstable branches (e.g. git_master) should be testable on
old system images (e.g. S). However, they run into an error during installation
on older images:
`Requires development platform $<current_codename>, but this is a
release platform`
This CL fixes this issue by updating the target_sdk_version of MTS test apps
targeting current to the magical sdk_version 10000
Bug: 227473065
Test: go build ./java
Test: TH
Change-Id: Ic0358a48a19dc239defbb4ee8ec99225cce75584
Diffstat (limited to 'java/app_test.go')
| -rw-r--r-- | java/app_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index bb448034c..0f973ba16 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -3160,3 +3160,65 @@ func TestAppIncludesJniPackages(t *testing.T) { }) } } + +func TestTargetSdkVersionMtsTests(t *testing.T) { + platformSdkCodename := "Tiramisu" + android_test := "android_test" + android_test_helper_app := "android_test_helper_app" + bpTemplate := ` + %v { + name: "mytest", + target_sdk_version: "%v", + test_suites: ["othersuite", "%v"], + } + ` + testCases := []struct { + desc string + moduleType string + targetSdkVersionInBp string + targetSdkVersionExpected string + testSuites string + }{ + { + desc: "Non-MTS android_test_apps targeting current should not be upgraded to 10000", + moduleType: android_test, + targetSdkVersionInBp: "current", + targetSdkVersionExpected: platformSdkCodename, + testSuites: "non-mts-suite", + }, + { + desc: "MTS android_test_apps targeting released sdks should not be upgraded to 10000", + moduleType: android_test, + targetSdkVersionInBp: "29", + targetSdkVersionExpected: "29", + testSuites: "mts-suite", + }, + { + desc: "MTS android_test_apps targeting current should be upgraded to 10000", + moduleType: android_test, + targetSdkVersionInBp: "current", + targetSdkVersionExpected: "10000", + testSuites: "mts-suite", + }, + { + desc: "MTS android_test_helper_apps targeting current should be upgraded to 10000", + moduleType: android_test_helper_app, + targetSdkVersionInBp: "current", + targetSdkVersionExpected: "10000", + testSuites: "mts-suite", + }, + } + fixture := android.GroupFixturePreparers( + prepareForJavaTest, + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.Platform_sdk_codename = &platformSdkCodename + variables.Platform_version_active_codenames = []string{platformSdkCodename} + }), + ) + for _, testCase := range testCases { + result := fixture.RunTestWithBp(t, fmt.Sprintf(bpTemplate, testCase.moduleType, testCase.targetSdkVersionInBp, testCase.testSuites)) + mytest := result.ModuleForTests("mytest", "android_common") + manifestFixerArgs := mytest.Output("manifest_fixer/AndroidManifest.xml").Args["args"] + android.AssertStringDoesContain(t, testCase.desc, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected) + } +} |