Merge "rust: Add data_libs and data_bins to rust_test"

This commit is contained in:
Ivan Lozano
2021-11-16 13:46:49 +00:00
committed by Gerrit Code Review
5 changed files with 198 additions and 18 deletions

View File

@@ -730,9 +730,16 @@ func TestDataLibsRelativeInstallPath(t *testing.T) {
gtest: false,
}
cc_binary {
name: "test_bin",
relative_install_path: "foo/bar/baz",
compile_multilib: "both",
}
cc_test {
name: "main_test",
data_libs: ["test_lib"],
data_bins: ["test_bin"],
gtest: false,
}
`
@@ -750,10 +757,10 @@ func TestDataLibsRelativeInstallPath(t *testing.T) {
t.Fatalf("Expected cc_test to produce output files, error: %s", err)
}
if len(outputFiles) != 1 {
t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles)
}
if len(testBinary.dataPaths()) != 1 {
t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
if len(testBinary.dataPaths()) != 2 {
t.Fatalf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
}
outputPath := outputFiles[0].String()
@@ -766,6 +773,10 @@ func TestDataLibsRelativeInstallPath(t *testing.T) {
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
}
if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][1], ":test_bin:foo/bar/baz") {
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_bin:foo/bar/baz`,"+
" but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][1])
}
}
func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {

View File

@@ -378,31 +378,26 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
ctx.VisitDirectDepsWithTag(dataLibDepTag, func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
ccDep, ok := dep.(LinkableInterface)
linkableDep, ok := dep.(LinkableInterface)
if !ok {
ctx.ModuleErrorf("data_lib %q is not a linkable cc module", depName)
ctx.ModuleErrorf("data_lib %q is not a LinkableInterface module", depName)
}
ccModule, ok := dep.(*Module)
if !ok {
ctx.ModuleErrorf("data_lib %q is not a cc module", depName)
}
if ccDep.OutputFile().Valid() {
if linkableDep.OutputFile().Valid() {
test.data = append(test.data,
android.DataPath{SrcPath: ccDep.OutputFile().Path(),
RelativeInstallPath: ccModule.installer.relativeInstallPath()})
android.DataPath{SrcPath: linkableDep.OutputFile().Path(),
RelativeInstallPath: linkableDep.RelativeInstallPath()})
}
})
ctx.VisitDirectDepsWithTag(dataBinDepTag, func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
ccModule, ok := dep.(*Module)
linkableDep, ok := dep.(LinkableInterface)
if !ok {
ctx.ModuleErrorf("data_bin %q is not a cc module", depName)
ctx.ModuleErrorf("data_bin %q is not a LinkableInterface module", depName)
}
if ccModule.OutputFile().Valid() {
if linkableDep.OutputFile().Valid() {
test.data = append(test.data,
android.DataPath{SrcPath: ccModule.OutputFile().Path(),
RelativeInstallPath: ccModule.installer.relativeInstallPath()})
android.DataPath{SrcPath: linkableDep.OutputFile().Path(),
RelativeInstallPath: linkableDep.RelativeInstallPath()})
}
})