Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f11bced3 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Convert cc/prebuilt_test.go to use fixtures"

parents d7bbeffe 6a1160e7
Loading
Loading
Loading
Loading
+14 −23
Original line number Diff line number Diff line
@@ -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)

	// 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)
var prebuiltFixtureFactory = ccFixtureFactory.Extend(
	android.PrepareForTestWithAndroidMk,
)

	for _, handler := range handlers {
		handler(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)

	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")