Update sh_test conversion to handle data_bins and test_configs properly

sh_test.data_bins are used to mark special executable dependencies which should be installed alongside the test entry point's cwd as siblings. This change makes it such that the Tradefed rule places them at the expected location. In addition, this change also incorporates the `tradefed.TestConfigAttributes` to handle the test_configs conversions.

Test: bp2build.sh
Bug: 283486885
Change-Id: Ifeb049c13ae208c785dbdc858f589be8f21109d1
diff --git a/bp2build/sh_test_conversion_test.go b/bp2build/sh_test_conversion_test.go
index e99d566..48fd077 100644
--- a/bp2build/sh_test_conversion_test.go
+++ b/bp2build/sh_test_conversion_test.go
@@ -22,11 +22,18 @@
 )
 
 func TestShTestSimple(t *testing.T) {
-	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
-		Description:                "sh_test test",
-		ModuleTypeUnderTest:        "sh_test",
+	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: [
@@ -47,28 +54,37 @@
 }`,
 		ExpectedBazelTargets: []string{
 			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
-				"srcs": `["empty.sh"]`,
+				"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",
     ]`,
-				"test_config":          `"art-gtests-target-install-apex.xml"`,
-				"test_config_template": `":art-run-test-target-template"`,
-				"auto_gen_config":      "False",
-				"tags":                 `["no-remote"]`,
+				"data_bins": `[
+        ":android.hardware.bluetooth@1.1-service.sim",
+        ":android.hardware.bluetooth@1.1-impl-sim",
+    ]`,
+				"tags": `["no-remote"]`,
 			})},
 	})
 }
 
 func TestShTestHostSimple(t *testing.T) {
-	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
-		Description:                "sh_test_host test",
-		ModuleTypeUnderTest:        "sh_test_host",
+	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: [
@@ -89,18 +105,20 @@
 }`,
 		ExpectedBazelTargets: []string{
 			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
-				"srcs": `["empty.sh"]`,
+				"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",
     ]`,
-				"tags":                 `["no-remote"]`,
-				"test_config":          `"art-gtests-target-install-apex.xml"`,
-				"test_config_template": `":art-run-test-target-template"`,
-				"auto_gen_config":      "False",
+				"data_bins": `[
+        ":android.hardware.bluetooth@1.1-service.sim",
+        ":android.hardware.bluetooth@1.1-impl-sim",
+    ]`,
+				"tags": `["no-remote"]`,
 				"target_compatible_with": `select({
         "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
         "//conditions:default": [],
@@ -109,12 +127,131 @@
 	})
 }
 
-func TestShTestSimpleUnset(t *testing.T) {
-	RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
-		Description:                "sh_test test",
-		ModuleTypeUnderTest:        "sh_test",
+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: [
+        "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_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"
+    ],
+    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: [
@@ -132,13 +269,18 @@
 }`,
 		ExpectedBazelTargets: []string{
 			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
-				"srcs": `["empty.sh"]`,
+				"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",
     ]`,
 				"tags": `["no-remote"]`,
 			})},
@@ -146,11 +288,18 @@
 }
 
 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: [
@@ -168,13 +317,18 @@
 }`,
 		ExpectedBazelTargets: []string{
 			MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{
-				"srcs": `["empty.sh"]`,
+				"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({