From 6a1160e749cce53e478227c41e374ad3bc81edd1 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Sun, 7 Mar 2021 15:47:42 +0000 Subject: [PATCH] Convert cc/prebuilt_test.go to use fixtures Bug: 181070625 Test: m nothing Change-Id: I6048812962382e2adaf79d941a24e5c0ffdd9b25 --- cc/prebuilt_test.go | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index ee4de6ee8..20274b2ba 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go @@ -23,27 +23,16 @@ import ( "github.com/google/blueprint" ) -func testPrebuilt(t *testing.T, bp string, fs map[string][]byte, handlers ...configCustomizer) *android.TestContext { - config := TestConfig(buildDir, android.Android, nil, bp, fs) - ctx := CreateTestContext(config) +var prebuiltFixtureFactory = ccFixtureFactory.Extend( + android.PrepareForTestWithAndroidMk, +) - // Enable androidmk support. - // * Register the singleton - // * Configure that we are inside make - // * Add CommonOS to ensure that androidmk processing works. - android.RegisterAndroidMkBuildComponents(ctx) - android.SetKatiEnabledForTests(config) +func testPrebuilt(t *testing.T, bp string, fs android.MockFS, handlers ...android.FixturePreparer) *android.TestContext { + result := prebuiltFixtureFactory.Extend( + fs.AddToFixture(), + ).Extend(handlers...).RunTestWithBp(t, bp) - for _, handler := range handlers { - handler(config) - } - - ctx.Register() - _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) - android.FailIfErrored(t, errs) - _, errs = ctx.PrepareBuildActions(config) - android.FailIfErrored(t, errs) - return ctx + return result.TestContext } type configCustomizer func(config android.Config) @@ -370,9 +359,11 @@ func TestPrebuiltLibrarySanitized(t *testing.T) { assertString(t, static2.OutputFile().Path().Base(), "libf.a") // With SANITIZE_TARGET=hwaddress - ctx = testPrebuilt(t, bp, fs, func(config android.Config) { - config.TestProductVariables.SanitizeDevice = []string{"hwaddress"} - }) + ctx = testPrebuilt(t, bp, fs, + 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") assertString(t, shared_rule.Input.String(), "hwasan/libf.so")