Merge "Set targetSdkVersion to 10000 for MTS tests targeting current" am: 0264058aea

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2164782

Change-Id: Ifff15aa2a63aed775150aa6d6147e6300633cbfb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2022-08-06 01:50:06 +00:00
committed by Automerger Merge Worker
3 changed files with 88 additions and 1 deletions

View File

@@ -3163,3 +3163,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)
}
}