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