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