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

Commit 10d38d20 authored by Jason Wu's avatar Jason Wu Committed by Automerger Merge Worker
Browse files

Merge "Update sh_test conversion to handle data_bins and test_configs...

Merge "Update sh_test conversion to handle data_bins and test_configs properly" into main am: 5a2a94eb am: b221ea83 am: 8488449e am: 76a39b9c am: 9f8d793b

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



Change-Id: I53ae7a9fe0ef1cbd2a68bfe25223fed0225a698e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c3d67abe 9f8d793b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -350,6 +350,8 @@ var (
		"packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue,
		"packages/modules/NeuralNetworks/apex":               Bp2BuildDefaultTrue,
		"packages/modules/NeuralNetworks/apex/testing":       Bp2BuildDefaultTrue,
		"packages/modules/SdkExtensions/gen_sdk":             Bp2BuildDefaultTrue,
		"packages/modules/common/proto":                      Bp2BuildDefaultTrue,
		"packages/providers/MediaProvider/tools/dialogs":     Bp2BuildDefaultFalse, // TODO(b/242834374)
		"packages/screensavers/Basic":                        Bp2BuildDefaultTrue,
		"packages/services/Car/tests/SampleRearViewCamera":   Bp2BuildDefaultFalse, // TODO(b/242834321)
@@ -1088,7 +1090,7 @@ var (
		"versioner", // TODO(b/228313961):  depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library

		// requires host tools for apexer
		"apexer_test", "apexer_test_host_tools", "host_apex_verifier",
		"apexer_test", "apexer_test_host_tools", "host_apex_verifier", "host-apex-verifier",

		// java bugs
		"libbase_ndk",           // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases)
+196 −42
Original line number Diff line number Diff line
@@ -22,11 +22,18 @@ import (
)

func TestShTestSimple(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:         "sh_test test",
		ModuleTypeUnderTest: "sh_test",
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
		ModuleTypeUnderTestFactory: sh.ShTestFactory,
		Blueprint: `sh_test{
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") + `sh_test{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
@@ -48,27 +55,36 @@ func TestShTestSimple(t *testing.T) {
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":    `["empty.sh"]`,
				"runs_on": `["device"]`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        "android.hardware.bluetooth@1.1-service.sim",
        "android.hardware.bluetooth@1.1-impl-sim",
        "libc++",
        "libcrypto",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"test_config":          `"art-gtests-target-install-apex.xml"`,
				"test_config_template": `":art-run-test-target-template"`,
				"auto_gen_config":      "False",
				"tags": `["no-remote"]`,
			})},
	})
}

func TestShTestHostSimple(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:         "sh_test_host test",
		ModuleTypeUnderTest: "sh_test_host",
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
		ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
		Blueprint: `sh_test_host{
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") + `sh_test_host{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
@@ -90,17 +106,19 @@ func TestShTestHostSimple(t *testing.T) {
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":    `["empty.sh"]`,
				"runs_on": `["host_without_device"]`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        "android.hardware.bluetooth@1.1-service.sim",
        "android.hardware.bluetooth@1.1-impl-sim",
        "libc++",
        "libcrypto",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"tags": `["no-remote"]`,
				"test_config":          `"art-gtests-target-install-apex.xml"`,
				"test_config_template": `":art-run-test-target-template"`,
				"auto_gen_config":      "False",
				"target_compatible_with": `select({
        "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
        "//conditions:default": [],
@@ -109,12 +127,20 @@ func TestShTestHostSimple(t *testing.T) {
	})
}

func TestShTestSimpleUnset(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
func TestShTestAutogen(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:         "sh_test test",
		ModuleTypeUnderTest: "sh_test",
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"},
		ModuleTypeUnderTestFactory: sh.ShTestFactory,
		Blueprint: `sh_test{
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") +
			simpleModule("filegroup", "art-run-test-target-template") + `sh_test{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
@@ -127,18 +153,134 @@ func TestShTestSimpleUnset(t *testing.T) {
    ],
    data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
    data_libs: ["libc++","libcrypto"],
		test_config: "art-gtests-target-install-apex.xml",
		test_config_template: ":art-run-test-target-template",
		auto_gen_config: true,
    test_options:{tags: ["no-remote"],
	},
}`,
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":                      `["empty.sh"]`,
				"runs_on":                   `["device"]`,
				"auto_generate_test_config": "True",
				"target_compatible_with":    `["//build/bazel/platforms/os:android"]`,
				"template_test_config":      `":art-run-test-target-template"`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"tags": `["no-remote"]`,
			})},
	})
}

func TestShTestHostAutogen(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:         "sh_test_host test",
		ModuleTypeUnderTest: "sh_test_host",
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"},
		ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") +
			simpleModule("filegroup", "art-run-test-target-template") + `sh_test_host{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
        "sts",
        "sts-lite",
    ],
    data_bins: [
        "android.hardware.bluetooth@1.1-service.sim",
        "android.hardware.bluetooth@1.1-impl-sim",
        "libc++",
        "libcrypto",
        "android.hardware.bluetooth@1.1-impl-sim"
    ],
    data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
    data_libs: ["libc++","libcrypto"],
		test_config: "art-gtests-target-install-apex.xml",
		test_config_template: ":art-run-test-target-template",
		auto_gen_config: true,
    test_options:{tags: ["no-remote"],
	},
}`,
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":                      `["empty.sh"]`,
				"runs_on":                   `["host_without_device"]`,
				"auto_generate_test_config": "True",
				"target_compatible_with": `select({
        "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
        "//conditions:default": [],
    })`,
				"template_test_config": `":art-run-test-target-template"`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"tags": `["no-remote"]`,
			})},
	})
}
func TestShTestSimpleUnset(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:         "sh_test test",
		ModuleTypeUnderTest: "sh_test",
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
		ModuleTypeUnderTestFactory: sh.ShTestFactory,
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") + `sh_test{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
        "sts",
        "sts-lite",
    ],
    data_bins: [
        "android.hardware.bluetooth@1.1-service.sim",
        "android.hardware.bluetooth@1.1-impl-sim"
    ],
    data: ["android.hardware.bluetooth@1.1-service.sim.rc"],
    data_libs: ["libc++","libcrypto"],
    test_options:{tags: ["no-remote"],
	},
}`,
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":    `["empty.sh"]`,
				"runs_on": `["device"]`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"tags": `["no-remote"]`,
			})},
@@ -146,11 +288,18 @@ func TestShTestSimpleUnset(t *testing.T) {
}

func TestShTestHostSimpleUnset(t *testing.T) {
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
		ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
	}, Bp2buildTestCase{
		Description:                "sh_test_host test",
		ModuleTypeUnderTest:        "sh_test_host",
		ModuleTypeUnderTestFactory: sh.ShTestHostFactory,
		Blueprint: `sh_test_host{
		StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim",
			"android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"},
		Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") +
			simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") +
			simpleModule("filegroup", "libc++") +
			simpleModule("filegroup", "libcrypto") + `sh_test_host{
    name: "sts-rootcanal-sidebins",
    src: "empty.sh",
    test_suites: [
@@ -169,12 +318,17 @@ func TestShTestHostSimpleUnset(t *testing.T) {
		ExpectedBazelTargets: []string{
			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
				"srcs":    `["empty.sh"]`,
				"runs_on": `["host_without_device"]`,
				"data": `[
        "android.hardware.bluetooth@1.1-service.sim.rc",
        "android.hardware.bluetooth@1.1-service.sim",
        "android.hardware.bluetooth@1.1-impl-sim",
        "libc++",
        "libcrypto",
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
        ":libc++",
        ":libcrypto",
    ]`,
				"data_bins": `[
        ":android.hardware.bluetooth@1.1-service.sim",
        ":android.hardware.bluetooth@1.1-impl-sim",
    ]`,
				"tags": `["no-remote"]`,
				"target_compatible_with": `select({
+30 −16
Original line number Diff line number Diff line
@@ -577,10 +577,10 @@ type bazelShBinaryAttributes struct {
type bazelShTestAttributes struct {
	Srcs      bazel.LabelListAttribute
	Data      bazel.LabelListAttribute
	Data_bins bazel.LabelListAttribute
	Tags      bazel.StringListAttribute
	Test_config          *string
	Test_config_template *string
	Auto_gen_config      *bool
	Runs_on   bazel.StringListAttribute
	tradefed.TestConfigAttributes
}

func (m *ShBinary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
@@ -615,28 +615,42 @@ func (m *ShTest) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
	srcs := bazel.MakeLabelListAttribute(
		android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))

	combinedData := append(m.testProperties.Data, m.testProperties.Data_bins...)
	combinedData = append(combinedData, m.testProperties.Data_libs...)
	dataBins := bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, m.testProperties.Data_bins))

	data := bazel.MakeLabelListAttribute(
		android.BazelLabelForModuleSrc(ctx, combinedData))
	var combinedData bazel.LabelList
	combinedData.Append(android.BazelLabelForModuleSrc(ctx, m.testProperties.Data))
	combinedData.Append(android.BazelLabelForModuleDeps(ctx, m.testProperties.Data_bins))
	combinedData.Append(android.BazelLabelForModuleDeps(ctx, m.testProperties.Data_libs))
	data := bazel.MakeLabelListAttribute(combinedData)

	tags := bazel.MakeStringListAttribute(
		m.testProperties.Test_options.Tags)

	test_config := m.testProperties.Test_config
	testConfigAttributes := tradefed.GetTestConfigAttributes(
		ctx,
		m.testProperties.Test_config,
		[]string{},
		m.testProperties.Auto_gen_config,
		m.testProperties.Test_suites,
		m.testProperties.Test_config_template,
		nil,
		nil,
	)

	test_config_template := m.testProperties.Test_config_template
	unitTest := m.testProperties.Test_options.Unit_test

	auto_gen_config := m.testProperties.Auto_gen_config
	runs_on := bazel.MakeStringListAttribute(android.RunsOn(
		m.ModuleBase.HostSupported(),
		m.ModuleBase.DeviceSupported(),
		(unitTest != nil && *unitTest)))

	attrs := &bazelShTestAttributes{
		Srcs:                 srcs,
		Data:                 data,
		Data_bins:            dataBins,
		Tags:                 tags,
		Test_config:          test_config,
		Test_config_template: test_config_template,
		Auto_gen_config:      auto_gen_config,
		Runs_on:              runs_on,
		TestConfigAttributes: testConfigAttributes,
	}

	props := bazel.BazelTargetModuleProperties{