Convert cc/prebuilt_test.go to use fixtures

Bug: 181070625
Test: m nothing
Change-Id: I6048812962382e2adaf79d941a24e5c0ffdd9b25
This commit is contained in:
Paul Duffin 2021-03-07 15:47:42 +00:00
parent 6c9da044f8
commit 6a1160e749
1 changed files with 13 additions and 22 deletions

View File

@ -23,27 +23,16 @@ import (
"github.com/google/blueprint" "github.com/google/blueprint"
) )
func testPrebuilt(t *testing.T, bp string, fs map[string][]byte, handlers ...configCustomizer) *android.TestContext { var prebuiltFixtureFactory = ccFixtureFactory.Extend(
config := TestConfig(buildDir, android.Android, nil, bp, fs) android.PrepareForTestWithAndroidMk,
ctx := CreateTestContext(config) )
// Enable androidmk support. func testPrebuilt(t *testing.T, bp string, fs android.MockFS, handlers ...android.FixturePreparer) *android.TestContext {
// * Register the singleton result := prebuiltFixtureFactory.Extend(
// * Configure that we are inside make fs.AddToFixture(),
// * Add CommonOS to ensure that androidmk processing works. ).Extend(handlers...).RunTestWithBp(t, bp)
android.RegisterAndroidMkBuildComponents(ctx)
android.SetKatiEnabledForTests(config)
for _, handler := range handlers { return result.TestContext
handler(config)
}
ctx.Register()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
android.FailIfErrored(t, errs)
return ctx
} }
type configCustomizer func(config android.Config) type configCustomizer func(config android.Config)
@ -370,9 +359,11 @@ func TestPrebuiltLibrarySanitized(t *testing.T) {
assertString(t, static2.OutputFile().Path().Base(), "libf.a") assertString(t, static2.OutputFile().Path().Base(), "libf.a")
// With SANITIZE_TARGET=hwaddress // With SANITIZE_TARGET=hwaddress
ctx = testPrebuilt(t, bp, fs, func(config android.Config) { ctx = testPrebuilt(t, bp, fs,
config.TestProductVariables.SanitizeDevice = []string{"hwaddress"} android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
}) variables.SanitizeDevice = []string{"hwaddress"}
}),
)
shared_rule = ctx.ModuleForTests("libtest", "android_arm64_armv8-a_shared_hwasan").Rule("android/soong/cc.strip") shared_rule = ctx.ModuleForTests("libtest", "android_arm64_armv8-a_shared_hwasan").Rule("android/soong/cc.strip")
assertString(t, shared_rule.Input.String(), "hwasan/libf.so") assertString(t, shared_rule.Input.String(), "hwasan/libf.so")