diff options
author | 2023-08-14 18:13:04 +0000 | |
---|---|---|
committer | 2023-08-14 18:13:04 +0000 | |
commit | 5ce68092d33eaae59d6f9ada5f89fc06fb996f7c (patch) | |
tree | 535b69b67d04ec137a05fa07f4f38a3205957c4c | |
parent | 83b86cccda1c926a53edafb213949ce5b0faaad0 (diff) | |
parent | 05b3410290a954733a507fcac4862c10cb1a43c0 (diff) |
Merge "Add unit test to verify default linkage for rust binaries" into main
-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. |