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

Commit c6a321e4 authored by Priyanka Advani's avatar Priyanka Advani Committed by Gerrit Code Review
Browse files

Revert "Change test_module_config from copying files to symlink ..."

Revert submission 3060229-ron-tmc-symlinks

Reason for revert: Droidmonitor created revert due to b/344045516

Reverted changes: /q/submissionid:3060229-ron-tmc-symlinks

Change-Id: If5045366677163560cdae95c0ab74256b4b49b9a
parent f216af56
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -1380,8 +1380,6 @@ func (a *AndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
		HostRequiredModuleNames: a.HostRequiredModuleNames(),
		HostRequiredModuleNames: a.HostRequiredModuleNames(),
		TestSuites:              a.testProperties.Test_suites,
		TestSuites:              a.testProperties.Test_suites,
		IsHost:                  false,
		IsHost:                  false,
		LocalCertificate:        a.certificate.AndroidMkString(),
		IsUnitTest:              Bool(a.testProperties.Test_options.Unit_test),
	})
	})
	android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
	android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
		TestOnly:       true,
		TestOnly:       true,
+0 −2
Original line number Original line Diff line number Diff line
@@ -1504,8 +1504,6 @@ func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) {
		RequiredModuleNames: j.RequiredModuleNames(),
		RequiredModuleNames: j.RequiredModuleNames(),
		TestSuites:          j.testProperties.Test_suites,
		TestSuites:          j.testProperties.Test_suites,
		IsHost:              true,
		IsHost:              true,
		LocalSdkVersion:     j.sdkVersion.String(),
		IsUnitTest:          Bool(j.testProperties.Test_options.Unit_test),
	})
	})
}
}


+2 −9
Original line number Original line Diff line number Diff line
@@ -6,8 +6,7 @@ import (
	"github.com/google/blueprint"
	"github.com/google/blueprint"
)
)


// Data that test_module_config[_host] modules types will need from
// Output files we need from a base test that we derive from.
// their dependencies to write out build rules and AndroidMkEntries.
type BaseTestProviderData struct {
type BaseTestProviderData struct {
	// data files and apps for android_test
	// data files and apps for android_test
	InstalledFiles android.Paths
	InstalledFiles android.Paths
@@ -20,14 +19,8 @@ type BaseTestProviderData struct {
	RequiredModuleNames     []string
	RequiredModuleNames     []string
	// List of test suites base uses.
	// List of test suites base uses.
	TestSuites []string
	TestSuites []string
	// True indicates the base modules is built for Host.
	// Used for bases that are Host
	IsHost bool
	IsHost bool
	// Base's sdk version for AndroidMkEntries, generally only used for Host modules.
	LocalSdkVersion string
	// Base's certificate for AndroidMkEntries, generally only used for device modules.
	LocalCertificate string
	// Indicates if the base module was a unit test.
	IsUnitTest bool
}
}


var BaseTestProviderKey = blueprint.NewProvider[BaseTestProviderData]()
var BaseTestProviderKey = blueprint.NewProvider[BaseTestProviderData]()
+43 −118
Original line number Original line Diff line number Diff line
@@ -5,8 +5,6 @@ import (
	"android/soong/tradefed"
	"android/soong/tradefed"
	"encoding/json"
	"encoding/json"
	"fmt"
	"fmt"
	"io"
	"strings"


	"github.com/google/blueprint"
	"github.com/google/blueprint"
	"github.com/google/blueprint/proptools"
	"github.com/google/blueprint/proptools"
@@ -25,17 +23,14 @@ func RegisterTestModuleConfigBuildComponents(ctx android.RegistrationContext) {
type testModuleConfigModule struct {
type testModuleConfigModule struct {
	android.ModuleBase
	android.ModuleBase
	android.DefaultableModuleBase
	android.DefaultableModuleBase
	base android.Module


	tradefedProperties
	tradefedProperties


	// Our updated testConfig.
	// Our updated testConfig.
	testConfig android.OutputPath
	testConfig android.OutputPath
	manifest   android.OutputPath
	manifest   android.InstallPath
	provider   tradefed.BaseTestProviderData
	provider   tradefed.BaseTestProviderData

	supportFiles android.InstallPaths

	isHost bool
}
}


// Host is mostly the same as non-host, just some diffs for AddDependency and
// Host is mostly the same as non-host, just some diffs for AddDependency and
@@ -99,6 +94,7 @@ func (m *testModuleConfigModule) DepsMutator(ctx android.BottomUpMutatorContext)


// Takes base's Tradefed Config xml file and generates a new one with the test properties
// Takes base's Tradefed Config xml file and generates a new one with the test properties
// appeneded from this module.
// appeneded from this module.
// Rewrite the name of the apk in "test-file-name" to be our module's name, rather than the original one.
func (m *testModuleConfigModule) fixTestConfig(ctx android.ModuleContext, baseTestConfig android.Path) android.OutputPath {
func (m *testModuleConfigModule) fixTestConfig(ctx android.ModuleContext, baseTestConfig android.Path) android.OutputPath {
	// Test safe to do when no test_runner_options, but check for that earlier?
	// Test safe to do when no test_runner_options, but check for that earlier?
	fixedConfig := android.PathForModuleOut(ctx, "test_config_fixer", ctx.ModuleName()+".config")
	fixedConfig := android.PathForModuleOut(ctx, "test_config_fixer", ctx.ModuleName()+".config")
@@ -110,8 +106,9 @@ func (m *testModuleConfigModule) fixTestConfig(ctx android.ModuleContext, baseTe
	}
	}
	xmlTestModuleConfigSnippet, _ := json.Marshal(options)
	xmlTestModuleConfigSnippet, _ := json.Marshal(options)
	escaped := proptools.NinjaAndShellEscape(string(xmlTestModuleConfigSnippet))
	escaped := proptools.NinjaAndShellEscape(string(xmlTestModuleConfigSnippet))
	command.FlagWithArg("--test-runner-options=", escaped)
	command.FlagWithArg("--test-file-name=", ctx.ModuleName()+".apk").

		FlagWithArg("--orig-test-file-name=", *m.tradefedProperties.Base+".apk").
		FlagWithArg("--test-runner-options=", escaped)
	rule.Build("fix_test_config", "fix test config")
	rule.Build("fix_test_config", "fix test config")
	return fixedConfig.OutputPath
	return fixedConfig.OutputPath
}
}
@@ -193,7 +190,6 @@ func TestModuleConfigHostFactory() android.Module {
	module.AddProperties(&module.tradefedProperties)
	module.AddProperties(&module.tradefedProperties)
	android.InitAndroidMultiTargetsArchModule(module, android.HostSupported, android.MultilibCommon)
	android.InitAndroidMultiTargetsArchModule(module, android.HostSupported, android.MultilibCommon)
	android.InitDefaultableModule(module)
	android.InitDefaultableModule(module)
	module.isHost = true


	return module
	return module
}
}
@@ -202,66 +198,39 @@ func TestModuleConfigHostFactory() android.Module {
var _ android.AndroidMkEntriesProvider = (*testModuleConfigModule)(nil)
var _ android.AndroidMkEntriesProvider = (*testModuleConfigModule)(nil)


func (m *testModuleConfigModule) AndroidMkEntries() []android.AndroidMkEntries {
func (m *testModuleConfigModule) AndroidMkEntries() []android.AndroidMkEntries {
	appClass := "APPS"
	// We rely on base writing LOCAL_COMPATIBILITY_SUPPORT_FILES for its data files
	include := "$(BUILD_SYSTEM)/soong_app_prebuilt.mk"
	entriesList := m.base.(android.AndroidMkEntriesProvider).AndroidMkEntries()
	if m.isHost {
	entries := &entriesList[0]
		appClass = "JAVA_LIBRARIES"
	entries.OutputFile = android.OptionalPathForPath(m.provider.OutputFile)
		include = "$(BUILD_SYSTEM)/soong_java_prebuilt.mk"
	entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
	}
		entries.SetString("LOCAL_MODULE", m.Name()) //  out module name, not base's
	return []android.AndroidMkEntries{{

		Class:      appClass,
		// Out update config file with extra options.
		OutputFile: android.OptionalPathForPath(m.manifest),
		Include:    include,
		Required:   []string{*m.Base},
		ExtraEntries: []android.AndroidMkExtraEntriesFunc{
			func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
		entries.SetPath("LOCAL_FULL_TEST_CONFIG", m.testConfig)
		entries.SetPath("LOCAL_FULL_TEST_CONFIG", m.testConfig)
		entries.SetString("LOCAL_MODULE_TAGS", "tests")
		entries.SetString("LOCAL_MODULE_TAGS", "tests")
				entries.SetString("LOCAL_TEST_MODULE_CONFIG_BASE", *m.Base)
				if m.provider.LocalSdkVersion != "" {
					entries.SetString("LOCAL_SDK_VERSION", m.provider.LocalSdkVersion)
				}
				if m.provider.LocalCertificate != "" {
					entries.SetString("LOCAL_CERTIFICATE", m.provider.LocalCertificate)
				}


				entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", m.provider.IsUnitTest)
		// Don't append to base's test-suites, only use the ones we define, so clear it before
		// appending to it.
		entries.SetString("LOCAL_COMPATIBILITY_SUITE", "")
		entries.AddCompatibilityTestSuites(m.tradefedProperties.Test_suites...)
		entries.AddCompatibilityTestSuites(m.tradefedProperties.Test_suites...)


				// The app_prebuilt_internal.mk files try create a copy of the OutputFile as an .apk.
		if len(m.provider.HostRequiredModuleNames) > 0 {
				// Normally, this copies the "package.apk" from the intermediate directory here.
			entries.AddStrings("LOCAL_HOST_REQUIRED_MODULES", m.provider.HostRequiredModuleNames...)
				// To prevent the copy of the large apk and to prevent confusion with the real .apk we
		}
				// link to, we set the STEM here to a bogus name and we set OutputFile to a small file (our manifest).
		if len(m.provider.RequiredModuleNames) > 0 {
				// We do this so we don't have to add more conditionals to base_rules.mk
			entries.AddStrings("LOCAL_REQUIRED_MODULES", m.provider.RequiredModuleNames...)
				// soong_java_prebult has the same issue for .jars so use this in both module types.
		}
				entries.SetString("LOCAL_MODULE_STEM", fmt.Sprintf("UNUSED-%s", *m.Base))


		if m.provider.IsHost == false {
				// In normal java/app modules, the module writes LOCAL_COMPATIBILITY_SUPPORT_FILES
			// Not needed for jar_host_test
				// and then base_rules.mk ends up copying each of those dependencies from .intermediates to the install directory.
				// tasks/general-tests.mk, tasks/devices-tests.mk also use these to figure out
				// which testcase files to put in a zip for running tests on another machine.
			//
			//
				// We need our files to end up in the zip, but we don't want \.mk files to
			// Clear the JNI symbols because they belong to base not us. Either transform the names in the string
				// `install` files for us.
			// or clear the variable because we don't need it, we are copying bases libraries not generating
				// So we create a new make variable to indicate these should be in the zip
			// new ones.
				// but not installed.
			entries.SetString("LOCAL_SOONG_JNI_LIBS_SYMBOLS", "")
				entries.AddStrings("LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES", m.supportFiles.Strings()...)
		}
			},
	})
		},
	return entriesList
		// Ensure each of our supportFiles depends on the installed file in base so that our symlinks will always
		// resolve.  The provider gives us the .intermediate path for the support file in base, we change it to
		// the installed path with a string substitution.
		ExtraFooters: []android.AndroidMkExtraFootersFunc{
			func(w io.Writer, name, prefix, moduleDir string) {
				for _, f := range m.supportFiles.Strings() {
					// convert out/.../testcases/FrameworksServicesTests_contentprotection/file1.apk
					// to      out/.../testcases/FrameworksServicesTests/file1.apk
					basePath := strings.Replace(f, "/"+m.Name()+"/", "/"+*m.Base+"/", 1)
					fmt.Fprintf(w, "%s: %s\n", f, basePath)
				}
			},
		},
	}}
}
}


func (m *testModuleConfigHostModule) DepsMutator(ctx android.BottomUpMutatorContext) {
func (m *testModuleConfigHostModule) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -279,7 +248,7 @@ func (m *testModuleConfigHostModule) DepsMutator(ctx android.BottomUpMutatorCont
//   - written via soong_java_prebuilt.mk
//   - written via soong_java_prebuilt.mk
//
//
// 4) out/host/linux-x86/testcases/derived-module/* # data dependencies from base.
// 4) out/host/linux-x86/testcases/derived-module/* # data dependencies from base.
//   - written via our InstallSymlink
//   - written via soong_java_prebuilt.mk
func (m *testModuleConfigHostModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
func (m *testModuleConfigHostModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	m.validateBase(ctx, &testModuleConfigHostTag, "java_test_host", true)
	m.validateBase(ctx, &testModuleConfigHostTag, "java_test_host", true)
	m.generateManifestAndConfig(ctx)
	m.generateManifestAndConfig(ctx)
@@ -291,6 +260,7 @@ func (m *testModuleConfigModule) validateBase(ctx android.ModuleContext, depTag
	ctx.VisitDirectDepsWithTag(*depTag, func(dep android.Module) {
	ctx.VisitDirectDepsWithTag(*depTag, func(dep android.Module) {
		if provider, ok := android.OtherModuleProvider(ctx, dep, tradefed.BaseTestProviderKey); ok {
		if provider, ok := android.OtherModuleProvider(ctx, dep, tradefed.BaseTestProviderKey); ok {
			if baseShouldBeHost == provider.IsHost {
			if baseShouldBeHost == provider.IsHost {
				m.base = dep
				m.provider = provider
				m.provider = provider
			} else {
			} else {
				if baseShouldBeHost {
				if baseShouldBeHost {
@@ -307,9 +277,7 @@ func (m *testModuleConfigModule) validateBase(ctx android.ModuleContext, depTag


// Actions to write:
// Actions to write:
//  1. manifest file to testcases dir
//  1. manifest file to testcases dir
//  2. Symlink to base.apk under base's arch dir
//  2. New Module.config / AndroidTest.xml file with our options.
//  3. Symlink to all data dependencies
//  4. New Module.config / AndroidTest.xml file with our options.
func (m *testModuleConfigModule) generateManifestAndConfig(ctx android.ModuleContext) {
func (m *testModuleConfigModule) generateManifestAndConfig(ctx android.ModuleContext) {
	// Keep before early returns.
	// Keep before early returns.
	android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
	android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
@@ -324,6 +292,7 @@ func (m *testModuleConfigModule) generateManifestAndConfig(ctx android.ModuleCon
	if m.provider.TestConfig == nil {
	if m.provider.TestConfig == nil {
		return
		return
	}
	}

	// 1) A manifest file listing the base, write text to a tiny file.
	// 1) A manifest file listing the base, write text to a tiny file.
	installDir := android.PathForModuleInstall(ctx, ctx.ModuleName())
	installDir := android.PathForModuleInstall(ctx, ctx.ModuleName())
	manifest := android.PathForModuleOut(ctx, "test_module_config.manifest")
	manifest := android.PathForModuleOut(ctx, "test_module_config.manifest")
@@ -332,53 +301,9 @@ func (m *testModuleConfigModule) generateManifestAndConfig(ctx android.ModuleCon
	//    Assume the primary install file is last
	//    Assume the primary install file is last
	// so we need to Install our file last.
	// so we need to Install our file last.
	ctx.InstallFile(installDir, manifest.Base(), manifest)
	ctx.InstallFile(installDir, manifest.Base(), manifest)
	m.manifest = manifest.OutputPath


	// 2) Module.config / AndroidTest.xml
	// 2) Symlink to base.apk
	baseApk := m.provider.OutputFile

	// Typically looks like this for baseApk
	// FrameworksServicesTests
	// └── x86_64
	//    └── FrameworksServicesTests.apk
	symlinkName := fmt.Sprintf("%s/%s", ctx.DeviceConfig().DeviceArch(), baseApk.Base())
	// Only android_test, not java_host_test puts the output in the DeviceArch dir.
	if m.provider.IsHost {
		// testcases/CtsDevicePolicyManagerTestCases
		// ├── CtsDevicePolicyManagerTestCases.jar
		symlinkName = baseApk.Base()
	}
	target := installedBaseRelativeToHere(symlinkName, *m.tradefedProperties.Base)
	installedApk := ctx.InstallAbsoluteSymlink(installDir, symlinkName, target)
	m.supportFiles = append(m.supportFiles, installedApk)

	// 3) Symlink for all data deps
	// And like this for data files and required modules
	// FrameworksServicesTests
	// ├── data
	// │   └── broken_shortcut.xml
	// ├── JobTestApp.apk
	for _, f := range m.provider.InstalledFiles {
		symlinkName := f.Rel()
		target := installedBaseRelativeToHere(symlinkName, *m.tradefedProperties.Base)
		installedPath := ctx.InstallAbsoluteSymlink(installDir, symlinkName, target)
		m.supportFiles = append(m.supportFiles, installedPath)
	}

	// 4) Module.config / AndroidTest.xml
	m.testConfig = m.fixTestConfig(ctx, m.provider.TestConfig)
	m.testConfig = m.fixTestConfig(ctx, m.provider.TestConfig)
}
}


var _ android.AndroidMkEntriesProvider = (*testModuleConfigHostModule)(nil)
var _ android.AndroidMkEntriesProvider = (*testModuleConfigHostModule)(nil)

// Given a relative path to a file in the current directory or a subdirectory,
// return a relative path under our sibling directory named `base`.
// There should be one "../" for each subdir we descend plus one to backup to "base".
//
//	 ThisDir/file1
//	 ThisDir/subdir/file2
//	would return "../base/file1" or "../../subdir/file2"
func installedBaseRelativeToHere(targetFileName string, base string) string {
	backup := strings.Repeat("../", strings.Count(targetFileName, "/")+1)
	return fmt.Sprintf("%s%s/%s", backup, base, targetFileName)
}
+22 −46
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@ package tradefed_modules
import (
import (
	"android/soong/android"
	"android/soong/android"
	"android/soong/java"
	"android/soong/java"
	"fmt"
	"strconv"
	"strconv"
	"strings"
	"strings"
	"testing"
	"testing"
@@ -70,36 +69,15 @@ func TestModuleConfigAndroidTest(t *testing.T) {
	entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
	entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]


	// Ensure some entries from base are there, specifically support files for data and helper apps.
	// Ensure some entries from base are there, specifically support files for data and helper apps.
	// Do not use LOCAL_COMPATIBILITY_SUPPORT_FILES, but instead use LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES
	assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
	android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
		[]string{"out/soong/target/product/test_device/testcases/derived_test/arm64/base.apk",
			"out/soong/target/product/test_device/testcases/derived_test/HelperApp.apk",
			"out/soong/target/product/test_device/testcases/derived_test/data/testfile"},
		entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{})

	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_REQUIRED_MODULES"], []string{"base"})
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_CERTIFICATE"], []string{"build/make/target/product/security/testkey.x509.pem"})
	android.AssertStringEquals(t, "", entries.Class, "APPS")


	// And some new derived entries are there.
	// And some new derived entries are there.
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE_TAGS"], []string{"tests"})
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE_TAGS"], []string{"tests"})


	android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
	// And ones we override
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})


	// Check the footer lines.  Our support files should depend on base's support files.
	android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
	convertedActual := make([]string, 5)
	for i, e := range entries.FooterLinesForTests() {
		// AssertStringPathsRelativeToTop doesn't replace both instances
		convertedActual[i] = strings.Replace(e, ctx.Config.SoongOutDir(), "", 2)
	}
	android.AssertArrayString(t, fmt.Sprintf("%s", ctx.Config.SoongOutDir()), convertedActual, []string{
		"include $(BUILD_SYSTEM)/soong_app_prebuilt.mk",
		"/target/product/test_device/testcases/derived_test/arm64/base.apk: /target/product/test_device/testcases/base/arm64/base.apk",
		"/target/product/test_device/testcases/derived_test/HelperApp.apk: /target/product/test_device/testcases/base/HelperApp.apk",
		"/target/product/test_device/testcases/derived_test/data/testfile: /target/product/test_device/testcases/base/data/testfile",
		"",
	})
}
}


// Make sure we call test-config-fixer with the right args.
// Make sure we call test-config-fixer with the right args.
@@ -114,7 +92,7 @@ func TestModuleConfigOptions(t *testing.T) {
	derived := ctx.ModuleForTests("derived_test", "android_common")
	derived := ctx.ModuleForTests("derived_test", "android_common")
	rule_cmd := derived.Rule("fix_test_config").RuleParams.Command
	rule_cmd := derived.Rule("fix_test_config").RuleParams.Command
	android.AssertStringDoesContain(t, "Bad FixConfig rule inputs", rule_cmd,
	android.AssertStringDoesContain(t, "Bad FixConfig rule inputs", rule_cmd,
		`--test-runner-options='[{"Name":"exclude-filter","Key":"","Value":"android.test.example.devcodelab.DevCodelabTest#testHelloFail"},{"Name":"include-annotation","Key":"","Value":"android.platform.test.annotations.LargeTest"}]'`)
		`--test-file-name=derived_test.apk --orig-test-file-name=base.apk --test-runner-options='[{"Name":"exclude-filter","Key":"","Value":"android.test.example.devcodelab.DevCodelabTest#testHelloFail"},{"Name":"include-annotation","Key":"","Value":"android.platform.test.annotations.LargeTest"}]'`)
}
}


// Ensure we error for a base we don't support.
// Ensure we error for a base we don't support.
@@ -217,12 +195,6 @@ func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T)
			name: "base",
			name: "base",
			sdk_version: "current",
			sdk_version: "current",
                        srcs: ["a.java"],
                        srcs: ["a.java"],
                        data: [":HelperApp", "data/testfile"],
		}

                android_test_helper_app {
                        name: "HelperApp",
                        srcs: ["helper.java"],
		}
		}


                test_module_config {
                test_module_config {
@@ -248,12 +220,8 @@ func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T)
		derived := ctx.ModuleForTests("derived_test", "android_common")
		derived := ctx.ModuleForTests("derived_test", "android_common")
		entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
		entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
		// All these should be the same in both derived tests
		// All these should be the same in both derived tests
		android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
		assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
			[]string{"out/soong/target/product/test_device/testcases/derived_test/arm64/base.apk",
		android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
				"out/soong/target/product/test_device/testcases/derived_test/HelperApp.apk",
				"out/soong/target/product/test_device/testcases/derived_test/data/testfile"},
			entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])

		// Except this one, which points to the updated tradefed xml file.
		// Except this one, which points to the updated tradefed xml file.
		android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
		android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
		// And this one, the module name.
		// And this one, the module name.
@@ -264,11 +232,8 @@ func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T)
		derived := ctx.ModuleForTests("another_derived_test", "android_common")
		derived := ctx.ModuleForTests("another_derived_test", "android_common")
		entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
		entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
		// All these should be the same in both derived tests
		// All these should be the same in both derived tests
		android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
		assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
			[]string{"out/soong/target/product/test_device/testcases/another_derived_test/arm64/base.apk",
		android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
				"out/soong/target/product/test_device/testcases/another_derived_test/HelperApp.apk",
				"out/soong/target/product/test_device/testcases/another_derived_test/data/testfile"},
			entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])
		// Except this one, which points to the updated tradefed xml file.
		// Except this one, which points to the updated tradefed xml file.
		android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "another_derived_test/android_common/test_config_fixer/another_derived_test.config")
		android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "another_derived_test/android_common/test_config_fixer/another_derived_test.config")
		// And this one, the module name.
		// And this one, the module name.
@@ -304,8 +269,6 @@ func TestModuleConfigHostBasics(t *testing.T) {
	allEntries := android.AndroidMkEntriesForTest(t, ctx.TestContext, mod)
	allEntries := android.AndroidMkEntriesForTest(t, ctx.TestContext, mod)
	entries := allEntries[0]
	entries := allEntries[0]
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"derived_test"})
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"derived_test"})
	android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SDK_VERSION"], []string{"private_current"})
	android.AssertStringEquals(t, "", entries.Class, "JAVA_LIBRARIES")


	if !mod.Host() {
	if !mod.Host() {
		t.Errorf("host bit is not set for a java_test_host module.")
		t.Errorf("host bit is not set for a java_test_host module.")
@@ -422,3 +385,16 @@ func TestTestOnlyProvider(t *testing.T) {
		t.Errorf("test-only: Expected but not found: %v, Found but not expected: %v", left, right)
		t.Errorf("test-only: Expected but not found: %v, Found but not expected: %v", left, right)
	}
	}
}
}

// Use for situations where the entries map contains pairs:  [srcPath:installedPath1, srcPath2:installedPath2]
// and we want to compare the RHS of the pairs, i.e. installedPath1, installedPath2
func assertEntryPairValues(t *testing.T, actual []string, expected []string) {
	for i, e := range actual {
		parts := strings.Split(e, ":")
		if len(parts) != 2 {
			t.Errorf("Expected entry to have a value delimited by :, received: %s", e)
			return
		}
		android.AssertStringEquals(t, "", parts[1], expected[i])
	}
}