summaryrefslogtreecommitdiff
path: root/java/dexpreopt_config_testing.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-01-17 12:14:44 -0800
committer Colin Cross <ccross@android.com> 2024-01-17 16:10:37 -0800
commit84ed511cebcf664eb15602a41bf74bc0f3e3440e (patch)
treeeb9f873306eb806498b40fffea24f10680989d42 /java/dexpreopt_config_testing.go
parentbcf53701b7d4a78988a202375b48606457fd1b2f (diff)
Fix data race in dex_bootjars
Move fields in bootImageConfig that are written during GenerateAndroidBuildActions into a provider to avoid a data race. Test: go test -race ./... Change-Id: I0d6783530843889b96f32d748bda7824493d2e32
Diffstat (limited to 'java/dexpreopt_config_testing.go')
-rw-r--r--java/dexpreopt_config_testing.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/java/dexpreopt_config_testing.go b/java/dexpreopt_config_testing.go
index 41d4b72a1..104829f5f 100644
--- a/java/dexpreopt_config_testing.go
+++ b/java/dexpreopt_config_testing.go
@@ -523,7 +523,7 @@ func checkArtBootImageConfig(t *testing.T, result *android.TestResult, mutated b
},
}
- checkBootImageConfig(t, imageConfig, mutated, expected)
+ checkBootImageConfig(t, result, imageConfig, mutated, expected)
}
// getFrameworkImageConfig gets the framework bootImageConfig that was created during the test.
@@ -904,7 +904,7 @@ func checkFrameworkBootImageConfig(t *testing.T, result *android.TestResult, mut
profileLicenseMetadataFile: expectedLicenseMetadataFile,
}
- checkBootImageConfig(t, imageConfig, mutated, expected)
+ checkBootImageConfig(t, result, imageConfig, mutated, expected)
}
// getMainlineImageConfig gets the framework bootImageConfig that was created during the test.
@@ -1183,7 +1183,7 @@ func CheckMainlineBootImageConfig(t *testing.T, result *android.TestResult) {
profileLicenseMetadataFile: expectedLicenseMetadataFile,
}
- checkBootImageConfig(t, imageConfig, false, expected)
+ checkBootImageConfig(t, result, imageConfig, false, expected)
}
// clearMutatedFields clears fields in the expectedConfig that correspond to fields in the
@@ -1211,19 +1211,19 @@ func clearMutatedFields(expected *expectedConfig) {
// zero value so that they will match the unmodified values in the boot image.
//
// It runs the checks in an image specific subtest of the current test.
-func checkBootImageConfig(t *testing.T, imageConfig *bootImageConfig, mutated bool, expected *expectedConfig) {
+func checkBootImageConfig(t *testing.T, result *android.TestResult, imageConfig *bootImageConfig, mutated bool, expected *expectedConfig) {
if !mutated {
clearMutatedFields(expected)
}
t.Run(imageConfig.name, func(t *testing.T) {
- nestedCheckBootImageConfig(t, imageConfig, expected)
+ nestedCheckBootImageConfig(t, result, imageConfig, mutated, expected)
})
}
// nestedCheckBootImageConfig does the work of comparing the image against the expected values and
// is run in an image specific subtest.
-func nestedCheckBootImageConfig(t *testing.T, imageConfig *bootImageConfig, expected *expectedConfig) {
+func nestedCheckBootImageConfig(t *testing.T, result *android.TestResult, imageConfig *bootImageConfig, mutated bool, expected *expectedConfig) {
android.AssertStringEquals(t, "name", expected.name, imageConfig.name)
android.AssertStringEquals(t, "stem", expected.stem, imageConfig.stem)
android.AssertPathRelativeToTopEquals(t, "dir", expected.dir, imageConfig.dir)
@@ -1234,8 +1234,13 @@ func nestedCheckBootImageConfig(t *testing.T, imageConfig *bootImageConfig, expe
android.AssertPathsRelativeToTopEquals(t, "dexPathsDeps", expected.dexPathsDeps, imageConfig.dexPathsDeps.Paths())
// dexPathsByModule is just a different representation of the other information in the config.
android.AssertPathRelativeToTopEquals(t, "zip", expected.zip, imageConfig.zip)
- assertInstallsEqual(t, "profileInstalls", expected.profileInstalls, imageConfig.profileInstalls)
- android.AssertStringEquals(t, "profileLicenseMetadataFile", expected.profileLicenseMetadataFile, imageConfig.profileLicenseMetadataFile.RelativeToTop().String())
+
+ if !mutated {
+ dexBootJarModule := result.ModuleForTests("dex_bootjars", "android_common")
+ profileInstallInfo, _ := android.SingletonModuleProvider(result, dexBootJarModule.Module(), profileInstallInfoProvider)
+ assertInstallsEqual(t, "profileInstalls", expected.profileInstalls, profileInstallInfo.profileInstalls)
+ android.AssertStringEquals(t, "profileLicenseMetadataFile", expected.profileLicenseMetadataFile, profileInstallInfo.profileLicenseMetadataFile.RelativeToTop().String())
+ }
android.AssertIntEquals(t, "variant count", 4, len(imageConfig.variants))
for i, variant := range imageConfig.variants {