Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package sysprop |
| 16 | |
| 17 | import ( |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 18 | "os" |
| 19 | "strings" |
| 20 | "testing" |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 21 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 22 | "android/soong/android" |
| 23 | "android/soong/cc" |
| 24 | "android/soong/java" |
| 25 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 26 | "github.com/google/blueprint/proptools" |
| 27 | ) |
| 28 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 29 | func TestMain(m *testing.M) { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 30 | os.Exit(m.Run()) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 31 | } |
| 32 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 33 | func test(t *testing.T, bp string) *android.TestResult { |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 34 | t.Helper() |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 35 | |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 36 | bp += ` |
| 37 | cc_library { |
| 38 | name: "libbase", |
| 39 | host_supported: true, |
| 40 | } |
| 41 | |
| 42 | cc_library_headers { |
| 43 | name: "libbase_headers", |
| 44 | vendor_available: true, |
| 45 | recovery_available: true, |
| 46 | } |
| 47 | |
| 48 | cc_library { |
| 49 | name: "liblog", |
| 50 | no_libcrt: true, |
| 51 | nocrt: true, |
| 52 | system_shared_libs: [], |
| 53 | recovery_available: true, |
| 54 | host_supported: true, |
| 55 | llndk_stubs: "liblog.llndk", |
| 56 | } |
| 57 | |
| 58 | llndk_library { |
| 59 | name: "liblog.llndk", |
| 60 | symbol_file: "", |
| 61 | } |
| 62 | |
| 63 | java_library { |
| 64 | name: "sysprop-library-stub-platform", |
| 65 | sdk_version: "core_current", |
| 66 | } |
| 67 | |
| 68 | java_library { |
| 69 | name: "sysprop-library-stub-vendor", |
| 70 | soc_specific: true, |
| 71 | sdk_version: "core_current", |
| 72 | } |
| 73 | |
| 74 | java_library { |
| 75 | name: "sysprop-library-stub-product", |
| 76 | product_specific: true, |
| 77 | sdk_version: "core_current", |
| 78 | } |
| 79 | ` |
| 80 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 81 | mockFS := android.MockFS{ |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 82 | "a.java": nil, |
| 83 | "b.java": nil, |
| 84 | "c.java": nil, |
| 85 | "d.cpp": nil, |
| 86 | "api/sysprop-platform-current.txt": nil, |
| 87 | "api/sysprop-platform-latest.txt": nil, |
| 88 | "api/sysprop-platform-on-product-current.txt": nil, |
| 89 | "api/sysprop-platform-on-product-latest.txt": nil, |
| 90 | "api/sysprop-vendor-current.txt": nil, |
| 91 | "api/sysprop-vendor-latest.txt": nil, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 92 | "api/sysprop-vendor-on-product-current.txt": nil, |
| 93 | "api/sysprop-vendor-on-product-latest.txt": nil, |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 94 | "api/sysprop-odm-current.txt": nil, |
| 95 | "api/sysprop-odm-latest.txt": nil, |
| 96 | "framework/aidl/a.aidl": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 97 | |
| 98 | // For framework-res, which is an implicit dependency for framework |
Dan Willemsen | 412160e | 2019-04-09 21:36:26 -0700 | [diff] [blame] | 99 | "AndroidManifest.xml": nil, |
| 100 | "build/make/target/product/security/testkey": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 101 | |
| 102 | "build/soong/scripts/jar-wrapper.sh": nil, |
| 103 | |
| 104 | "build/make/core/proguard.flags": nil, |
| 105 | "build/make/core/proguard_basic_keeps.flags": nil, |
| 106 | |
| 107 | "jdk8/jre/lib/jce.jar": nil, |
| 108 | "jdk8/jre/lib/rt.jar": nil, |
| 109 | "jdk8/lib/tools.jar": nil, |
| 110 | |
| 111 | "bar-doc/a.java": nil, |
| 112 | "bar-doc/b.java": nil, |
| 113 | "bar-doc/IFoo.aidl": nil, |
| 114 | "bar-doc/known_oj_tags.txt": nil, |
| 115 | "external/doclava/templates-sdk": nil, |
| 116 | |
| 117 | "cert/new_cert.x509.pem": nil, |
| 118 | "cert/new_cert.pk8": nil, |
| 119 | |
| 120 | "android/sysprop/PlatformProperties.sysprop": nil, |
| 121 | "com/android/VendorProperties.sysprop": nil, |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 122 | "com/android2/OdmProperties.sysprop": nil, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 123 | } |
| 124 | |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 125 | result := android.GroupFixturePreparers( |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 126 | cc.PrepareForTestWithCcDefaultModules, |
| 127 | java.PrepareForTestWithJavaDefaultModules, |
| 128 | PrepareForTestWithSyspropBuildComponents, |
| 129 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 130 | variables.DeviceSystemSdkVersions = []string{"28"} |
| 131 | variables.DeviceVndkVersion = proptools.StringPtr("current") |
| 132 | variables.Platform_vndk_version = proptools.StringPtr("VER") |
| 133 | }), |
| 134 | mockFS.AddToFixture(), |
| 135 | android.FixtureWithRootAndroidBp(bp), |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 136 | ).RunTest(t) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 137 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 138 | return result |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | func TestSyspropLibrary(t *testing.T) { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 142 | result := test(t, ` |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 143 | sysprop_library { |
| 144 | name: "sysprop-platform", |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 145 | apex_available: ["//apex_available:platform"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 146 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 147 | api_packages: ["android.sysprop"], |
| 148 | property_owner: "Platform", |
| 149 | vendor_available: true, |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 150 | host_supported: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | sysprop_library { |
| 154 | name: "sysprop-platform-on-product", |
| 155 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 156 | api_packages: ["android.sysprop"], |
| 157 | property_owner: "Platform", |
| 158 | product_specific: true, |
| 159 | } |
| 160 | |
| 161 | sysprop_library { |
| 162 | name: "sysprop-vendor", |
| 163 | srcs: ["com/android/VendorProperties.sysprop"], |
| 164 | api_packages: ["com.android"], |
| 165 | property_owner: "Vendor", |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 166 | vendor: true, |
| 167 | } |
| 168 | |
| 169 | sysprop_library { |
| 170 | name: "sysprop-vendor-on-product", |
| 171 | srcs: ["com/android/VendorProperties.sysprop"], |
| 172 | api_packages: ["com.android"], |
| 173 | property_owner: "Vendor", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 174 | product_specific: true, |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 175 | } |
| 176 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 177 | sysprop_library { |
| 178 | name: "sysprop-odm", |
| 179 | srcs: ["com/android2/OdmProperties.sysprop"], |
| 180 | api_packages: ["com.android2"], |
| 181 | property_owner: "Odm", |
| 182 | device_specific: true, |
| 183 | } |
| 184 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 185 | java_library { |
| 186 | name: "java-platform", |
| 187 | srcs: ["c.java"], |
| 188 | sdk_version: "system_current", |
| 189 | libs: ["sysprop-platform"], |
| 190 | } |
| 191 | |
| 192 | java_library { |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 193 | name: "java-platform-private", |
| 194 | srcs: ["c.java"], |
| 195 | platform_apis: true, |
| 196 | libs: ["sysprop-platform"], |
| 197 | } |
| 198 | |
| 199 | java_library { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 200 | name: "java-product", |
| 201 | srcs: ["c.java"], |
| 202 | sdk_version: "system_current", |
| 203 | product_specific: true, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 204 | libs: ["sysprop-platform", "sysprop-vendor-on-product"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | java_library { |
| 208 | name: "java-vendor", |
| 209 | srcs: ["c.java"], |
| 210 | sdk_version: "system_current", |
| 211 | soc_specific: true, |
| 212 | libs: ["sysprop-platform", "sysprop-vendor"], |
| 213 | } |
| 214 | |
| 215 | cc_library { |
| 216 | name: "cc-client-platform", |
| 217 | srcs: ["d.cpp"], |
| 218 | static_libs: ["sysprop-platform"], |
| 219 | } |
| 220 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 221 | cc_library_static { |
| 222 | name: "cc-client-platform-static", |
| 223 | srcs: ["d.cpp"], |
| 224 | whole_static_libs: ["sysprop-platform"], |
| 225 | } |
| 226 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 227 | cc_library { |
| 228 | name: "cc-client-product", |
| 229 | srcs: ["d.cpp"], |
| 230 | product_specific: true, |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 231 | static_libs: ["sysprop-platform-on-product", "sysprop-vendor-on-product"], |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | cc_library { |
| 235 | name: "cc-client-vendor", |
| 236 | srcs: ["d.cpp"], |
| 237 | soc_specific: true, |
| 238 | static_libs: ["sysprop-platform", "sysprop-vendor"], |
| 239 | } |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 240 | |
Inseob Kim | 89db15d | 2020-02-03 18:06:46 +0900 | [diff] [blame] | 241 | cc_binary_host { |
| 242 | name: "hostbin", |
| 243 | static_libs: ["sysprop-platform"], |
Inseob Kim | 1f95976 | 2019-03-27 17:20:37 +0900 | [diff] [blame] | 244 | } |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 245 | `) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 246 | |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 247 | // Check for generated cc_library |
| 248 | for _, variant := range []string{ |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 249 | "android_vendor.VER_arm_armv7-a-neon_shared", |
| 250 | "android_vendor.VER_arm_armv7-a-neon_static", |
| 251 | "android_vendor.VER_arm64_armv8-a_shared", |
| 252 | "android_vendor.VER_arm64_armv8-a_static", |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 253 | } { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 254 | result.ModuleForTests("libsysprop-platform", variant) |
| 255 | result.ModuleForTests("libsysprop-vendor", variant) |
| 256 | result.ModuleForTests("libsysprop-odm", variant) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 257 | } |
| 258 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 259 | for _, variant := range []string{ |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 260 | "android_arm_armv7-a-neon_shared", |
| 261 | "android_arm_armv7-a-neon_static", |
| 262 | "android_arm64_armv8-a_shared", |
| 263 | "android_arm64_armv8-a_static", |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 264 | } { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 265 | library := result.ModuleForTests("libsysprop-platform", variant).Module().(*cc.Module) |
Paul Duffin | 7b3de8f | 2020-03-30 18:00:25 +0100 | [diff] [blame] | 266 | expectedApexAvailableOnLibrary := []string{"//apex_available:platform"} |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 267 | android.AssertDeepEquals(t, "apex available property on libsysprop-platform", expectedApexAvailableOnLibrary, library.ApexProperties.Apex_available) |
Inseob Kim | 4288274 | 2019-07-30 17:55:33 +0900 | [diff] [blame] | 268 | |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 269 | // product variant of vendor-owned sysprop_library |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 270 | result.ModuleForTests("libsysprop-vendor-on-product", variant) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 271 | } |
| 272 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 273 | result.ModuleForTests("sysprop-platform", "android_common") |
| 274 | result.ModuleForTests("sysprop-platform_public", "android_common") |
| 275 | result.ModuleForTests("sysprop-vendor", "android_common") |
| 276 | result.ModuleForTests("sysprop-vendor-on-product", "android_common") |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 277 | |
| 278 | // Check for exported includes |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 279 | coreVariant := "android_arm64_armv8-a_static" |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 280 | vendorVariant := "android_vendor.VER_arm64_armv8-a_static" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 281 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 282 | platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/include" |
| 283 | platformPublicCorePath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 284 | platformPublicVendorPath := "libsysprop-platform/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 285 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 286 | platformOnProductPath := "libsysprop-platform-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 287 | |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 288 | vendorInternalPath := "libsysprop-vendor/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/include" |
Inseob Kim | fe61218 | 2020-10-20 16:29:55 +0900 | [diff] [blame] | 289 | vendorPublicPath := "libsysprop-vendor-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include" |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 290 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 291 | platformClient := result.ModuleForTests("cc-client-platform", coreVariant) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 292 | platformFlags := platformClient.Rule("cc").Args["cFlags"] |
| 293 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 294 | // platform should use platform's internal header |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 295 | android.AssertStringDoesContain(t, "flags for platform", platformFlags, platformInternalPath) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 296 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 297 | platformStaticClient := result.ModuleForTests("cc-client-platform-static", coreVariant) |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 298 | platformStaticFlags := platformStaticClient.Rule("cc").Args["cFlags"] |
| 299 | |
| 300 | // platform-static should use platform's internal header |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 301 | android.AssertStringDoesContain(t, "flags for platform-static", platformStaticFlags, platformInternalPath) |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 302 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 303 | productClient := result.ModuleForTests("cc-client-product", coreVariant) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 304 | productFlags := productClient.Rule("cc").Args["cFlags"] |
| 305 | |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 306 | // Product should use platform's and vendor's public headers |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 307 | if !strings.Contains(productFlags, platformOnProductPath) || |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 308 | !strings.Contains(productFlags, vendorPublicPath) { |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 309 | t.Errorf("flags for product must contain %#v and %#v, but was %#v.", |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 310 | platformPublicCorePath, vendorPublicPath, productFlags) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 311 | } |
| 312 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 313 | vendorClient := result.ModuleForTests("cc-client-vendor", vendorVariant) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 314 | vendorFlags := vendorClient.Rule("cc").Args["cFlags"] |
| 315 | |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 316 | // Vendor should use platform's public header and vendor's internal header |
| 317 | if !strings.Contains(vendorFlags, platformPublicVendorPath) || |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 318 | !strings.Contains(vendorFlags, vendorInternalPath) { |
| 319 | t.Errorf("flags for vendor must contain %#v and %#v, but was %#v.", |
Inseob Kim | 5cefbd2 | 2019-06-08 20:36:59 +0900 | [diff] [blame] | 320 | platformPublicVendorPath, vendorInternalPath, vendorFlags) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 321 | } |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 322 | |
| 323 | // Java modules linking against system API should use public stub |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 324 | javaSystemApiClient := result.ModuleForTests("java-platform", "android_common").Rule("javac") |
| 325 | syspropPlatformPublic := result.ModuleForTests("sysprop-platform_public", "android_common").Description("for turbine") |
Colin Cross | 75ce9ec | 2021-02-26 16:20:32 -0800 | [diff] [blame] | 326 | if g, w := javaSystemApiClient.Implicits.Strings(), syspropPlatformPublic.Output.String(); !android.InList(w, g) { |
| 327 | t.Errorf("system api client should use public stub %q, got %q", w, g) |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 328 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 329 | } |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 330 | |
| 331 | func TestApexAvailabilityIsForwarded(t *testing.T) { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 332 | result := test(t, ` |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 333 | sysprop_library { |
| 334 | name: "sysprop-platform", |
| 335 | apex_available: ["//apex_available:platform"], |
| 336 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 337 | api_packages: ["android.sysprop"], |
| 338 | property_owner: "Platform", |
| 339 | } |
| 340 | `) |
| 341 | |
| 342 | expected := []string{"//apex_available:platform"} |
| 343 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 344 | ccModule := result.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 345 | propFromCc := ccModule.ApexProperties.Apex_available |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 346 | android.AssertDeepEquals(t, "apex_available forwarding to cc module", expected, propFromCc) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 347 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 348 | javaModule := result.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 349 | propFromJava := javaModule.ApexProperties.Apex_available |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 350 | android.AssertDeepEquals(t, "apex_available forwarding to java module", expected, propFromJava) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | func TestMinSdkVersionIsForwarded(t *testing.T) { |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 354 | result := test(t, ` |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 355 | sysprop_library { |
| 356 | name: "sysprop-platform", |
| 357 | srcs: ["android/sysprop/PlatformProperties.sysprop"], |
| 358 | api_packages: ["android.sysprop"], |
| 359 | property_owner: "Platform", |
| 360 | cpp: { |
| 361 | min_sdk_version: "29", |
| 362 | }, |
| 363 | java: { |
| 364 | min_sdk_version: "30", |
| 365 | }, |
| 366 | } |
| 367 | `) |
| 368 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 369 | ccModule := result.ModuleForTests("libsysprop-platform", "android_arm64_armv8-a_shared").Module().(*cc.Module) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 370 | propFromCc := proptools.String(ccModule.Properties.Min_sdk_version) |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 371 | android.AssertStringEquals(t, "min_sdk_version forwarding to cc module", "29", propFromCc) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 372 | |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 373 | javaModule := result.ModuleForTests("sysprop-platform", "android_common").Module().(*java.Library) |
Jiyong Park | f1691d2 | 2021-03-29 20:11:58 +0900 | [diff] [blame^] | 374 | propFromJava := javaModule.MinSdkVersionString() |
Paul Duffin | 9cbbbb8 | 2021-03-18 00:21:03 +0000 | [diff] [blame] | 375 | android.AssertStringEquals(t, "min_sdk_version forwarding to java module", "30", propFromJava) |
Jiyong Park | 5e914b2 | 2021-03-08 10:09:52 +0900 | [diff] [blame] | 376 | } |