diff options
author | 2021-03-08 10:09:52 +0900 | |
---|---|---|
committer | 2021-03-08 10:11:00 +0900 | |
commit | 5e914b286fad85d8d610a24af4c15c88ed71679e (patch) | |
tree | e52f6ae9ce0ba97cf3cba4b5fb5dfc78ca878443 /sysprop/sysprop_test.go | |
parent | 6d3e72688729ea72bf64f1e7dacccc5b57f384be (diff) |
sysprop_library correctly supports apex_available and min_sdk_version
This fixes a bug that apex_available and min_sdk_version properties of a
sysprop_library module are not forwarded to the generated cc or java
modules.
Bug: 181942475
Bug: 181940232
Test: m nothing
Change-Id: I03bcb5836f080aecd452021a3ffe003f36eb652e
Diffstat (limited to 'sysprop/sysprop_test.go')
-rw-r--r-- | sysprop/sysprop_test.go | 149 |
1 files changed, 105 insertions, 44 deletions
diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go index 9d914e317..fde41d67e 100644 --- a/sysprop/sysprop_test.go +++ b/sysprop/sysprop_test.go @@ -81,6 +81,51 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) { } func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config { + bp += ` + cc_library { + name: "libbase", + host_supported: true, + } + + cc_library_headers { + name: "libbase_headers", + vendor_available: true, + recovery_available: true, + } + + cc_library { + name: "liblog", + no_libcrt: true, + nocrt: true, + system_shared_libs: [], + recovery_available: true, + host_supported: true, + llndk_stubs: "liblog.llndk", + } + + llndk_library { + name: "liblog.llndk", + symbol_file: "", + } + + java_library { + name: "sysprop-library-stub-platform", + sdk_version: "core_current", + } + + java_library { + name: "sysprop-library-stub-vendor", + soc_specific: true, + sdk_version: "core_current", + } + + java_library { + name: "sysprop-library-stub-product", + product_specific: true, + sdk_version: "core_current", + } + ` + bp += cc.GatherRequiredDepsForTest(android.Android) mockFS := map[string][]byte{ @@ -250,54 +295,11 @@ func TestSyspropLibrary(t *testing.T) { static_libs: ["sysprop-platform", "sysprop-vendor"], } - cc_library { - name: "libbase", - host_supported: true, - } - - cc_library_headers { - name: "libbase_headers", - vendor_available: true, - recovery_available: true, - } - - cc_library { - name: "liblog", - no_libcrt: true, - nocrt: true, - system_shared_libs: [], - recovery_available: true, - host_supported: true, - llndk_stubs: "liblog.llndk", - } - cc_binary_host { name: "hostbin", static_libs: ["sysprop-platform"], } - - llndk_library { - name: "liblog.llndk", - symbol_file: "", - } - - java_library { - name: "sysprop-library-stub-platform", - sdk_version: "core_current", - } - - java_library { - name: "sysprop-library-stub-vendor", - soc_specific: true, - sdk_version: "core_current", - } - - java_library { - name: "sysprop-library-stub-product", - product_specific: true, - sdk_version: "core_current", - } - `) + `) // Check for generated cc_library for _, variant := range []string{ @@ -391,3 +393,62 @@ func TestSyspropLibrary(t *testing.T) { t.Errorf("system api client should use public stub %q, got %q", w, g) } } + +func TestApexAvailabilityIsForwarded(t *testing.T) { + ctx := test(t, ` + sysprop_library { + name: "sysprop-platform", + apex_available: ["//apex_available:platform"], + srcs: ["android/sysprop/PlatformProperties.sysprop"], + api_packages: ["android.sysprop"], + property_owner: "Platform", + } + `) + + expected := []string{"//apex_available:platform"} + + ccModule := ctx.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module) + propFromCc := ccModule.ApexProperties.Apex_available + if !reflect.DeepEqual(propFromCc, expected) { + t.Errorf("apex_available not forwarded to cc module. expected %#v, got %#v", + expected, propFromCc) + } + + javaModule := ctx.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library) + propFromJava := javaModule.ApexProperties.Apex_available + if !reflect.DeepEqual(propFromJava, expected) { + t.Errorf("apex_available not forwarded to java module. expected %#v, got %#v", + expected, propFromJava) + } +} + +func TestMinSdkVersionIsForwarded(t *testing.T) { + ctx := test(t, ` + sysprop_library { + name: "sysprop-platform", + srcs: ["android/sysprop/PlatformProperties.sysprop"], + api_packages: ["android.sysprop"], + property_owner: "Platform", + cpp: { + min_sdk_version: "29", + }, + java: { + min_sdk_version: "30", + }, + } + `) + + ccModule := ctx.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module) + propFromCc := proptools.String(ccModule.Properties.Min_sdk_version) + if propFromCc != "29" { + t.Errorf("min_sdk_version not forwarded to cc module. expected %#v, got %#v", + "29", propFromCc) + } + + javaModule := ctx.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library) + propFromJava := javaModule.MinSdkVersion() + if propFromJava != "30" { + t.Errorf("min_sdk_version not forwarded to java module. expected %#v, got %#v", + "30", propFromJava) + } +} |