From b432df9cda56a19f05377628989ee4c7550e8678 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 22 Mar 2021 22:09:42 +0000 Subject: Add dependencies from platform_bootclasspath to contents Adds a FinalDeps mutator to add dependencies from the platform_bootclasspath to the configured boot jars which can be from either the platform or any apex. It adds dependencies for every configured boot jar, whether in ArtApexJars, BootJars or UpdatableBootJars. At the moment the dependencies are only used for testing purposes but following changes will make more use of them. Bug: 177892522 Test: m nothing Change-Id: I981305bf45bc20539a3d36987252f490e2b885cc --- java/testing.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'java/testing.go') diff --git a/java/testing.go b/java/testing.go index 80c107d12..455cca9dd 100644 --- a/java/testing.go +++ b/java/testing.go @@ -300,6 +300,37 @@ func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, varia } } +// CheckPlatformBootclasspathModules returns the apex:module pair for the modules depended upon by +// the platform-bootclasspath module. +func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, name string, expected []string) { + t.Helper() + platformBootclasspath := result.Module(name, "android_common").(*platformBootclasspathModule) + pairs := ApexNamePairsFromModules(result.TestContext, platformBootclasspath.configuredModules) + android.AssertDeepEquals(t, fmt.Sprintf("%s modules", "platform-bootclasspath"), expected, pairs) +} + +// ApexNamePairsFromModules returns the apex:module pair for the supplied modules. +func ApexNamePairsFromModules(ctx *android.TestContext, modules []android.Module) []string { + pairs := []string{} + for _, module := range modules { + pairs = append(pairs, apexNamePairFromModule(ctx, module)) + } + return pairs +} + +func apexNamePairFromModule(ctx *android.TestContext, module android.Module) string { + name := module.Name() + var apex string + apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo) + if apexInfo.IsForPlatform() { + apex = "platform" + } else { + apex = apexInfo.InApexes[0] + } + + return fmt.Sprintf("%s:%s", apex, name) +} + func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) { t.Helper() actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n")) -- cgit v1.2.3-59-g8ed1b