summaryrefslogtreecommitdiff
path: root/sdk/sdk_test.go
diff options
context:
space:
mode:
author Jiyong Park <jiyong@google.com> 2019-11-04 12:23:40 +0900
committer Jiyong Park <jiyong@google.com> 2019-11-07 12:24:48 +0900
commit232e785b9894a2df107b557378b84a900bbb68e5 (patch)
treec75ae0daeff4ef4620598e0438f3026e1c0e013c /sdk/sdk_test.go
parentb9a80a071657aacec5c03a5b5baa2ec0d2f5a729 (diff)
SDK snapshot is dist'ed
`m module_sdk dist` produces snapshots of all SDKs in the source tree. A snapshot is a zip file consists of Android.bp, exported headers, exported AIDL files, stubs for native libs and jars. The zip file is expected to be downloaded from the build server and extracted to a directory (which probably will be /prebuilts/module_sdks/<module_name>/current). Bug: 138182343 Test: m (sdk_test.go updated) Change-Id: Idbe4bc24795fe08f26fc1cf7497028f9d162053a
Diffstat (limited to 'sdk/sdk_test.go')
-rw-r--r--sdk/sdk_test.go70
1 files changed, 69 insertions, 1 deletions
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 96129b838..3471bc9da 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -17,6 +17,7 @@ package sdk
import (
"io/ioutil"
"os"
+ "path/filepath"
"strings"
"testing"
@@ -100,6 +101,8 @@ func testSdkContext(t *testing.T, bp string) (*android.TestContext, android.Conf
"myapex.pk8": nil,
"Test.java": nil,
"Test.cpp": nil,
+ "include/Test.h": nil,
+ "aidl/foo/bar/Test.aidl": nil,
"libfoo.so": nil,
})
@@ -398,7 +401,9 @@ func TestSdkIsCompileMultilibBoth(t *testing.T) {
var inputs []string
buildParams := ctx.ModuleForTests("mysdk", "android_common").Module().BuildParamsForTests()
for _, bp := range buildParams {
- inputs = append(inputs, bp.Implicits.Strings()...)
+ if bp.Input != nil {
+ inputs = append(inputs, bp.Input.String())
+ }
}
// ensure that both 32/64 outputs are inputs of the sdk snapshot
@@ -406,6 +411,69 @@ func TestSdkIsCompileMultilibBoth(t *testing.T) {
ensureListContains(t, inputs, arm64Output.String())
}
+func TestSnapshot(t *testing.T) {
+ ctx, config := testSdk(t, `
+ sdk {
+ name: "mysdk",
+ java_libs: ["myjavalib"],
+ native_shared_libs: ["mynativelib"],
+ }
+
+ java_library {
+ name: "myjavalib",
+ srcs: ["Test.java"],
+ aidl: {
+ export_include_dirs: ["aidl"],
+ },
+ system_modules: "none",
+ sdk_version: "none",
+ compile_dex: true,
+ host_supported: true,
+ }
+
+ cc_library_shared {
+ name: "mynativelib",
+ srcs: [
+ "Test.cpp",
+ "aidl/foo/bar/Test.aidl",
+ ],
+ export_include_dirs: ["include"],
+ aidl: {
+ export_aidl_headers: true,
+ },
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ var copySrcs []string
+ var copyDests []string
+ buildParams := ctx.ModuleForTests("mysdk", "android_common").Module().BuildParamsForTests()
+ for _, bp := range buildParams {
+ if bp.Rule.String() == "android/soong/android.Cp" {
+ copySrcs = append(copySrcs, bp.Input.String())
+ copyDests = append(copyDests, bp.Output.Rel()) // rooted at the snapshot root
+ }
+ }
+
+ buildDir := config.BuildDir()
+ ensureListContains(t, copySrcs, "aidl/foo/bar/Test.aidl")
+ ensureListContains(t, copySrcs, "include/Test.h")
+ ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BnTest.h"))
+ ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/BpTest.h"))
+ ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/gen/aidl/aidl/foo/bar/Test.h"))
+ ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar"))
+ ensureListContains(t, copySrcs, filepath.Join(buildDir, ".intermediates/mynativelib/android_arm64_armv8-a_core_shared/mynativelib.so"))
+
+ ensureListContains(t, copyDests, "aidl/aidl/foo/bar/Test.aidl")
+ ensureListContains(t, copyDests, "arm64/include/include/Test.h")
+ ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/BnTest.h")
+ ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/BpTest.h")
+ ensureListContains(t, copyDests, "arm64/include_gen/mynativelib/aidl/foo/bar/Test.h")
+ ensureListContains(t, copyDests, "java/myjavalib.jar")
+ ensureListContains(t, copyDests, "arm64/lib/mynativelib.so")
+}
+
var buildDir string
func setUp() {