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