Add module dependency checking testing method
Currently in Soong testing suite, the only method for testing module dependency is CheckModuleDependencies(...), which comapares for the exact module dependencies. This change adds the method CheckModuleDependency(...) which enables checking the dependency between two modules, instead of comparing for all dependencies of an interested module. Test: m nothing Bug: 288624417 Change-Id: I804d35979ddc24b0134671e326c1d37615ec4190
This commit is contained in:
@@ -574,7 +574,7 @@ func gatherRequiredDepsForTest() string {
|
||||
return bp
|
||||
}
|
||||
|
||||
func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
|
||||
func getModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string) []string {
|
||||
t.Helper()
|
||||
module := ctx.ModuleForTests(name, variant).Module()
|
||||
deps := []string{}
|
||||
@@ -583,11 +583,29 @@ func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, varia
|
||||
})
|
||||
sort.Strings(deps)
|
||||
|
||||
return deps
|
||||
}
|
||||
|
||||
// CheckModuleDependencies checks if the expected dependencies of the module are
|
||||
// identical to the actual dependencies.
|
||||
func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
|
||||
deps := getModuleDependencies(t, ctx, name, variant)
|
||||
|
||||
if actual := deps; !reflect.DeepEqual(expected, actual) {
|
||||
t.Errorf("expected %#q, found %#q", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckModuleHasDependency returns true if the module depends on the expected dependency.
|
||||
func CheckModuleHasDependency(t *testing.T, ctx *android.TestContext, name, variant string, expected string) bool {
|
||||
for _, dep := range getModuleDependencies(t, ctx, name, variant) {
|
||||
if dep == expected {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// CheckPlatformBootclasspathModules returns the apex:module pair for the modules depended upon by
|
||||
// the platform-bootclasspath module.
|
||||
func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, name string, expected []string) {
|
||||
|
Reference in New Issue
Block a user