diff options
author | 2023-08-14 11:26:18 -0400 | |
---|---|---|
committer | 2023-08-14 11:26:18 -0400 | |
commit | 05b3410290a954733a507fcac4862c10cb1a43c0 (patch) | |
tree | ee408c2092656c9f711d4463831a5abb5e08e0d8 /rust/binary_test.go | |
parent | 88df1d3e0b750e1a3c1cff1fa73576e9fbfe9e3d (diff) |
Add unit test to verify default linkage for rust binaries
Test: go test
Change-Id: I16eed90dffc8f98a880aa801e96601227dcc37be
Diffstat (limited to 'rust/binary_test.go')
-rw-r--r-- | rust/binary_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rust/binary_test.go b/rust/binary_test.go index dd4f99314..fc4c56037 100644 --- a/rust/binary_test.go +++ b/rust/binary_test.go @@ -21,6 +21,27 @@ import ( "android/soong/android" ) +// Test that rustlibs default linkage is always rlib for host binaries. +func TestBinaryHostLinkage(t *testing.T) { + ctx := testRust(t, ` + rust_binary_host { + name: "fizz-buzz", + srcs: ["foo.rs"], + rustlibs: ["libfoo"], + } + rust_library { + name: "libfoo", + srcs: ["foo.rs"], + crate_name: "foo", + host_supported: true, + } + `) + fizzBuzz := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Module().(*Module) + if !android.InList("libfoo.rlib-std", fizzBuzz.Properties.AndroidMkRlibs) { + t.Errorf("rustlibs dependency libfoo should be an rlib dep for host binaries") + } +} + // Test that rustlibs default linkage is correct for binaries. func TestBinaryLinkage(t *testing.T) { ctx := testRust(t, ` @@ -54,6 +75,12 @@ func TestBinaryLinkage(t *testing.T) { if !android.InList("libfoo", fizzBuzzDevice.Properties.AndroidMkDylibs) { t.Errorf("rustlibs dependency libfoo should be an dylib dep for device modules") } + + rlibLinkDevice := ctx.ModuleForTests("rlib_linked", "android_arm64_armv8-a").Module().(*Module) + + if !android.InList("libfoo.rlib-std", rlibLinkDevice.Properties.AndroidMkRlibs) { + t.Errorf("rustlibs dependency libfoo should be an rlib dep for device modules when prefer_rlib is set") + } } // Test that prefer_rlib links in libstd statically as well as rustlibs. |