Merge "Convert ...InstallHwasan.. tests to use fixtures" am: ef0449b0f3

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2529a69e75f0c15e0ede332865792ad82670207f
This commit is contained in:
Paul Duffin
2021-03-15 11:33:54 +00:00
committed by Automerger Merge Worker

View File

@@ -127,6 +127,8 @@ func withUnbundledBuild(_ map[string][]byte, config android.Config) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
} }
var emptyFixtureFactory = android.NewFixtureFactory(&buildDir)
var apexFixtureFactory = android.NewFixtureFactory( var apexFixtureFactory = android.NewFixtureFactory(
&buildDir, &buildDir,
// General preparers in alphabetical order as test infrastructure will enforce correct // General preparers in alphabetical order as test infrastructure will enforce correct
@@ -1316,9 +1318,10 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
} }
func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) { var prepareForTestOfRuntimeApexWithHwasan = android.GroupFixturePreparers(
ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) { cc.PrepareForTestWithCcBuildComponents,
bp := ` PrepareForTestWithApexBuildComponents,
android.FixtureAddTextFile("bionic/apex/Android.bp", `
apex { apex {
name: "com.android.runtime", name: "com.android.runtime",
key: "com.android.runtime.key", key: "com.android.runtime.key",
@@ -1331,7 +1334,12 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
public_key: "testkey.avbpubkey", public_key: "testkey.avbpubkey",
private_key: "testkey.pem", private_key: "testkey.pem",
} }
`),
android.FixtureAddFile("system/sepolicy/apex/com.android.runtime-file_contexts", nil),
)
func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
result := emptyFixtureFactory.Extend(prepareForTestOfRuntimeApexWithHwasan).RunTestWithBp(t, `
cc_library { cc_library {
name: "libc", name: "libc",
no_libcrt: true, no_libcrt: true,
@@ -1358,12 +1366,8 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
sanitize: { sanitize: {
never: true, never: true,
}, },
} } `)
` ctx := result.TestContext
// override bp to use hard-coded names: com.android.runtime and libc
fs["Android.bp"] = []byte(bp)
fs["system/sepolicy/apex/com.android.runtime-file_contexts"] = nil
})
ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_image", []string{ ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_image", []string{
"lib64/bionic/libc.so", "lib64/bionic/libc.so",
@@ -1381,21 +1385,12 @@ func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
} }
func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) { func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) {
ctx := testApex(t, "", func(fs map[string][]byte, config android.Config) { result := emptyFixtureFactory.Extend(
bp := ` prepareForTestOfRuntimeApexWithHwasan,
apex { android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
name: "com.android.runtime", variables.SanitizeDevice = []string{"hwaddress"}
key: "com.android.runtime.key", }),
native_shared_libs: ["libc"], ).RunTestWithBp(t, `
updatable: false,
}
apex_key {
name: "com.android.runtime.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
cc_library { cc_library {
name: "libc", name: "libc",
no_libcrt: true, no_libcrt: true,
@@ -1419,13 +1414,8 @@ func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) {
never: true, never: true,
}, },
} }
` `)
// override bp to use hard-coded names: com.android.runtime and libc ctx := result.TestContext
fs["Android.bp"] = []byte(bp)
fs["system/sepolicy/apex/com.android.runtime-file_contexts"] = nil
config.TestProductVariables.SanitizeDevice = []string{"hwaddress"}
})
ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_image", []string{ ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_image", []string{
"lib64/bionic/libc.so", "lib64/bionic/libc.so",