summaryrefslogtreecommitdiff
path: root/rust/image_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'rust/image_test.go')
-rw-r--r--rust/image_test.go25
1 files changed, 22 insertions, 3 deletions
diff --git a/rust/image_test.go b/rust/image_test.go
index 1515aa264..e40599c3a 100644
--- a/rust/image_test.go
+++ b/rust/image_test.go
@@ -15,6 +15,7 @@
package rust
import (
+ "strings"
"testing"
"android/soong/android"
@@ -23,7 +24,7 @@ import (
// Test that cc modules can link against vendor_available rust_ffi_static libraries.
func TestVendorLinkage(t *testing.T) {
- ctx := testRust(t, `
+ ctx := testRustVndk(t, `
cc_binary {
name: "fizz_vendor",
static_libs: ["libfoo_vendor"],
@@ -37,16 +38,34 @@ func TestVendorLinkage(t *testing.T) {
}
`)
- vendorBinary := ctx.ModuleForTests("fizz_vendor", "android_arm64_armv8-a").Module().(*cc.Module)
+ vendorBinary := ctx.ModuleForTests("fizz_vendor", "android_vendor.VER_arm64_armv8-a").Module().(*cc.Module)
if !android.InList("libfoo_vendor", vendorBinary.Properties.AndroidMkStaticLibs) {
t.Errorf("vendorBinary should have a dependency on libfoo_vendor")
}
}
+// Test that variants which use the vndk emit the appropriate cfg flag.
+func TestImageVndkCfgFlag(t *testing.T) {
+ ctx := testRustVndk(t, `
+ rust_ffi_static {
+ name: "libfoo",
+ crate_name: "foo",
+ srcs: ["foo.rs"],
+ vendor_available: true,
+ }
+ `)
+
+ vendor := ctx.ModuleForTests("libfoo", "android_vendor.VER_arm64_armv8-a_static").Rule("rustc")
+
+ if !strings.Contains(vendor.Args["rustcFlags"], "--cfg 'android_vndk'") {
+ t.Errorf("missing \"--cfg 'android_vndk'\" for libfoo vendor variant, rustcFlags: %#v", vendor.Args["rustcFlags"])
+ }
+}
+
// Test that cc modules can link against vendor_ramdisk_available rust_ffi_static libraries.
func TestVendorRamdiskLinkage(t *testing.T) {
- ctx := testRust(t, `
+ ctx := testRustVndk(t, `
cc_library_static {
name: "libcc_vendor_ramdisk",
static_libs: ["libfoo_vendor_ramdisk"],