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