summaryrefslogtreecommitdiff
path: root/rust/rust_test.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2019-10-29 21:47:14 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-10-29 21:47:14 +0000
commit765fe7a50194bd16e4d08e80c45ce7ef17f1e09f (patch)
tree0ddf510fc8c0c569d3c5aa94f7ddc4d0269fd40f /rust/rust_test.go
parentec90e44ce786c3a560e7ab7c0666714c8c744cb4 (diff)
parent52767be335c200dfbf2af3da802e24a1cc91f1bf (diff)
Merge changes Ia7deed13,I7378a46f
* changes: Add support for Rust C libraries. Add a common interface for cc linkable libraries.
Diffstat (limited to 'rust/rust_test.go')
-rw-r--r--rust/rust_test.go45
1 files changed, 35 insertions, 10 deletions
diff --git a/rust/rust_test.go b/rust/rust_test.go
index 0c8d35586..eb04e7257 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -101,12 +101,20 @@ func testRustError(t *testing.T, pattern string, bp string) {
// Test that we can extract the lib name from a lib path.
func TestLibNameFromFilePath(t *testing.T) {
- barPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so")
- libName := libNameFromFilePath(barPath)
+ libBarPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so")
+ libLibPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/liblib.dylib.so")
+
+ libBarName := libNameFromFilePath(libBarPath)
+ libLibName := libNameFromFilePath(libLibPath)
+
expectedResult := "bar"
+ if libBarName != expectedResult {
+ t.Errorf("libNameFromFilePath returned the wrong name; expected '%#v', got '%#v'", expectedResult, libBarName)
+ }
- if libName != expectedResult {
- t.Errorf("libNameFromFilePath returned the wrong name; expected '%#v', got '%#v'", expectedResult, libName)
+ expectedResult = "lib.dylib"
+ if libLibName != expectedResult {
+ t.Errorf("libNameFromFilePath returned the wrong name; expected '%#v', got '%#v'", expectedResult, libLibPath)
}
}
@@ -140,12 +148,20 @@ func TestDefaultCrateName(t *testing.T) {
// Test to make sure dependencies are being picked up correctly.
func TestDepsTracking(t *testing.T) {
ctx := testRust(t, `
+ rust_library_host_static {
+ name: "libstatic",
+ srcs: ["foo.rs"],
+ }
+ rust_library_host_shared {
+ name: "libshared",
+ srcs: ["foo.rs"],
+ }
rust_library_host_dylib {
- name: "libfoo",
+ name: "libdylib",
srcs: ["foo.rs"],
}
rust_library_host_rlib {
- name: "libbar",
+ name: "librlib",
srcs: ["foo.rs"],
}
rust_proc_macro {
@@ -154,20 +170,22 @@ func TestDepsTracking(t *testing.T) {
}
rust_binary_host {
name: "fizz-buzz",
- dylibs: ["libfoo"],
- rlibs: ["libbar"],
+ dylibs: ["libdylib"],
+ rlibs: ["librlib"],
proc_macros: ["libpm"],
+ static_libs: ["libstatic"],
+ shared_libs: ["libshared"],
srcs: ["foo.rs"],
}
`)
module := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Module().(*Module)
// Since dependencies are added to AndroidMk* properties, we can check these to see if they've been picked up.
- if !android.InList("libfoo", module.Properties.AndroidMkDylibs) {
+ if !android.InList("libdylib", module.Properties.AndroidMkDylibs) {
t.Errorf("Dylib dependency not detected (dependency missing from AndroidMkDylibs)")
}
- if !android.InList("libbar", module.Properties.AndroidMkRlibs) {
+ if !android.InList("librlib", module.Properties.AndroidMkRlibs) {
t.Errorf("Rlib dependency not detected (dependency missing from AndroidMkRlibs)")
}
@@ -175,6 +193,13 @@ func TestDepsTracking(t *testing.T) {
t.Errorf("Proc_macro dependency not detected (dependency missing from AndroidMkProcMacroLibs)")
}
+ if !android.InList("libshared", module.Properties.AndroidMkSharedLibs) {
+ t.Errorf("Shared library dependency not detected (dependency missing from AndroidMkSharedLibs)")
+ }
+
+ if !android.InList("libstatic", module.Properties.AndroidMkStaticLibs) {
+ t.Errorf("Static library dependency not detected (dependency missing from AndroidMkStaticLibs)")
+ }
}
// Test to make sure proc_macros use host variants when building device modules.