xref: /aosp_15_r20/build/soong/java/testing.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1*333d2b36SAndroid Build Coastguard Worker// Copyright 2019 Google Inc. All rights reserved.
2*333d2b36SAndroid Build Coastguard Worker//
3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*333d2b36SAndroid Build Coastguard Worker//
7*333d2b36SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*333d2b36SAndroid Build Coastguard Worker//
9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*333d2b36SAndroid Build Coastguard Worker// limitations under the License.
14*333d2b36SAndroid Build Coastguard Worker
15*333d2b36SAndroid Build Coastguard Workerpackage java
16*333d2b36SAndroid Build Coastguard Worker
17*333d2b36SAndroid Build Coastguard Workerimport (
18*333d2b36SAndroid Build Coastguard Worker	"fmt"
19*333d2b36SAndroid Build Coastguard Worker	"reflect"
20*333d2b36SAndroid Build Coastguard Worker	"regexp"
21*333d2b36SAndroid Build Coastguard Worker	"sort"
22*333d2b36SAndroid Build Coastguard Worker	"strings"
23*333d2b36SAndroid Build Coastguard Worker	"testing"
24*333d2b36SAndroid Build Coastguard Worker
25*333d2b36SAndroid Build Coastguard Worker	"android/soong/android"
26*333d2b36SAndroid Build Coastguard Worker	"android/soong/cc"
27*333d2b36SAndroid Build Coastguard Worker	"android/soong/dexpreopt"
28*333d2b36SAndroid Build Coastguard Worker
29*333d2b36SAndroid Build Coastguard Worker	"github.com/google/blueprint"
30*333d2b36SAndroid Build Coastguard Worker)
31*333d2b36SAndroid Build Coastguard Worker
32*333d2b36SAndroid Build Coastguard Workerconst defaultJavaDir = "default/java"
33*333d2b36SAndroid Build Coastguard Workerconst testDefaultUpdatableModuleVersion = "340090000"
34*333d2b36SAndroid Build Coastguard Worker
35*333d2b36SAndroid Build Coastguard Worker// Test fixture preparer that will register most java build components.
36*333d2b36SAndroid Build Coastguard Worker//
37*333d2b36SAndroid Build Coastguard Worker// Singletons and mutators should only be added here if they are needed for a majority of java
38*333d2b36SAndroid Build Coastguard Worker// module types, otherwise they should be added under a separate preparer to allow them to be
39*333d2b36SAndroid Build Coastguard Worker// selected only when needed to reduce test execution time.
40*333d2b36SAndroid Build Coastguard Worker//
41*333d2b36SAndroid Build Coastguard Worker// Module types do not have much of an overhead unless they are used so this should include as many
42*333d2b36SAndroid Build Coastguard Worker// module types as possible. The exceptions are those module types that require mutators and/or
43*333d2b36SAndroid Build Coastguard Worker// singletons in order to function in which case they should be kept together in a separate
44*333d2b36SAndroid Build Coastguard Worker// preparer.
45*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers(
46*333d2b36SAndroid Build Coastguard Worker	// Make sure that mutators and module types, e.g. prebuilt mutators available.
47*333d2b36SAndroid Build Coastguard Worker	android.PrepareForTestWithAndroidBuildComponents,
48*333d2b36SAndroid Build Coastguard Worker	// Make java build components available to the test.
49*333d2b36SAndroid Build Coastguard Worker	android.FixtureRegisterWithContext(registerRequiredBuildComponentsForTest),
50*333d2b36SAndroid Build Coastguard Worker	android.FixtureRegisterWithContext(registerJavaPluginBuildComponents),
51*333d2b36SAndroid Build Coastguard Worker	// Additional files needed in tests that disallow non-existent source files.
52*333d2b36SAndroid Build Coastguard Worker	// This includes files that are needed by all, or at least most, instances of a java module type.
53*333d2b36SAndroid Build Coastguard Worker	android.MockFS{
54*333d2b36SAndroid Build Coastguard Worker		// Needed for linter used by java_library.
55*333d2b36SAndroid Build Coastguard Worker		"build/soong/java/lint_defaults.txt": nil,
56*333d2b36SAndroid Build Coastguard Worker		// Needed for java components that invoke Metalava.
57*333d2b36SAndroid Build Coastguard Worker		"build/soong/java/metalava/Android.bp": []byte(`filegroup {name: "metalava-config-files"}`),
58*333d2b36SAndroid Build Coastguard Worker		// Needed for apps that do not provide their own.
59*333d2b36SAndroid Build Coastguard Worker		"build/make/target/product/security": nil,
60*333d2b36SAndroid Build Coastguard Worker		// Required to generate Java used-by API coverage
61*333d2b36SAndroid Build Coastguard Worker		"build/soong/scripts/gen_java_usedby_apex.sh": nil,
62*333d2b36SAndroid Build Coastguard Worker		// Needed for the global lint checks provided from frameworks/base
63*333d2b36SAndroid Build Coastguard Worker		"prebuilts/cmdline-tools/AndroidGlobalLintChecker.jar": nil,
64*333d2b36SAndroid Build Coastguard Worker	}.AddToFixture(),
65*333d2b36SAndroid Build Coastguard Worker	android.PrepareForTestWithBuildFlag("RELEASE_DEFAULT_UPDATABLE_MODULE_VERSION", testDefaultUpdatableModuleVersion),
66*333d2b36SAndroid Build Coastguard Worker)
67*333d2b36SAndroid Build Coastguard Worker
68*333d2b36SAndroid Build Coastguard Workervar prepareForTestWithFrameworkDeps = android.GroupFixturePreparers(
69*333d2b36SAndroid Build Coastguard Worker	// The java default module definitions.
70*333d2b36SAndroid Build Coastguard Worker	android.FixtureAddTextFile(defaultJavaDir+"/Android.bp", gatherRequiredDepsForTest()),
71*333d2b36SAndroid Build Coastguard Worker	// Additional files needed when test disallows non-existent source.
72*333d2b36SAndroid Build Coastguard Worker	android.MockFS{
73*333d2b36SAndroid Build Coastguard Worker		// Needed for framework-res
74*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/AndroidManifest.xml": nil,
75*333d2b36SAndroid Build Coastguard Worker		// Needed for framework
76*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/framework/aidl": nil,
77*333d2b36SAndroid Build Coastguard Worker		// Needed for various deps defined in GatherRequiredDepsForTest()
78*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/a.java":                        nil,
79*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/current.txt":               nil,
80*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/removed.txt":               nil,
81*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/system-current.txt":        nil,
82*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/system-removed.txt":        nil,
83*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/test-current.txt":          nil,
84*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/test-removed.txt":          nil,
85*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/module-lib-current.txt":    nil,
86*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/module-lib-removed.txt":    nil,
87*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/system-server-current.txt": nil,
88*333d2b36SAndroid Build Coastguard Worker		defaultJavaDir + "/api/system-server-removed.txt": nil,
89*333d2b36SAndroid Build Coastguard Worker
90*333d2b36SAndroid Build Coastguard Worker		// Needed for R8 rules on apps
91*333d2b36SAndroid Build Coastguard Worker		"build/make/core/proguard.flags":             nil,
92*333d2b36SAndroid Build Coastguard Worker		"build/make/core/proguard_basic_keeps.flags": nil,
93*333d2b36SAndroid Build Coastguard Worker		"prebuilts/cmdline-tools/shrinker.xml":       nil,
94*333d2b36SAndroid Build Coastguard Worker	}.AddToFixture(),
95*333d2b36SAndroid Build Coastguard Worker)
96*333d2b36SAndroid Build Coastguard Worker
97*333d2b36SAndroid Build Coastguard Workervar prepareForTestWithJavaDefaultModulesBase = android.GroupFixturePreparers(
98*333d2b36SAndroid Build Coastguard Worker	// Make sure that all the module types used in the defaults are registered.
99*333d2b36SAndroid Build Coastguard Worker	PrepareForTestWithJavaBuildComponents,
100*333d2b36SAndroid Build Coastguard Worker	prepareForTestWithFrameworkDeps,
101*333d2b36SAndroid Build Coastguard Worker	// Add dexpreopt compat libs (android.test.base, etc.) and a fake dex2oatd module.
102*333d2b36SAndroid Build Coastguard Worker	dexpreopt.PrepareForTestWithDexpreoptCompatLibs,
103*333d2b36SAndroid Build Coastguard Worker)
104*333d2b36SAndroid Build Coastguard Worker
105*333d2b36SAndroid Build Coastguard Worker// Test fixture preparer that will define default java modules, e.g. standard prebuilt modules.
106*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithJavaDefaultModules = android.GroupFixturePreparers(
107*333d2b36SAndroid Build Coastguard Worker	prepareForTestWithJavaDefaultModulesBase,
108*333d2b36SAndroid Build Coastguard Worker	dexpreopt.FixtureDisableDexpreoptBootImages(true),
109*333d2b36SAndroid Build Coastguard Worker	dexpreopt.FixtureDisableDexpreopt(true),
110*333d2b36SAndroid Build Coastguard Worker)
111*333d2b36SAndroid Build Coastguard Worker
112*333d2b36SAndroid Build Coastguard Worker// Provides everything needed by dexpreopt.
113*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithDexpreopt = android.GroupFixturePreparers(
114*333d2b36SAndroid Build Coastguard Worker	prepareForTestWithJavaDefaultModulesBase,
115*333d2b36SAndroid Build Coastguard Worker	dexpreopt.PrepareForTestWithFakeDex2oatd,
116*333d2b36SAndroid Build Coastguard Worker	dexpreopt.PrepareForTestByEnablingDexpreopt,
117*333d2b36SAndroid Build Coastguard Worker)
118*333d2b36SAndroid Build Coastguard Worker
119*333d2b36SAndroid Build Coastguard Worker// Provides everything needed by dexpreopt except the fake_tool_binary for dex2oatd.
120*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithDexpreoptWithoutFakeDex2oatd = android.GroupFixturePreparers(
121*333d2b36SAndroid Build Coastguard Worker	prepareForTestWithJavaDefaultModulesBase,
122*333d2b36SAndroid Build Coastguard Worker	dexpreopt.PrepareForTestByEnablingDexpreopt,
123*333d2b36SAndroid Build Coastguard Worker)
124*333d2b36SAndroid Build Coastguard Worker
125*333d2b36SAndroid Build Coastguard Worker// Prepare a fixture to use all java module types, mutators and singletons fully.
126*333d2b36SAndroid Build Coastguard Worker//
127*333d2b36SAndroid Build Coastguard Worker// This should only be used by tests that want to run with as much of the build enabled as possible.
128*333d2b36SAndroid Build Coastguard Workervar PrepareForIntegrationTestWithJava = android.GroupFixturePreparers(
129*333d2b36SAndroid Build Coastguard Worker	cc.PrepareForIntegrationTestWithCc,
130*333d2b36SAndroid Build Coastguard Worker	PrepareForTestWithJavaDefaultModules,
131*333d2b36SAndroid Build Coastguard Worker)
132*333d2b36SAndroid Build Coastguard Worker
133*333d2b36SAndroid Build Coastguard Worker// Prepare a fixture with the standard files required by a java_sdk_library module.
134*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithJavaSdkLibraryFiles = android.FixtureMergeMockFs(android.MockFS{
135*333d2b36SAndroid Build Coastguard Worker	"api/current.txt":               nil,
136*333d2b36SAndroid Build Coastguard Worker	"api/removed.txt":               nil,
137*333d2b36SAndroid Build Coastguard Worker	"api/system-current.txt":        nil,
138*333d2b36SAndroid Build Coastguard Worker	"api/system-removed.txt":        nil,
139*333d2b36SAndroid Build Coastguard Worker	"api/test-current.txt":          nil,
140*333d2b36SAndroid Build Coastguard Worker	"api/test-removed.txt":          nil,
141*333d2b36SAndroid Build Coastguard Worker	"api/module-lib-current.txt":    nil,
142*333d2b36SAndroid Build Coastguard Worker	"api/module-lib-removed.txt":    nil,
143*333d2b36SAndroid Build Coastguard Worker	"api/system-server-current.txt": nil,
144*333d2b36SAndroid Build Coastguard Worker	"api/system-server-removed.txt": nil,
145*333d2b36SAndroid Build Coastguard Worker})
146*333d2b36SAndroid Build Coastguard Worker
147*333d2b36SAndroid Build Coastguard Worker// FixtureWithLastReleaseApis creates a preparer that creates prebuilt versions of the specified
148*333d2b36SAndroid Build Coastguard Worker// modules for the `last` API release. By `last` it just means last in the list of supplied versions
149*333d2b36SAndroid Build Coastguard Worker// and as this only provides one version it can be any value.
150*333d2b36SAndroid Build Coastguard Worker//
151*333d2b36SAndroid Build Coastguard Worker// This uses FixtureWithPrebuiltApis under the covers so the limitations of that apply to this.
152*333d2b36SAndroid Build Coastguard Workerfunc FixtureWithLastReleaseApis(moduleNames ...string) android.FixturePreparer {
153*333d2b36SAndroid Build Coastguard Worker	return FixtureWithPrebuiltApis(map[string][]string{
154*333d2b36SAndroid Build Coastguard Worker		"30": moduleNames,
155*333d2b36SAndroid Build Coastguard Worker	})
156*333d2b36SAndroid Build Coastguard Worker}
157*333d2b36SAndroid Build Coastguard Worker
158*333d2b36SAndroid Build Coastguard Worker// PrepareForTestWithPrebuiltsOfCurrentApi is a preparer that creates prebuilt versions of the
159*333d2b36SAndroid Build Coastguard Worker// standard modules for the current version.
160*333d2b36SAndroid Build Coastguard Worker//
161*333d2b36SAndroid Build Coastguard Worker// This uses FixtureWithPrebuiltApis under the covers so the limitations of that apply to this.
162*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithPrebuiltsOfCurrentApi = FixtureWithPrebuiltApis(map[string][]string{
163*333d2b36SAndroid Build Coastguard Worker	"current": {},
164*333d2b36SAndroid Build Coastguard Worker	// Can't have current on its own as it adds a prebuilt_apis module but doesn't add any
165*333d2b36SAndroid Build Coastguard Worker	// .txt files which causes the prebuilt_apis module to fail.
166*333d2b36SAndroid Build Coastguard Worker	"30": {},
167*333d2b36SAndroid Build Coastguard Worker})
168*333d2b36SAndroid Build Coastguard Worker
169*333d2b36SAndroid Build Coastguard Workervar prepareForTestWithFrameworkJacocoInstrumentation = android.GroupFixturePreparers(
170*333d2b36SAndroid Build Coastguard Worker	android.FixtureMergeEnv(map[string]string{
171*333d2b36SAndroid Build Coastguard Worker		"EMMA_INSTRUMENT_FRAMEWORK": "true",
172*333d2b36SAndroid Build Coastguard Worker	}),
173*333d2b36SAndroid Build Coastguard Worker	PrepareForTestWithJacocoInstrumentation,
174*333d2b36SAndroid Build Coastguard Worker)
175*333d2b36SAndroid Build Coastguard Worker
176*333d2b36SAndroid Build Coastguard Worker// PrepareForTestWithJacocoInstrumentation creates a mock jacocoagent library that can be
177*333d2b36SAndroid Build Coastguard Worker// depended on as part of the build process for instrumented Java modules.
178*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithJacocoInstrumentation = android.GroupFixturePreparers(
179*333d2b36SAndroid Build Coastguard Worker	android.FixtureMergeEnv(map[string]string{
180*333d2b36SAndroid Build Coastguard Worker		"EMMA_INSTRUMENT": "true",
181*333d2b36SAndroid Build Coastguard Worker	}),
182*333d2b36SAndroid Build Coastguard Worker	android.FixtureAddFile("jacocoagent/Test.java", nil),
183*333d2b36SAndroid Build Coastguard Worker	android.FixtureAddFile("jacocoagent/Android.bp", []byte(`
184*333d2b36SAndroid Build Coastguard Worker		java_library {
185*333d2b36SAndroid Build Coastguard Worker			name: "jacocoagent",
186*333d2b36SAndroid Build Coastguard Worker			host_supported: true,
187*333d2b36SAndroid Build Coastguard Worker			srcs: ["Test.java"],
188*333d2b36SAndroid Build Coastguard Worker			sdk_version: "current",
189*333d2b36SAndroid Build Coastguard Worker			apex_available: [
190*333d2b36SAndroid Build Coastguard Worker				"//apex_available:anyapex",
191*333d2b36SAndroid Build Coastguard Worker				"//apex_available:platform",
192*333d2b36SAndroid Build Coastguard Worker			],
193*333d2b36SAndroid Build Coastguard Worker			compile_dex: true,
194*333d2b36SAndroid Build Coastguard Worker		}
195*333d2b36SAndroid Build Coastguard Worker	`)),
196*333d2b36SAndroid Build Coastguard Worker)
197*333d2b36SAndroid Build Coastguard Worker
198*333d2b36SAndroid Build Coastguard Worker// FixtureWithPrebuiltApis creates a preparer that will define prebuilt api modules for the
199*333d2b36SAndroid Build Coastguard Worker// specified releases and modules.
200*333d2b36SAndroid Build Coastguard Worker//
201*333d2b36SAndroid Build Coastguard Worker// The supplied map keys are the releases, e.g. current, 29, 30, etc. The values are a list of
202*333d2b36SAndroid Build Coastguard Worker// modules for that release. Due to limitations in the prebuilt_apis module which this preparer
203*333d2b36SAndroid Build Coastguard Worker// uses the set of releases must include at least one numbered release, i.e. it cannot just include
204*333d2b36SAndroid Build Coastguard Worker// "current".
205*333d2b36SAndroid Build Coastguard Worker//
206*333d2b36SAndroid Build Coastguard Worker// This defines a file in the mock file system in a predefined location (prebuilts/sdk/Android.bp)
207*333d2b36SAndroid Build Coastguard Worker// and so only one instance of this can be used in each fixture.
208*333d2b36SAndroid Build Coastguard Workerfunc FixtureWithPrebuiltApis(release2Modules map[string][]string) android.FixturePreparer {
209*333d2b36SAndroid Build Coastguard Worker	return FixtureWithPrebuiltApisAndExtensions(release2Modules, nil)
210*333d2b36SAndroid Build Coastguard Worker}
211*333d2b36SAndroid Build Coastguard Worker
212*333d2b36SAndroid Build Coastguard Workerfunc FixtureWithPrebuiltApisAndExtensions(apiLevel2Modules map[string][]string, extensionLevel2Modules map[string][]string) android.FixturePreparer {
213*333d2b36SAndroid Build Coastguard Worker	mockFS := android.MockFS{}
214*333d2b36SAndroid Build Coastguard Worker	path := "prebuilts/sdk/Android.bp"
215*333d2b36SAndroid Build Coastguard Worker
216*333d2b36SAndroid Build Coastguard Worker	bp := fmt.Sprintf(`
217*333d2b36SAndroid Build Coastguard Worker			prebuilt_apis {
218*333d2b36SAndroid Build Coastguard Worker				name: "sdk",
219*333d2b36SAndroid Build Coastguard Worker				api_dirs: ["%s"],
220*333d2b36SAndroid Build Coastguard Worker				extensions_dir: "extensions",
221*333d2b36SAndroid Build Coastguard Worker				imports_sdk_version: "none",
222*333d2b36SAndroid Build Coastguard Worker				imports_compile_dex: true,
223*333d2b36SAndroid Build Coastguard Worker			}
224*333d2b36SAndroid Build Coastguard Worker		`, strings.Join(android.SortedKeys(apiLevel2Modules), `", "`))
225*333d2b36SAndroid Build Coastguard Worker
226*333d2b36SAndroid Build Coastguard Worker	for release, modules := range apiLevel2Modules {
227*333d2b36SAndroid Build Coastguard Worker		mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))
228*333d2b36SAndroid Build Coastguard Worker	}
229*333d2b36SAndroid Build Coastguard Worker	if extensionLevel2Modules != nil {
230*333d2b36SAndroid Build Coastguard Worker		for release, modules := range extensionLevel2Modules {
231*333d2b36SAndroid Build Coastguard Worker			mockFS.Merge(prebuiltExtensionApiFiles([]string{release}, modules))
232*333d2b36SAndroid Build Coastguard Worker		}
233*333d2b36SAndroid Build Coastguard Worker	}
234*333d2b36SAndroid Build Coastguard Worker	return android.GroupFixturePreparers(
235*333d2b36SAndroid Build Coastguard Worker		android.FixtureAddTextFile(path, bp),
236*333d2b36SAndroid Build Coastguard Worker		android.FixtureMergeMockFs(mockFS),
237*333d2b36SAndroid Build Coastguard Worker	)
238*333d2b36SAndroid Build Coastguard Worker}
239*333d2b36SAndroid Build Coastguard Worker
240*333d2b36SAndroid Build Coastguard Workerfunc FixtureWithPrebuiltIncrementalApis(apiLevel2Modules map[string][]string) android.FixturePreparer {
241*333d2b36SAndroid Build Coastguard Worker	mockFS := android.MockFS{}
242*333d2b36SAndroid Build Coastguard Worker	path := "prebuilts/sdk/Android.bp"
243*333d2b36SAndroid Build Coastguard Worker
244*333d2b36SAndroid Build Coastguard Worker	bp := fmt.Sprintf(`
245*333d2b36SAndroid Build Coastguard Worker			prebuilt_apis {
246*333d2b36SAndroid Build Coastguard Worker				name: "sdk",
247*333d2b36SAndroid Build Coastguard Worker				api_dirs: ["%s"],
248*333d2b36SAndroid Build Coastguard Worker				allow_incremental_platform_api: true,
249*333d2b36SAndroid Build Coastguard Worker				imports_sdk_version: "none",
250*333d2b36SAndroid Build Coastguard Worker				imports_compile_dex: true,
251*333d2b36SAndroid Build Coastguard Worker			}
252*333d2b36SAndroid Build Coastguard Worker		`, strings.Join(android.SortedKeys(apiLevel2Modules), `", "`))
253*333d2b36SAndroid Build Coastguard Worker
254*333d2b36SAndroid Build Coastguard Worker	for release, modules := range apiLevel2Modules {
255*333d2b36SAndroid Build Coastguard Worker		mockFS.Merge(prebuiltApisFilesForModules([]string{release}, modules))
256*333d2b36SAndroid Build Coastguard Worker	}
257*333d2b36SAndroid Build Coastguard Worker	return android.GroupFixturePreparers(
258*333d2b36SAndroid Build Coastguard Worker		android.FixtureAddTextFile(path, bp),
259*333d2b36SAndroid Build Coastguard Worker		android.FixtureMergeMockFs(mockFS),
260*333d2b36SAndroid Build Coastguard Worker	)
261*333d2b36SAndroid Build Coastguard Worker}
262*333d2b36SAndroid Build Coastguard Worker
263*333d2b36SAndroid Build Coastguard Workerfunc prebuiltApisFilesForModules(apiLevels []string, modules []string) map[string][]byte {
264*333d2b36SAndroid Build Coastguard Worker	libs := append([]string{"android"}, modules...)
265*333d2b36SAndroid Build Coastguard Worker
266*333d2b36SAndroid Build Coastguard Worker	fs := make(map[string][]byte)
267*333d2b36SAndroid Build Coastguard Worker	for _, level := range apiLevels {
268*333d2b36SAndroid Build Coastguard Worker		apiLevel := android.ApiLevelForTest(level)
269*333d2b36SAndroid Build Coastguard Worker		for _, sdkKind := range []android.SdkKind{android.SdkPublic, android.SdkSystem, android.SdkModule, android.SdkSystemServer, android.SdkTest} {
270*333d2b36SAndroid Build Coastguard Worker			// A core-for-system-modules file must only be created for the sdk kind that supports it.
271*333d2b36SAndroid Build Coastguard Worker			if sdkKind == systemModuleKind(sdkKind, apiLevel) {
272*333d2b36SAndroid Build Coastguard Worker				fs[fmt.Sprintf("prebuilts/sdk/%s/%s/core-for-system-modules.jar", level, sdkKind)] = nil
273*333d2b36SAndroid Build Coastguard Worker			}
274*333d2b36SAndroid Build Coastguard Worker
275*333d2b36SAndroid Build Coastguard Worker			for _, lib := range libs {
276*333d2b36SAndroid Build Coastguard Worker				// Create a jar file for every library.
277*333d2b36SAndroid Build Coastguard Worker				fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, sdkKind, lib)] = nil
278*333d2b36SAndroid Build Coastguard Worker
279*333d2b36SAndroid Build Coastguard Worker				// No finalized API files for "current"
280*333d2b36SAndroid Build Coastguard Worker				if level != "current" {
281*333d2b36SAndroid Build Coastguard Worker					fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, sdkKind, lib)] = nil
282*333d2b36SAndroid Build Coastguard Worker					fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, sdkKind, lib)] = nil
283*333d2b36SAndroid Build Coastguard Worker				}
284*333d2b36SAndroid Build Coastguard Worker			}
285*333d2b36SAndroid Build Coastguard Worker		}
286*333d2b36SAndroid Build Coastguard Worker		if level == "current" {
287*333d2b36SAndroid Build Coastguard Worker			fs["prebuilts/sdk/current/core/android.jar"] = nil
288*333d2b36SAndroid Build Coastguard Worker		}
289*333d2b36SAndroid Build Coastguard Worker		fs[fmt.Sprintf("prebuilts/sdk/%s/public/framework.aidl", level)] = nil
290*333d2b36SAndroid Build Coastguard Worker	}
291*333d2b36SAndroid Build Coastguard Worker	return fs
292*333d2b36SAndroid Build Coastguard Worker}
293*333d2b36SAndroid Build Coastguard Worker
294*333d2b36SAndroid Build Coastguard Workerfunc prebuiltExtensionApiFiles(extensionLevels []string, modules []string) map[string][]byte {
295*333d2b36SAndroid Build Coastguard Worker	fs := make(map[string][]byte)
296*333d2b36SAndroid Build Coastguard Worker	for _, level := range extensionLevels {
297*333d2b36SAndroid Build Coastguard Worker		for _, sdkKind := range []android.SdkKind{android.SdkPublic, android.SdkSystem, android.SdkModule, android.SdkSystemServer} {
298*333d2b36SAndroid Build Coastguard Worker			for _, lib := range modules {
299*333d2b36SAndroid Build Coastguard Worker				fs[fmt.Sprintf("prebuilts/sdk/extensions/%s/%s/api/%s.txt", level, sdkKind, lib)] = nil
300*333d2b36SAndroid Build Coastguard Worker				fs[fmt.Sprintf("prebuilts/sdk/extensions/%s/%s/api/%s-removed.txt", level, sdkKind, lib)] = nil
301*333d2b36SAndroid Build Coastguard Worker			}
302*333d2b36SAndroid Build Coastguard Worker		}
303*333d2b36SAndroid Build Coastguard Worker	}
304*333d2b36SAndroid Build Coastguard Worker	return fs
305*333d2b36SAndroid Build Coastguard Worker}
306*333d2b36SAndroid Build Coastguard Worker
307*333d2b36SAndroid Build Coastguard Worker// FixtureConfigureBootJars configures the boot jars in both the dexpreopt.GlobalConfig and
308*333d2b36SAndroid Build Coastguard Worker// Config.productVariables structs. As a side effect that enables dexpreopt.
309*333d2b36SAndroid Build Coastguard Workerfunc FixtureConfigureBootJars(bootJars ...string) android.FixturePreparer {
310*333d2b36SAndroid Build Coastguard Worker	artBootJars := []string{}
311*333d2b36SAndroid Build Coastguard Worker	for _, j := range bootJars {
312*333d2b36SAndroid Build Coastguard Worker		artApex := false
313*333d2b36SAndroid Build Coastguard Worker		for _, artApexName := range artApexNames {
314*333d2b36SAndroid Build Coastguard Worker			if strings.HasPrefix(j, artApexName+":") {
315*333d2b36SAndroid Build Coastguard Worker				artApex = true
316*333d2b36SAndroid Build Coastguard Worker				break
317*333d2b36SAndroid Build Coastguard Worker			}
318*333d2b36SAndroid Build Coastguard Worker		}
319*333d2b36SAndroid Build Coastguard Worker		if artApex {
320*333d2b36SAndroid Build Coastguard Worker			artBootJars = append(artBootJars, j)
321*333d2b36SAndroid Build Coastguard Worker		}
322*333d2b36SAndroid Build Coastguard Worker	}
323*333d2b36SAndroid Build Coastguard Worker	return android.GroupFixturePreparers(
324*333d2b36SAndroid Build Coastguard Worker		android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
325*333d2b36SAndroid Build Coastguard Worker			variables.BootJars = android.CreateTestConfiguredJarList(bootJars)
326*333d2b36SAndroid Build Coastguard Worker		}),
327*333d2b36SAndroid Build Coastguard Worker		dexpreopt.FixtureSetBootJars(bootJars...),
328*333d2b36SAndroid Build Coastguard Worker		dexpreopt.FixtureSetArtBootJars(artBootJars...),
329*333d2b36SAndroid Build Coastguard Worker
330*333d2b36SAndroid Build Coastguard Worker		// Add a fake dex2oatd module.
331*333d2b36SAndroid Build Coastguard Worker		dexpreopt.PrepareForTestWithFakeDex2oatd,
332*333d2b36SAndroid Build Coastguard Worker	)
333*333d2b36SAndroid Build Coastguard Worker}
334*333d2b36SAndroid Build Coastguard Worker
335*333d2b36SAndroid Build Coastguard Worker// FixtureConfigureApexBootJars configures the apex boot jars in both the
336*333d2b36SAndroid Build Coastguard Worker// dexpreopt.GlobalConfig and Config.productVariables structs. As a side effect that enables
337*333d2b36SAndroid Build Coastguard Worker// dexpreopt.
338*333d2b36SAndroid Build Coastguard Workerfunc FixtureConfigureApexBootJars(bootJars ...string) android.FixturePreparer {
339*333d2b36SAndroid Build Coastguard Worker	return android.GroupFixturePreparers(
340*333d2b36SAndroid Build Coastguard Worker		android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
341*333d2b36SAndroid Build Coastguard Worker			variables.ApexBootJars = android.CreateTestConfiguredJarList(bootJars)
342*333d2b36SAndroid Build Coastguard Worker		}),
343*333d2b36SAndroid Build Coastguard Worker		dexpreopt.FixtureSetApexBootJars(bootJars...),
344*333d2b36SAndroid Build Coastguard Worker
345*333d2b36SAndroid Build Coastguard Worker		// Add a fake dex2oatd module.
346*333d2b36SAndroid Build Coastguard Worker		dexpreopt.PrepareForTestWithFakeDex2oatd,
347*333d2b36SAndroid Build Coastguard Worker	)
348*333d2b36SAndroid Build Coastguard Worker}
349*333d2b36SAndroid Build Coastguard Worker
350*333d2b36SAndroid Build Coastguard Worker// FixtureUseLegacyCorePlatformApi prepares the fixture by setting the exception list of those
351*333d2b36SAndroid Build Coastguard Worker// modules that are allowed to use the legacy core platform API to be the ones supplied.
352*333d2b36SAndroid Build Coastguard Workerfunc FixtureUseLegacyCorePlatformApi(moduleNames ...string) android.FixturePreparer {
353*333d2b36SAndroid Build Coastguard Worker	lookup := make(map[string]struct{})
354*333d2b36SAndroid Build Coastguard Worker	for _, moduleName := range moduleNames {
355*333d2b36SAndroid Build Coastguard Worker		lookup[moduleName] = struct{}{}
356*333d2b36SAndroid Build Coastguard Worker	}
357*333d2b36SAndroid Build Coastguard Worker	return android.FixtureModifyConfig(func(config android.Config) {
358*333d2b36SAndroid Build Coastguard Worker		// Try and set the legacyCorePlatformApiLookup in the config, the returned value will be the
359*333d2b36SAndroid Build Coastguard Worker		// actual value that is set.
360*333d2b36SAndroid Build Coastguard Worker		cached := config.Once(legacyCorePlatformApiLookupKey, func() interface{} {
361*333d2b36SAndroid Build Coastguard Worker			return lookup
362*333d2b36SAndroid Build Coastguard Worker		})
363*333d2b36SAndroid Build Coastguard Worker		// Make sure that the cached value is the one we need.
364*333d2b36SAndroid Build Coastguard Worker		if !reflect.DeepEqual(cached, lookup) {
365*333d2b36SAndroid Build Coastguard Worker			panic(fmt.Errorf("attempting to set legacyCorePlatformApiLookupKey to %q but it has already been set to %q", lookup, cached))
366*333d2b36SAndroid Build Coastguard Worker		}
367*333d2b36SAndroid Build Coastguard Worker	})
368*333d2b36SAndroid Build Coastguard Worker}
369*333d2b36SAndroid Build Coastguard Worker
370*333d2b36SAndroid Build Coastguard Worker// registerRequiredBuildComponentsForTest registers the build components used by
371*333d2b36SAndroid Build Coastguard Worker// PrepareForTestWithJavaDefaultModules.
372*333d2b36SAndroid Build Coastguard Worker//
373*333d2b36SAndroid Build Coastguard Worker// As functionality is moved out of here into separate FixturePreparer instances they should also
374*333d2b36SAndroid Build Coastguard Worker// be moved into GatherRequiredDepsForTest for use by tests that have not yet switched to use test
375*333d2b36SAndroid Build Coastguard Worker// fixtures.
376*333d2b36SAndroid Build Coastguard Workerfunc registerRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
377*333d2b36SAndroid Build Coastguard Worker	RegisterAARBuildComponents(ctx)
378*333d2b36SAndroid Build Coastguard Worker	RegisterAppBuildComponents(ctx)
379*333d2b36SAndroid Build Coastguard Worker	RegisterAppImportBuildComponents(ctx)
380*333d2b36SAndroid Build Coastguard Worker	RegisterAppSetBuildComponents(ctx)
381*333d2b36SAndroid Build Coastguard Worker	registerBootclasspathBuildComponents(ctx)
382*333d2b36SAndroid Build Coastguard Worker	registerBootclasspathFragmentBuildComponents(ctx)
383*333d2b36SAndroid Build Coastguard Worker	RegisterDexpreoptBootJarsComponents(ctx)
384*333d2b36SAndroid Build Coastguard Worker	RegisterDocsBuildComponents(ctx)
385*333d2b36SAndroid Build Coastguard Worker	RegisterGenRuleBuildComponents(ctx)
386*333d2b36SAndroid Build Coastguard Worker	registerJavaBuildComponents(ctx)
387*333d2b36SAndroid Build Coastguard Worker	registerPlatformBootclasspathBuildComponents(ctx)
388*333d2b36SAndroid Build Coastguard Worker	RegisterPrebuiltApisBuildComponents(ctx)
389*333d2b36SAndroid Build Coastguard Worker	RegisterRuntimeResourceOverlayBuildComponents(ctx)
390*333d2b36SAndroid Build Coastguard Worker	RegisterSdkLibraryBuildComponents(ctx)
391*333d2b36SAndroid Build Coastguard Worker	RegisterStubsBuildComponents(ctx)
392*333d2b36SAndroid Build Coastguard Worker	RegisterSystemModulesBuildComponents(ctx)
393*333d2b36SAndroid Build Coastguard Worker	registerSystemserverClasspathBuildComponents(ctx)
394*333d2b36SAndroid Build Coastguard Worker	android.RegisterApexContributionsBuildComponents(ctx)
395*333d2b36SAndroid Build Coastguard Worker}
396*333d2b36SAndroid Build Coastguard Worker
397*333d2b36SAndroid Build Coastguard Worker// gatherRequiredDepsForTest gathers the module definitions used by
398*333d2b36SAndroid Build Coastguard Worker// PrepareForTestWithJavaDefaultModules.
399*333d2b36SAndroid Build Coastguard Worker//
400*333d2b36SAndroid Build Coastguard Worker// As functionality is moved out of here into separate FixturePreparer instances they should also
401*333d2b36SAndroid Build Coastguard Worker// be moved into GatherRequiredDepsForTest for use by tests that have not yet switched to use test
402*333d2b36SAndroid Build Coastguard Worker// fixtures.
403*333d2b36SAndroid Build Coastguard Workerfunc gatherRequiredDepsForTest() string {
404*333d2b36SAndroid Build Coastguard Worker	var bp string
405*333d2b36SAndroid Build Coastguard Worker
406*333d2b36SAndroid Build Coastguard Worker	extraModules := []string{
407*333d2b36SAndroid Build Coastguard Worker		"core-lambda-stubs",
408*333d2b36SAndroid Build Coastguard Worker		"ext",
409*333d2b36SAndroid Build Coastguard Worker		"android_stubs_current",
410*333d2b36SAndroid Build Coastguard Worker		"android_system_stubs_current",
411*333d2b36SAndroid Build Coastguard Worker		"android_test_stubs_current",
412*333d2b36SAndroid Build Coastguard Worker		"android_module_lib_stubs_current",
413*333d2b36SAndroid Build Coastguard Worker		"android_system_server_stubs_current",
414*333d2b36SAndroid Build Coastguard Worker		"core.current.stubs",
415*333d2b36SAndroid Build Coastguard Worker		"legacy.core.platform.api.stubs",
416*333d2b36SAndroid Build Coastguard Worker		"stable.core.platform.api.stubs",
417*333d2b36SAndroid Build Coastguard Worker		"android_stubs_current_exportable",
418*333d2b36SAndroid Build Coastguard Worker		"android_system_stubs_current_exportable",
419*333d2b36SAndroid Build Coastguard Worker		"android_test_stubs_current_exportable",
420*333d2b36SAndroid Build Coastguard Worker		"android_module_lib_stubs_current_exportable",
421*333d2b36SAndroid Build Coastguard Worker		"android_system_server_stubs_current_exportable",
422*333d2b36SAndroid Build Coastguard Worker		"core.current.stubs.exportable",
423*333d2b36SAndroid Build Coastguard Worker		"legacy.core.platform.api.stubs.exportable",
424*333d2b36SAndroid Build Coastguard Worker		"kotlin-stdlib",
425*333d2b36SAndroid Build Coastguard Worker		"kotlin-stdlib-jdk7",
426*333d2b36SAndroid Build Coastguard Worker		"kotlin-stdlib-jdk8",
427*333d2b36SAndroid Build Coastguard Worker		"kotlin-annotations",
428*333d2b36SAndroid Build Coastguard Worker		"stub-annotations",
429*333d2b36SAndroid Build Coastguard Worker		"aconfig-annotations-lib",
430*333d2b36SAndroid Build Coastguard Worker		"aconfig_storage_stub",
431*333d2b36SAndroid Build Coastguard Worker		"unsupportedappusage",
432*333d2b36SAndroid Build Coastguard Worker	}
433*333d2b36SAndroid Build Coastguard Worker
434*333d2b36SAndroid Build Coastguard Worker	for _, extra := range extraModules {
435*333d2b36SAndroid Build Coastguard Worker		bp += fmt.Sprintf(`
436*333d2b36SAndroid Build Coastguard Worker			java_library {
437*333d2b36SAndroid Build Coastguard Worker				name: "%s",
438*333d2b36SAndroid Build Coastguard Worker				srcs: ["a.java"],
439*333d2b36SAndroid Build Coastguard Worker				sdk_version: "none",
440*333d2b36SAndroid Build Coastguard Worker				system_modules: "stable-core-platform-api-stubs-system-modules",
441*333d2b36SAndroid Build Coastguard Worker				compile_dex: true,
442*333d2b36SAndroid Build Coastguard Worker				is_stubs_module: true,
443*333d2b36SAndroid Build Coastguard Worker			}
444*333d2b36SAndroid Build Coastguard Worker		`, extra)
445*333d2b36SAndroid Build Coastguard Worker	}
446*333d2b36SAndroid Build Coastguard Worker
447*333d2b36SAndroid Build Coastguard Worker	type droidstubsStruct struct {
448*333d2b36SAndroid Build Coastguard Worker		name        string
449*333d2b36SAndroid Build Coastguard Worker		apiSurface  string
450*333d2b36SAndroid Build Coastguard Worker		apiFile     string
451*333d2b36SAndroid Build Coastguard Worker		removedFile string
452*333d2b36SAndroid Build Coastguard Worker	}
453*333d2b36SAndroid Build Coastguard Worker
454*333d2b36SAndroid Build Coastguard Worker	var publicDroidstubs = droidstubsStruct{
455*333d2b36SAndroid Build Coastguard Worker		name:        "api-stubs-docs-non-updatable",
456*333d2b36SAndroid Build Coastguard Worker		apiSurface:  "public",
457*333d2b36SAndroid Build Coastguard Worker		apiFile:     "api/current.txt",
458*333d2b36SAndroid Build Coastguard Worker		removedFile: "api/removed.txt",
459*333d2b36SAndroid Build Coastguard Worker	}
460*333d2b36SAndroid Build Coastguard Worker	var systemDroidstubs = droidstubsStruct{
461*333d2b36SAndroid Build Coastguard Worker		name:        "system-api-stubs-docs-non-updatable",
462*333d2b36SAndroid Build Coastguard Worker		apiSurface:  "system",
463*333d2b36SAndroid Build Coastguard Worker		apiFile:     "api/system-current.txt",
464*333d2b36SAndroid Build Coastguard Worker		removedFile: "api/system-removed.txt",
465*333d2b36SAndroid Build Coastguard Worker	}
466*333d2b36SAndroid Build Coastguard Worker	var testDroidstubs = droidstubsStruct{
467*333d2b36SAndroid Build Coastguard Worker		name:        "test-api-stubs-docs-non-updatable",
468*333d2b36SAndroid Build Coastguard Worker		apiSurface:  "test",
469*333d2b36SAndroid Build Coastguard Worker		apiFile:     "api/test-current.txt",
470*333d2b36SAndroid Build Coastguard Worker		removedFile: "api/test-removed.txt",
471*333d2b36SAndroid Build Coastguard Worker	}
472*333d2b36SAndroid Build Coastguard Worker	var moduleLibDroidstubs = droidstubsStruct{
473*333d2b36SAndroid Build Coastguard Worker		name:        "module-lib-api-stubs-docs-non-updatable",
474*333d2b36SAndroid Build Coastguard Worker		apiSurface:  "module-lib",
475*333d2b36SAndroid Build Coastguard Worker		apiFile:     "api/module-lib-current.txt",
476*333d2b36SAndroid Build Coastguard Worker		removedFile: "api/module-lib-removed.txt",
477*333d2b36SAndroid Build Coastguard Worker	}
478*333d2b36SAndroid Build Coastguard Worker	var systemServerDroidstubs = droidstubsStruct{
479*333d2b36SAndroid Build Coastguard Worker		// This module does not exist but is named this way for consistency
480*333d2b36SAndroid Build Coastguard Worker		name:        "system-server-api-stubs-docs-non-updatable",
481*333d2b36SAndroid Build Coastguard Worker		apiSurface:  "system-server",
482*333d2b36SAndroid Build Coastguard Worker		apiFile:     "api/system-server-current.txt",
483*333d2b36SAndroid Build Coastguard Worker		removedFile: "api/system-server-removed.txt",
484*333d2b36SAndroid Build Coastguard Worker	}
485*333d2b36SAndroid Build Coastguard Worker	var droidstubsStructs = []droidstubsStruct{
486*333d2b36SAndroid Build Coastguard Worker		publicDroidstubs,
487*333d2b36SAndroid Build Coastguard Worker		systemDroidstubs,
488*333d2b36SAndroid Build Coastguard Worker		testDroidstubs,
489*333d2b36SAndroid Build Coastguard Worker		moduleLibDroidstubs,
490*333d2b36SAndroid Build Coastguard Worker		systemServerDroidstubs,
491*333d2b36SAndroid Build Coastguard Worker	}
492*333d2b36SAndroid Build Coastguard Worker
493*333d2b36SAndroid Build Coastguard Worker	extraApiLibraryModules := map[string]droidstubsStruct{
494*333d2b36SAndroid Build Coastguard Worker		"android_stubs_current.from-text":                 publicDroidstubs,
495*333d2b36SAndroid Build Coastguard Worker		"android_system_stubs_current.from-text":          systemDroidstubs,
496*333d2b36SAndroid Build Coastguard Worker		"android_test_stubs_current.from-text":            testDroidstubs,
497*333d2b36SAndroid Build Coastguard Worker		"android_module_lib_stubs_current.from-text":      moduleLibDroidstubs,
498*333d2b36SAndroid Build Coastguard Worker		"android_module_lib_stubs_current_full.from-text": moduleLibDroidstubs,
499*333d2b36SAndroid Build Coastguard Worker		"android_system_server_stubs_current.from-text":   systemServerDroidstubs,
500*333d2b36SAndroid Build Coastguard Worker		"core.current.stubs.from-text":                    publicDroidstubs,
501*333d2b36SAndroid Build Coastguard Worker		"legacy.core.platform.api.stubs.from-text":        publicDroidstubs,
502*333d2b36SAndroid Build Coastguard Worker		"stable.core.platform.api.stubs.from-text":        publicDroidstubs,
503*333d2b36SAndroid Build Coastguard Worker		"core-lambda-stubs.from-text":                     publicDroidstubs,
504*333d2b36SAndroid Build Coastguard Worker		"android-non-updatable.stubs.test_module_lib":     moduleLibDroidstubs,
505*333d2b36SAndroid Build Coastguard Worker	}
506*333d2b36SAndroid Build Coastguard Worker
507*333d2b36SAndroid Build Coastguard Worker	for _, droidstubs := range droidstubsStructs {
508*333d2b36SAndroid Build Coastguard Worker		bp += fmt.Sprintf(`
509*333d2b36SAndroid Build Coastguard Worker			droidstubs {
510*333d2b36SAndroid Build Coastguard Worker				name: "%s",
511*333d2b36SAndroid Build Coastguard Worker				api_surface: "%s",
512*333d2b36SAndroid Build Coastguard Worker				check_api: {
513*333d2b36SAndroid Build Coastguard Worker					current: {
514*333d2b36SAndroid Build Coastguard Worker						api_file: "%s",
515*333d2b36SAndroid Build Coastguard Worker						removed_api_file: "%s",
516*333d2b36SAndroid Build Coastguard Worker					}
517*333d2b36SAndroid Build Coastguard Worker				}
518*333d2b36SAndroid Build Coastguard Worker			}
519*333d2b36SAndroid Build Coastguard Worker		`,
520*333d2b36SAndroid Build Coastguard Worker			droidstubs.name,
521*333d2b36SAndroid Build Coastguard Worker			droidstubs.apiSurface,
522*333d2b36SAndroid Build Coastguard Worker			droidstubs.apiFile,
523*333d2b36SAndroid Build Coastguard Worker			droidstubs.removedFile,
524*333d2b36SAndroid Build Coastguard Worker		)
525*333d2b36SAndroid Build Coastguard Worker	}
526*333d2b36SAndroid Build Coastguard Worker
527*333d2b36SAndroid Build Coastguard Worker	for libName, droidstubs := range extraApiLibraryModules {
528*333d2b36SAndroid Build Coastguard Worker		bp += fmt.Sprintf(`
529*333d2b36SAndroid Build Coastguard Worker		java_api_library {
530*333d2b36SAndroid Build Coastguard Worker			name: "%s",
531*333d2b36SAndroid Build Coastguard Worker			api_contributions: ["%s"],
532*333d2b36SAndroid Build Coastguard Worker			stubs_type: "everything",
533*333d2b36SAndroid Build Coastguard Worker			sdk_version: "none",
534*333d2b36SAndroid Build Coastguard Worker			system_modules: "none",
535*333d2b36SAndroid Build Coastguard Worker		}
536*333d2b36SAndroid Build Coastguard Worker        `, libName, droidstubs.name+".api.contribution")
537*333d2b36SAndroid Build Coastguard Worker	}
538*333d2b36SAndroid Build Coastguard Worker
539*333d2b36SAndroid Build Coastguard Worker	bp += `
540*333d2b36SAndroid Build Coastguard Worker		java_library {
541*333d2b36SAndroid Build Coastguard Worker			name: "framework",
542*333d2b36SAndroid Build Coastguard Worker			srcs: ["a.java"],
543*333d2b36SAndroid Build Coastguard Worker			sdk_version: "none",
544*333d2b36SAndroid Build Coastguard Worker			system_modules: "stable-core-platform-api-stubs-system-modules",
545*333d2b36SAndroid Build Coastguard Worker			aidl: {
546*333d2b36SAndroid Build Coastguard Worker				export_include_dirs: ["framework/aidl"],
547*333d2b36SAndroid Build Coastguard Worker			},
548*333d2b36SAndroid Build Coastguard Worker			compile_dex: true,
549*333d2b36SAndroid Build Coastguard Worker		}
550*333d2b36SAndroid Build Coastguard Worker		java_library {
551*333d2b36SAndroid Build Coastguard Worker			name: "framework-minus-apex",
552*333d2b36SAndroid Build Coastguard Worker			srcs: ["a.java"],
553*333d2b36SAndroid Build Coastguard Worker			sdk_version: "none",
554*333d2b36SAndroid Build Coastguard Worker			system_modules: "stable-core-platform-api-stubs-system-modules",
555*333d2b36SAndroid Build Coastguard Worker			aidl: {
556*333d2b36SAndroid Build Coastguard Worker				export_include_dirs: ["framework/aidl"],
557*333d2b36SAndroid Build Coastguard Worker			},
558*333d2b36SAndroid Build Coastguard Worker			compile_dex: true,
559*333d2b36SAndroid Build Coastguard Worker		}
560*333d2b36SAndroid Build Coastguard Worker
561*333d2b36SAndroid Build Coastguard Worker		android_app {
562*333d2b36SAndroid Build Coastguard Worker			name: "framework-res",
563*333d2b36SAndroid Build Coastguard Worker			sdk_version: "core_platform",
564*333d2b36SAndroid Build Coastguard Worker		}`
565*333d2b36SAndroid Build Coastguard Worker
566*333d2b36SAndroid Build Coastguard Worker	systemModules := []string{
567*333d2b36SAndroid Build Coastguard Worker		"core-public-stubs-system-modules",
568*333d2b36SAndroid Build Coastguard Worker		"core-module-lib-stubs-system-modules",
569*333d2b36SAndroid Build Coastguard Worker		"legacy-core-platform-api-stubs-system-modules",
570*333d2b36SAndroid Build Coastguard Worker		"stable-core-platform-api-stubs-system-modules",
571*333d2b36SAndroid Build Coastguard Worker		"core-public-stubs-system-modules.from-text",
572*333d2b36SAndroid Build Coastguard Worker		"core-module-lib-stubs-system-modules.from-text",
573*333d2b36SAndroid Build Coastguard Worker		"legacy-core-platform-api-stubs-system-modules.from-text",
574*333d2b36SAndroid Build Coastguard Worker		"stable-core-platform-api-stubs-system-modules.from-text",
575*333d2b36SAndroid Build Coastguard Worker	}
576*333d2b36SAndroid Build Coastguard Worker
577*333d2b36SAndroid Build Coastguard Worker	for _, extra := range systemModules {
578*333d2b36SAndroid Build Coastguard Worker		bp += fmt.Sprintf(`
579*333d2b36SAndroid Build Coastguard Worker			java_system_modules {
580*333d2b36SAndroid Build Coastguard Worker				name: "%[1]s",
581*333d2b36SAndroid Build Coastguard Worker				libs: ["%[1]s-lib"],
582*333d2b36SAndroid Build Coastguard Worker			}
583*333d2b36SAndroid Build Coastguard Worker			java_library {
584*333d2b36SAndroid Build Coastguard Worker				name: "%[1]s-lib",
585*333d2b36SAndroid Build Coastguard Worker				sdk_version: "none",
586*333d2b36SAndroid Build Coastguard Worker				system_modules: "none",
587*333d2b36SAndroid Build Coastguard Worker				srcs: ["a.java"],
588*333d2b36SAndroid Build Coastguard Worker			}
589*333d2b36SAndroid Build Coastguard Worker		`, extra)
590*333d2b36SAndroid Build Coastguard Worker	}
591*333d2b36SAndroid Build Coastguard Worker
592*333d2b36SAndroid Build Coastguard Worker	// Make sure that the dex_bootjars singleton module is instantiated for the tests.
593*333d2b36SAndroid Build Coastguard Worker	bp += `
594*333d2b36SAndroid Build Coastguard Worker		dex_bootjars {
595*333d2b36SAndroid Build Coastguard Worker			name: "dex_bootjars",
596*333d2b36SAndroid Build Coastguard Worker		}
597*333d2b36SAndroid Build Coastguard Worker`
598*333d2b36SAndroid Build Coastguard Worker
599*333d2b36SAndroid Build Coastguard Worker	bp += `
600*333d2b36SAndroid Build Coastguard Worker		all_apex_contributions {
601*333d2b36SAndroid Build Coastguard Worker			name: "all_apex_contributions",
602*333d2b36SAndroid Build Coastguard Worker		}
603*333d2b36SAndroid Build Coastguard Worker`
604*333d2b36SAndroid Build Coastguard Worker	return bp
605*333d2b36SAndroid Build Coastguard Worker}
606*333d2b36SAndroid Build Coastguard Worker
607*333d2b36SAndroid Build Coastguard Workerfunc getModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string) []string {
608*333d2b36SAndroid Build Coastguard Worker	t.Helper()
609*333d2b36SAndroid Build Coastguard Worker	module := ctx.ModuleForTests(name, variant).Module()
610*333d2b36SAndroid Build Coastguard Worker	deps := []string{}
611*333d2b36SAndroid Build Coastguard Worker	ctx.VisitDirectDeps(module, func(m blueprint.Module) {
612*333d2b36SAndroid Build Coastguard Worker		deps = append(deps, m.Name())
613*333d2b36SAndroid Build Coastguard Worker	})
614*333d2b36SAndroid Build Coastguard Worker	sort.Strings(deps)
615*333d2b36SAndroid Build Coastguard Worker
616*333d2b36SAndroid Build Coastguard Worker	return deps
617*333d2b36SAndroid Build Coastguard Worker}
618*333d2b36SAndroid Build Coastguard Worker
619*333d2b36SAndroid Build Coastguard Worker// CheckModuleDependencies checks if the expected dependencies of the module are
620*333d2b36SAndroid Build Coastguard Worker// identical to the actual dependencies.
621*333d2b36SAndroid Build Coastguard Workerfunc CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
622*333d2b36SAndroid Build Coastguard Worker	deps := getModuleDependencies(t, ctx, name, variant)
623*333d2b36SAndroid Build Coastguard Worker
624*333d2b36SAndroid Build Coastguard Worker	if actual := deps; !reflect.DeepEqual(expected, actual) {
625*333d2b36SAndroid Build Coastguard Worker		t.Errorf("expected %#q, found %#q", expected, actual)
626*333d2b36SAndroid Build Coastguard Worker	}
627*333d2b36SAndroid Build Coastguard Worker}
628*333d2b36SAndroid Build Coastguard Worker
629*333d2b36SAndroid Build Coastguard Worker// CheckModuleHasDependency returns true if the module depends on the expected dependency.
630*333d2b36SAndroid Build Coastguard Workerfunc CheckModuleHasDependency(t *testing.T, ctx *android.TestContext, name, variant string, expected string) bool {
631*333d2b36SAndroid Build Coastguard Worker	for _, dep := range getModuleDependencies(t, ctx, name, variant) {
632*333d2b36SAndroid Build Coastguard Worker		if dep == expected {
633*333d2b36SAndroid Build Coastguard Worker			return true
634*333d2b36SAndroid Build Coastguard Worker		}
635*333d2b36SAndroid Build Coastguard Worker	}
636*333d2b36SAndroid Build Coastguard Worker	return false
637*333d2b36SAndroid Build Coastguard Worker}
638*333d2b36SAndroid Build Coastguard Worker
639*333d2b36SAndroid Build Coastguard Worker// CheckModuleHasDependency returns true if the module depends on the expected dependency.
640*333d2b36SAndroid Build Coastguard Workerfunc CheckModuleHasDependencyWithTag(t *testing.T, ctx *android.TestContext, name, variant string, desiredTag blueprint.DependencyTag, expected string) bool {
641*333d2b36SAndroid Build Coastguard Worker	module := ctx.ModuleForTests(name, variant).Module()
642*333d2b36SAndroid Build Coastguard Worker	found := false
643*333d2b36SAndroid Build Coastguard Worker	ctx.VisitDirectDepsWithTags(module, func(m blueprint.Module, tag blueprint.DependencyTag) {
644*333d2b36SAndroid Build Coastguard Worker		if tag == desiredTag && m.Name() == expected {
645*333d2b36SAndroid Build Coastguard Worker			found = true
646*333d2b36SAndroid Build Coastguard Worker		}
647*333d2b36SAndroid Build Coastguard Worker	})
648*333d2b36SAndroid Build Coastguard Worker	return found
649*333d2b36SAndroid Build Coastguard Worker}
650*333d2b36SAndroid Build Coastguard Worker
651*333d2b36SAndroid Build Coastguard Worker// CheckPlatformBootclasspathModules returns the apex:module pair for the modules depended upon by
652*333d2b36SAndroid Build Coastguard Worker// the platform-bootclasspath module.
653*333d2b36SAndroid Build Coastguard Workerfunc CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, name string, expected []string) {
654*333d2b36SAndroid Build Coastguard Worker	t.Helper()
655*333d2b36SAndroid Build Coastguard Worker	platformBootclasspath := result.Module(name, "android_common").(*platformBootclasspathModule)
656*333d2b36SAndroid Build Coastguard Worker	pairs := ApexNamePairsFromModules(result.TestContext, platformBootclasspath.configuredModules)
657*333d2b36SAndroid Build Coastguard Worker	android.AssertDeepEquals(t, fmt.Sprintf("%s modules", "platform-bootclasspath"), expected, pairs)
658*333d2b36SAndroid Build Coastguard Worker}
659*333d2b36SAndroid Build Coastguard Worker
660*333d2b36SAndroid Build Coastguard Workerfunc CheckClasspathFragmentProtoContentInfoProvider(t *testing.T, result *android.TestResult, generated bool, contents, outputFilename, installDir string) {
661*333d2b36SAndroid Build Coastguard Worker	t.Helper()
662*333d2b36SAndroid Build Coastguard Worker	p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule)
663*333d2b36SAndroid Build Coastguard Worker	info, _ := android.OtherModuleProvider(result, p, ClasspathFragmentProtoContentInfoProvider)
664*333d2b36SAndroid Build Coastguard Worker
665*333d2b36SAndroid Build Coastguard Worker	android.AssertBoolEquals(t, "classpath proto generated", generated, info.ClasspathFragmentProtoGenerated)
666*333d2b36SAndroid Build Coastguard Worker	android.AssertStringEquals(t, "classpath proto contents", contents, info.ClasspathFragmentProtoContents.String())
667*333d2b36SAndroid Build Coastguard Worker	android.AssertStringEquals(t, "output filepath", outputFilename, info.ClasspathFragmentProtoOutput.Base())
668*333d2b36SAndroid Build Coastguard Worker	android.AssertPathRelativeToTopEquals(t, "install filepath", installDir, info.ClasspathFragmentProtoInstallDir)
669*333d2b36SAndroid Build Coastguard Worker}
670*333d2b36SAndroid Build Coastguard Worker
671*333d2b36SAndroid Build Coastguard Worker// ApexNamePairsFromModules returns the apex:module pair for the supplied modules.
672*333d2b36SAndroid Build Coastguard Workerfunc ApexNamePairsFromModules(ctx *android.TestContext, modules []android.Module) []string {
673*333d2b36SAndroid Build Coastguard Worker	pairs := []string{}
674*333d2b36SAndroid Build Coastguard Worker	for _, module := range modules {
675*333d2b36SAndroid Build Coastguard Worker		pairs = append(pairs, apexNamePairFromModule(ctx, module))
676*333d2b36SAndroid Build Coastguard Worker	}
677*333d2b36SAndroid Build Coastguard Worker	return pairs
678*333d2b36SAndroid Build Coastguard Worker}
679*333d2b36SAndroid Build Coastguard Worker
680*333d2b36SAndroid Build Coastguard Workerfunc apexNamePairFromModule(ctx *android.TestContext, module android.Module) string {
681*333d2b36SAndroid Build Coastguard Worker	name := module.Name()
682*333d2b36SAndroid Build Coastguard Worker	var apex string
683*333d2b36SAndroid Build Coastguard Worker	apexInfo, _ := android.OtherModuleProvider(ctx, module, android.ApexInfoProvider)
684*333d2b36SAndroid Build Coastguard Worker	if apexInfo.IsForPlatform() {
685*333d2b36SAndroid Build Coastguard Worker		apex = "platform"
686*333d2b36SAndroid Build Coastguard Worker	} else {
687*333d2b36SAndroid Build Coastguard Worker		apex = apexInfo.InApexVariants[0]
688*333d2b36SAndroid Build Coastguard Worker	}
689*333d2b36SAndroid Build Coastguard Worker
690*333d2b36SAndroid Build Coastguard Worker	return fmt.Sprintf("%s:%s", apex, name)
691*333d2b36SAndroid Build Coastguard Worker}
692*333d2b36SAndroid Build Coastguard Worker
693*333d2b36SAndroid Build Coastguard Worker// CheckPlatformBootclasspathFragments returns the apex:module pair for the fragments depended upon
694*333d2b36SAndroid Build Coastguard Worker// by the platform-bootclasspath module.
695*333d2b36SAndroid Build Coastguard Workerfunc CheckPlatformBootclasspathFragments(t *testing.T, result *android.TestResult, name string, expected []string) {
696*333d2b36SAndroid Build Coastguard Worker	t.Helper()
697*333d2b36SAndroid Build Coastguard Worker	platformBootclasspath := result.Module(name, "android_common").(*platformBootclasspathModule)
698*333d2b36SAndroid Build Coastguard Worker	pairs := ApexNamePairsFromModules(result.TestContext, platformBootclasspath.fragments)
699*333d2b36SAndroid Build Coastguard Worker	android.AssertDeepEquals(t, fmt.Sprintf("%s fragments", "platform-bootclasspath"), expected, pairs)
700*333d2b36SAndroid Build Coastguard Worker}
701*333d2b36SAndroid Build Coastguard Worker
702*333d2b36SAndroid Build Coastguard Workerfunc CheckHiddenAPIRuleInputs(t *testing.T, message string, expected string, hiddenAPIRule android.TestingBuildParams) {
703*333d2b36SAndroid Build Coastguard Worker	t.Helper()
704*333d2b36SAndroid Build Coastguard Worker	inputs := android.Paths{}
705*333d2b36SAndroid Build Coastguard Worker	if hiddenAPIRule.Input != nil {
706*333d2b36SAndroid Build Coastguard Worker		inputs = append(inputs, hiddenAPIRule.Input)
707*333d2b36SAndroid Build Coastguard Worker	}
708*333d2b36SAndroid Build Coastguard Worker	inputs = append(inputs, hiddenAPIRule.Inputs...)
709*333d2b36SAndroid Build Coastguard Worker	inputs = append(inputs, hiddenAPIRule.Implicits...)
710*333d2b36SAndroid Build Coastguard Worker	inputs = android.SortedUniquePaths(inputs)
711*333d2b36SAndroid Build Coastguard Worker	actual := strings.TrimSpace(strings.Join(inputs.RelativeToTop().Strings(), "\n"))
712*333d2b36SAndroid Build Coastguard Worker	re := regexp.MustCompile(`\n\s+`)
713*333d2b36SAndroid Build Coastguard Worker	expected = strings.TrimSpace(re.ReplaceAllString(expected, "\n"))
714*333d2b36SAndroid Build Coastguard Worker	if actual != expected {
715*333d2b36SAndroid Build Coastguard Worker		t.Errorf("Expected hiddenapi rule inputs - %s:\n%s\nactual inputs:\n%s", message, expected, actual)
716*333d2b36SAndroid Build Coastguard Worker	}
717*333d2b36SAndroid Build Coastguard Worker}
718*333d2b36SAndroid Build Coastguard Worker
719*333d2b36SAndroid Build Coastguard Worker// Check that the merged file create by platform_compat_config_singleton has the correct inputs.
720*333d2b36SAndroid Build Coastguard Workerfunc CheckMergedCompatConfigInputs(t *testing.T, result *android.TestResult, message string, expectedPaths ...string) {
721*333d2b36SAndroid Build Coastguard Worker	sourceGlobalCompatConfig := result.SingletonForTests("platform_compat_config_singleton")
722*333d2b36SAndroid Build Coastguard Worker	allOutputs := sourceGlobalCompatConfig.AllOutputs()
723*333d2b36SAndroid Build Coastguard Worker	android.AssertIntEquals(t, message+": output len", 1, len(allOutputs))
724*333d2b36SAndroid Build Coastguard Worker	output := sourceGlobalCompatConfig.Output(allOutputs[0])
725*333d2b36SAndroid Build Coastguard Worker	android.AssertPathsRelativeToTopEquals(t, message+": inputs", expectedPaths, output.Implicits)
726*333d2b36SAndroid Build Coastguard Worker}
727*333d2b36SAndroid Build Coastguard Worker
728*333d2b36SAndroid Build Coastguard Worker// Register the fake APEX mutator to `android.InitRegistrationContext` as if the real mutator exists
729*333d2b36SAndroid Build Coastguard Worker// at runtime. This must be called in `init()` of a test if the test is going to use the fake APEX
730*333d2b36SAndroid Build Coastguard Worker// mutator. Otherwise, we will be missing the runtime mutator because "soong-apex" is not a
731*333d2b36SAndroid Build Coastguard Worker// dependency, which will cause an inconsistency between testing and runtime mutators.
732*333d2b36SAndroid Build Coastguard Workerfunc RegisterFakeRuntimeApexMutator() {
733*333d2b36SAndroid Build Coastguard Worker	registerFakeApexMutator(android.InitRegistrationContext)
734*333d2b36SAndroid Build Coastguard Worker}
735*333d2b36SAndroid Build Coastguard Worker
736*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithFakeApexMutator = android.GroupFixturePreparers(
737*333d2b36SAndroid Build Coastguard Worker	android.FixtureRegisterWithContext(registerFakeApexMutator),
738*333d2b36SAndroid Build Coastguard Worker)
739*333d2b36SAndroid Build Coastguard Worker
740*333d2b36SAndroid Build Coastguard Workerfunc registerFakeApexMutator(ctx android.RegistrationContext) {
741*333d2b36SAndroid Build Coastguard Worker	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
742*333d2b36SAndroid Build Coastguard Worker		ctx.Transition("apex", &fakeApexMutator{})
743*333d2b36SAndroid Build Coastguard Worker	})
744*333d2b36SAndroid Build Coastguard Worker}
745*333d2b36SAndroid Build Coastguard Worker
746*333d2b36SAndroid Build Coastguard Workertype apexModuleBase interface {
747*333d2b36SAndroid Build Coastguard Worker	ApexAvailable() []string
748*333d2b36SAndroid Build Coastguard Worker}
749*333d2b36SAndroid Build Coastguard Worker
750*333d2b36SAndroid Build Coastguard Workervar _ apexModuleBase = (*Library)(nil)
751*333d2b36SAndroid Build Coastguard Workervar _ apexModuleBase = (*SdkLibrary)(nil)
752*333d2b36SAndroid Build Coastguard Worker
753*333d2b36SAndroid Build Coastguard Worker// A fake APEX mutator that creates a platform variant and an APEX variant for modules with
754*333d2b36SAndroid Build Coastguard Worker// `apex_available`. It helps us avoid a dependency on the real mutator defined in "soong-apex",
755*333d2b36SAndroid Build Coastguard Worker// which will cause a cyclic dependency, and it provides an easy way to create an APEX variant for
756*333d2b36SAndroid Build Coastguard Worker// testing without dealing with all the complexities in the real mutator.
757*333d2b36SAndroid Build Coastguard Workertype fakeApexMutator struct{}
758*333d2b36SAndroid Build Coastguard Worker
759*333d2b36SAndroid Build Coastguard Workerfunc (f *fakeApexMutator) Split(ctx android.BaseModuleContext) []string {
760*333d2b36SAndroid Build Coastguard Worker	switch ctx.Module().(type) {
761*333d2b36SAndroid Build Coastguard Worker	case *Library, *SdkLibrary:
762*333d2b36SAndroid Build Coastguard Worker		return []string{"", "apex1000"}
763*333d2b36SAndroid Build Coastguard Worker	}
764*333d2b36SAndroid Build Coastguard Worker	return []string{""}
765*333d2b36SAndroid Build Coastguard Worker}
766*333d2b36SAndroid Build Coastguard Worker
767*333d2b36SAndroid Build Coastguard Workerfunc (f *fakeApexMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
768*333d2b36SAndroid Build Coastguard Worker	return sourceVariation
769*333d2b36SAndroid Build Coastguard Worker}
770*333d2b36SAndroid Build Coastguard Worker
771*333d2b36SAndroid Build Coastguard Workerfunc (f *fakeApexMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
772*333d2b36SAndroid Build Coastguard Worker	return incomingVariation
773*333d2b36SAndroid Build Coastguard Worker}
774*333d2b36SAndroid Build Coastguard Worker
775*333d2b36SAndroid Build Coastguard Workerfunc (f *fakeApexMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
776*333d2b36SAndroid Build Coastguard Worker	if variation != "" {
777*333d2b36SAndroid Build Coastguard Worker		apexInfo := android.ApexInfo{
778*333d2b36SAndroid Build Coastguard Worker			ApexVariationName: "apex1000",
779*333d2b36SAndroid Build Coastguard Worker		}
780*333d2b36SAndroid Build Coastguard Worker		android.SetProvider(ctx, android.ApexInfoProvider, apexInfo)
781*333d2b36SAndroid Build Coastguard Worker	}
782*333d2b36SAndroid Build Coastguard Worker}
783*333d2b36SAndroid Build Coastguard Worker
784*333d2b36SAndroid Build Coastguard Worker// Applies the given modifier on the boot image config with the given name.
785*333d2b36SAndroid Build Coastguard Workerfunc FixtureModifyBootImageConfig(name string, configModifier func(*bootImageConfig)) android.FixturePreparer {
786*333d2b36SAndroid Build Coastguard Worker	return android.FixtureModifyConfig(func(androidConfig android.Config) {
787*333d2b36SAndroid Build Coastguard Worker		pathCtx := android.PathContextForTesting(androidConfig)
788*333d2b36SAndroid Build Coastguard Worker		config := genBootImageConfigRaw(pathCtx)
789*333d2b36SAndroid Build Coastguard Worker		configModifier(config[name])
790*333d2b36SAndroid Build Coastguard Worker	})
791*333d2b36SAndroid Build Coastguard Worker}
792*333d2b36SAndroid Build Coastguard Worker
793*333d2b36SAndroid Build Coastguard Worker// Sets the value of `installDir` of the boot image config with the given name.
794*333d2b36SAndroid Build Coastguard Workerfunc FixtureSetBootImageInstallDirOnDevice(name string, installDir string) android.FixturePreparer {
795*333d2b36SAndroid Build Coastguard Worker	return FixtureModifyBootImageConfig(name, func(config *bootImageConfig) {
796*333d2b36SAndroid Build Coastguard Worker		config.installDir = installDir
797*333d2b36SAndroid Build Coastguard Worker	})
798*333d2b36SAndroid Build Coastguard Worker}
799*333d2b36SAndroid Build Coastguard Worker
800*333d2b36SAndroid Build Coastguard Workervar PrepareForTestWithTransitiveClasspathEnabled = android.PrepareForTestWithBuildFlag("RELEASE_USE_TRANSITIVE_JARS_IN_CLASSPATH", "true")
801