diff options
author | ThiƩbaud Weksteen <tweek@google.com> | 2020-09-30 08:21:36 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-09-30 08:21:36 +0000 |
commit | d2ff08710b539dc798c29828e639cf577dad40bf (patch) | |
tree | 9567a3e8d17415e3acf06cfd1b1ef7a9fdde46f2 /rust/project_json_test.go | |
parent | 21de510915dadd0cdf223d1f3e0e3a19efac4096 (diff) | |
parent | a6351caf1220538a61d03ab17efa8d85572d4bf9 (diff) |
Merge changes Icbbf176c,I52beadc8
* changes:
rust: Add ref to generated sources (aidl, bindgen)
rust: refactor projectGeneratorSingleton
Diffstat (limited to 'rust/project_json_test.go')
-rw-r--r-- | rust/project_json_test.go | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/rust/project_json_test.go b/rust/project_json_test.go index 85219404a..8c1c43623 100644 --- a/rust/project_json_test.go +++ b/rust/project_json_test.go @@ -18,6 +18,7 @@ import ( "encoding/json" "io/ioutil" "path/filepath" + "strings" "testing" "android/soong/android" @@ -100,22 +101,50 @@ func TestProjectJsonBindGen(t *testing.T) { rust_library { name: "liba", srcs: ["src/lib.rs"], - rlibs: ["libbindings"], + rlibs: ["libbindings1"], crate_name: "a" } rust_bindgen { - name: "libbindings", - crate_name: "bindings", - source_stem: "bindings", + name: "libbindings1", + crate_name: "bindings1", + source_stem: "bindings1", host_supported: true, wrapper_src: "src/any.h", } + rust_library_host { + name: "libb", + srcs: ["src/lib.rs"], + rustlibs: ["libbindings2"], + crate_name: "b" + } + rust_bindgen_host { + name: "libbindings2", + crate_name: "bindings2", + source_stem: "bindings2", + wrapper_src: "src/any.h", + } ` + GatherRequiredDepsForTest() fs := map[string][]byte{ "src/lib.rs": nil, } jsonContent := testProjectJson(t, bp, fs) - validateJsonCrates(t, jsonContent) + crates := validateJsonCrates(t, jsonContent) + for _, c := range crates { + crate, ok := c.(map[string]interface{}) + if !ok { + t.Fatalf("Unexpected type for crate: %v", c) + } + rootModule, ok := crate["root_module"].(string) + if !ok { + t.Fatalf("Unexpected type for root_module: %v", crate["root_module"]) + } + if strings.Contains(rootModule, "libbindings1") && !strings.Contains(rootModule, "android_arm64") { + t.Errorf("The source for libbindings1 does not contain android_arm64, got %v", rootModule) + } + if strings.Contains(rootModule, "libbindings2") && !strings.Contains(rootModule, "linux_glibc") { + t.Errorf("The source for libbindings2 does not contain linux_glibc, got %v", rootModule) + } + } } func TestProjectJsonMultiVersion(t *testing.T) { |