Soong: Add test for apex
This test checks if "runtime_libs" dep of "cc_library" is respected. Test: m (run soong tests) Change-Id: I4b81fc548761be9b284d15c61c62718df72d409f
This commit is contained in:
parent
a48f8c8070
commit
d363955938
|
@ -30,6 +30,16 @@ import (
|
||||||
|
|
||||||
var buildDir string
|
var buildDir string
|
||||||
|
|
||||||
|
// names returns name list from white space separated string
|
||||||
|
func names(s string) (ns []string) {
|
||||||
|
for _, n := range strings.Split(s, " ") {
|
||||||
|
if len(n) > 0 {
|
||||||
|
ns = append(ns, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func testApexError(t *testing.T, pattern, bp string) {
|
func testApexError(t *testing.T, pattern, bp string) {
|
||||||
ctx, config := testApexContext(t, bp)
|
ctx, config := testApexContext(t, bp)
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||||
|
@ -626,6 +636,73 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
|
||||||
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestApexWithRuntimeLibsDependency(t *testing.T) {
|
||||||
|
/*
|
||||||
|
myapex
|
||||||
|
|
|
||||||
|
v (runtime_libs)
|
||||||
|
mylib ------+------> libfoo [provides stub]
|
||||||
|
|
|
||||||
|
`------> libbar
|
||||||
|
*/
|
||||||
|
ctx, _ := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
runtime_libs: ["libfoo", "libbar"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
stubs: {
|
||||||
|
versions: ["10", "20", "30"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libbar",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
|
||||||
|
`)
|
||||||
|
|
||||||
|
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
|
||||||
|
copyCmds := apexRule.Args["copy_commands"]
|
||||||
|
|
||||||
|
// Ensure that direct non-stubs dep is always included
|
||||||
|
ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
|
||||||
|
|
||||||
|
// Ensure that indirect stubs dep is not included
|
||||||
|
ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so")
|
||||||
|
|
||||||
|
// Ensure that runtime_libs dep in included
|
||||||
|
ensureContains(t, copyCmds, "image.apex/lib64/libbar.so")
|
||||||
|
|
||||||
|
injectRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("injectApexDependency")
|
||||||
|
ensureListEmpty(t, names(injectRule.Args["provideNativeLibs"]))
|
||||||
|
ensureListContains(t, names(injectRule.Args["requireNativeLibs"]), "libfoo.so")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestApexWithSystemLibsStubs(t *testing.T) {
|
func TestApexWithSystemLibsStubs(t *testing.T) {
|
||||||
ctx, _ := testApex(t, `
|
ctx, _ := testApex(t, `
|
||||||
apex {
|
apex {
|
||||||
|
@ -1133,15 +1210,6 @@ func TestDependenciesInApexManifest(t *testing.T) {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
names := func(s string) (ns []string) {
|
|
||||||
for _, n := range strings.Split(s, " ") {
|
|
||||||
if len(n) > 0 {
|
|
||||||
ns = append(ns, n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var injectRule android.TestingBuildParams
|
var injectRule android.TestingBuildParams
|
||||||
var provideNativeLibs, requireNativeLibs []string
|
var provideNativeLibs, requireNativeLibs []string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue