Create 'cc_prebuilt_test_library_shared' module type
This new module type allows cc_test modules to depend on prebuilt
shared libraries and have them included as data dependencies alongside
the test binary.
Test: Manually verified to facilitate mk-to-bp migration of
bionic-unit-test prebuilt dependencies (aosp/1339035)
Change-Id: Idbac0854f1f9e2e01bbfa63591de458b61733e17
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 041c4a3..38a5c2d 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -612,7 +612,6 @@
}
outputPath := outputFiles[0].String()
- testBinaryPath := testBinary.dataPaths()[0]
if !strings.HasSuffix(outputPath, "/main_test") {
t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
@@ -620,7 +619,7 @@
entries := android.AndroidMkEntriesForTest(t, config, "", module)[0]
if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") {
t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
- " but was '%s'", testBinaryPath)
+ " but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
}
}
@@ -2967,6 +2966,52 @@
}
}
+func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
+ bp := `
+ cc_prebuilt_test_library_shared {
+ name: "test_lib",
+ relative_install_path: "foo/bar/baz",
+ srcs: ["srcpath/dontusethispath/baz.so"],
+ }
+
+ cc_test {
+ name: "main_test",
+ data_libs: ["test_lib"],
+ gtest: false,
+ }
+ `
+
+ config := TestConfig(buildDir, android.Android, nil, bp, nil)
+ config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
+ config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
+ config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)
+
+ ctx := testCcWithConfig(t, config)
+ module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module()
+ testBinary := module.(*Module).linker.(*testBinary)
+ outputFiles, err := module.(android.OutputFileProducer).OutputFiles("")
+ if err != nil {
+ t.Fatalf("Expected cc_test to produce output files, error: %s", err)
+ }
+ if len(outputFiles) != 1 {
+ t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
+ }
+ if len(testBinary.dataPaths()) != 1 {
+ t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
+ }
+
+ outputPath := outputFiles[0].String()
+
+ if !strings.HasSuffix(outputPath, "/main_test") {
+ t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
+ }
+ entries := android.AndroidMkEntriesForTest(t, config, "", module)[0]
+ if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") {
+ t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
+ " but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0])
+ }
+}
+
func TestVersionedStubs(t *testing.T) {
ctx := testCc(t, `
cc_library_shared {