rust: Add data_libs and data_bins to rust_test

Allows defining data binaries and libraries that should be installed
alongside a rust_test module, similar to cc_test.

This refactors cc_test as well so it can define rust_ffi_shared and
rust_binary modules as data.

Bug: 171710847
Test: New Soong tests pass.
Test: Example module installs data appropriately.
Change-Id: I0b56098fb475ec54f9b7a761220d260fe68cbee1
This commit is contained in:
Ivan Lozano
2021-11-04 14:09:38 -04:00
parent 8d10fc39af
commit 4e5f07d27b
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) {