Add test_for property

This change adds 'test_for' property to cc_test_* types. The property is
used to mark a module as a test for one or more APEXes, in which case
the module has accecss to the private part of the listed APEXes. For
example, the module is linked with the actrual shared library in the
APEX instead of the stub of the shared library.

Exempt-From-Owner-Approval: already +2'ed by owner

Bug: 129539670
Bug: 153046163
Test: m
Change-Id: I45ed0d7a15540b0d69b2a3b8d9c4cb202adff6f2
This commit is contained in:
Jiyong Park
2020-04-13 16:19:48 +09:00
parent 96447be640
commit 62304bbeec
4 changed files with 90 additions and 0 deletions

View File

@@ -4533,6 +4533,58 @@ func TestNoUpdatableJarsInBootImage(t *testing.T) {
testNoUpdatableJarsInBootImage(t, "", bp, transform)
}
func TestTestFor(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
native_shared_libs: ["mylib", "myprivlib"],
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
cc_library {
name: "mylib",
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
stubs: {
versions: ["1"],
},
apex_available: ["myapex"],
}
cc_library {
name: "myprivlib",
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: ["myapex"],
}
cc_test {
name: "mytest",
gtest: false,
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
shared_libs: ["mylib", "myprivlib"],
test_for: ["myapex"]
}
`)
// the test 'mytest' is a test for the apex, therefore is linked to the
// actual implementation of mylib instead of its stub.
ldFlags := ctx.ModuleForTests("mytest", "android_arm64_armv8-a").Rule("ld").Args["libFlags"]
ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared/mylib.so")
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
}
func TestMain(m *testing.M) {
run := func() int {
setUp()