satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 1 | // Copyright (C) 2021 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 apex |
| 16 | |
| 17 | import ( |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 18 | "strings" |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 19 | "testing" |
| 20 | |
| 21 | "android/soong/android" |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 22 | "android/soong/dexpreopt" |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 23 | "android/soong/java" |
| 24 | ) |
| 25 | |
| 26 | var prepareForTestWithSystemserverclasspathFragment = android.GroupFixturePreparers( |
| 27 | java.PrepareForTestWithDexpreopt, |
| 28 | PrepareForTestWithApexBuildComponents, |
| 29 | ) |
| 30 | |
| 31 | func TestSystemserverclasspathFragmentContents(t *testing.T) { |
| 32 | result := android.GroupFixturePreparers( |
| 33 | prepareForTestWithSystemserverclasspathFragment, |
| 34 | prepareForTestWithMyapex, |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 35 | dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"), |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 36 | ).RunTestWithBp(t, ` |
| 37 | apex { |
| 38 | name: "myapex", |
| 39 | key: "myapex.key", |
| 40 | systemserverclasspath_fragments: [ |
| 41 | "mysystemserverclasspathfragment", |
| 42 | ], |
| 43 | updatable: false, |
| 44 | } |
| 45 | |
| 46 | apex_key { |
| 47 | name: "myapex.key", |
| 48 | public_key: "testkey.avbpubkey", |
| 49 | private_key: "testkey.pem", |
| 50 | } |
| 51 | |
| 52 | java_library { |
| 53 | name: "foo", |
| 54 | srcs: ["b.java"], |
| 55 | installable: true, |
| 56 | apex_available: [ |
| 57 | "myapex", |
| 58 | ], |
| 59 | } |
| 60 | |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 61 | java_library { |
| 62 | name: "bar", |
| 63 | srcs: ["c.java"], |
| 64 | installable: true, |
| 65 | dex_preopt: { |
| 66 | profile: "bar-art-profile", |
| 67 | }, |
| 68 | apex_available: [ |
| 69 | "myapex", |
| 70 | ], |
| 71 | } |
| 72 | |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 73 | java_library { |
| 74 | name: "baz", |
| 75 | srcs: ["d.java"], |
| 76 | installable: true, |
| 77 | dex_preopt: { |
| 78 | profile_guided: true, // ignored |
| 79 | }, |
| 80 | apex_available: [ |
| 81 | "myapex", |
| 82 | ], |
| 83 | } |
| 84 | |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 85 | systemserverclasspath_fragment { |
| 86 | name: "mysystemserverclasspathfragment", |
| 87 | contents: [ |
| 88 | "foo", |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 89 | "bar", |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 90 | "baz", |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 91 | ], |
| 92 | apex_available: [ |
| 93 | "myapex", |
| 94 | ], |
| 95 | } |
| 96 | `) |
| 97 | |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 98 | ctx := result.TestContext |
| 99 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 100 | ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{ |
satayev | 227e745 | 2021-05-20 21:35:06 +0100 | [diff] [blame] | 101 | "etc/classpaths/systemserverclasspath.pb", |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 102 | "javalib/foo.jar", |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 103 | "javalib/bar.jar", |
| 104 | "javalib/bar.jar.prof", |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 105 | "javalib/baz.jar", |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 106 | }) |
| 107 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 108 | java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex", []string{ |
Spandan Das | e21a8d4 | 2024-01-23 23:56:29 +0000 | [diff] [blame] | 109 | `dex2oatd`, |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 110 | `myapex.key`, |
| 111 | `mysystemserverclasspathfragment`, |
| 112 | }) |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 113 | |
| 114 | assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false) |
| 115 | assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true) |
| 116 | assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false) |
satayev | 333a173 | 2021-05-17 21:35:26 +0100 | [diff] [blame] | 117 | } |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 118 | |
| 119 | func TestSystemserverclasspathFragmentNoGeneratedProto(t *testing.T) { |
| 120 | result := android.GroupFixturePreparers( |
| 121 | prepareForTestWithSystemserverclasspathFragment, |
| 122 | prepareForTestWithMyapex, |
satayev | abcd597 | 2021-08-06 17:49:46 +0100 | [diff] [blame] | 123 | dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"), |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 124 | ).RunTestWithBp(t, ` |
| 125 | apex { |
| 126 | name: "myapex", |
| 127 | key: "myapex.key", |
| 128 | systemserverclasspath_fragments: [ |
| 129 | "mysystemserverclasspathfragment", |
| 130 | ], |
| 131 | updatable: false, |
| 132 | } |
| 133 | |
| 134 | apex_key { |
| 135 | name: "myapex.key", |
| 136 | public_key: "testkey.avbpubkey", |
| 137 | private_key: "testkey.pem", |
| 138 | } |
| 139 | |
| 140 | java_library { |
| 141 | name: "foo", |
| 142 | srcs: ["b.java"], |
| 143 | installable: true, |
| 144 | apex_available: [ |
| 145 | "myapex", |
| 146 | ], |
| 147 | } |
| 148 | |
| 149 | systemserverclasspath_fragment { |
| 150 | name: "mysystemserverclasspathfragment", |
| 151 | generate_classpaths_proto: false, |
| 152 | contents: [ |
| 153 | "foo", |
| 154 | ], |
| 155 | apex_available: [ |
| 156 | "myapex", |
| 157 | ], |
| 158 | } |
| 159 | `) |
| 160 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 161 | ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex", []string{ |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 162 | "javalib/foo.jar", |
| 163 | }) |
| 164 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 165 | java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{ |
Spandan Das | e21a8d4 | 2024-01-23 23:56:29 +0000 | [diff] [blame] | 166 | `dex2oatd`, |
satayev | b98371c | 2021-06-15 16:49:50 +0100 | [diff] [blame] | 167 | `myapex.key`, |
| 168 | `mysystemserverclasspathfragment`, |
| 169 | }) |
| 170 | } |
satayev | d34eb0c | 2021-08-06 13:20:28 +0100 | [diff] [blame] | 171 | |
| 172 | func TestSystemServerClasspathFragmentWithContentNotInMake(t *testing.T) { |
| 173 | android.GroupFixturePreparers( |
| 174 | prepareForTestWithSystemserverclasspathFragment, |
| 175 | prepareForTestWithMyapex, |
| 176 | dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"), |
| 177 | ). |
| 178 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( |
Ulya Trafimovich | e5b2b49 | 2021-10-04 15:42:53 +0100 | [diff] [blame] | 179 | `in contents must also be declared in PRODUCT_APEX_SYSTEM_SERVER_JARS`)). |
satayev | d34eb0c | 2021-08-06 13:20:28 +0100 | [diff] [blame] | 180 | RunTestWithBp(t, ` |
| 181 | apex { |
| 182 | name: "myapex", |
| 183 | key: "myapex.key", |
| 184 | systemserverclasspath_fragments: [ |
| 185 | "mysystemserverclasspathfragment", |
| 186 | ], |
| 187 | updatable: false, |
| 188 | } |
| 189 | |
| 190 | apex_key { |
| 191 | name: "myapex.key", |
| 192 | public_key: "testkey.avbpubkey", |
| 193 | private_key: "testkey.pem", |
| 194 | } |
| 195 | |
| 196 | java_library { |
| 197 | name: "foo", |
| 198 | srcs: ["b.java"], |
| 199 | installable: true, |
| 200 | apex_available: ["myapex"], |
| 201 | } |
| 202 | |
| 203 | java_library { |
| 204 | name: "bar", |
| 205 | srcs: ["b.java"], |
| 206 | installable: true, |
| 207 | apex_available: ["myapex"], |
| 208 | } |
| 209 | |
| 210 | systemserverclasspath_fragment { |
| 211 | name: "mysystemserverclasspathfragment", |
| 212 | contents: [ |
| 213 | "foo", |
| 214 | "bar", |
| 215 | ], |
| 216 | apex_available: [ |
| 217 | "myapex", |
| 218 | ], |
| 219 | } |
| 220 | `) |
| 221 | } |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 222 | |
| 223 | func TestPrebuiltSystemserverclasspathFragmentContents(t *testing.T) { |
| 224 | result := android.GroupFixturePreparers( |
| 225 | prepareForTestWithSystemserverclasspathFragment, |
| 226 | prepareForTestWithMyapex, |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 227 | dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar"), |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 228 | ).RunTestWithBp(t, ` |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 229 | prebuilt_apex { |
| 230 | name: "myapex", |
| 231 | arch: { |
| 232 | arm64: { |
| 233 | src: "myapex-arm64.apex", |
| 234 | }, |
| 235 | arm: { |
| 236 | src: "myapex-arm.apex", |
| 237 | }, |
| 238 | }, |
| 239 | exported_systemserverclasspath_fragments: ["mysystemserverclasspathfragment"], |
| 240 | } |
| 241 | |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 242 | java_import { |
| 243 | name: "foo", |
| 244 | jars: ["foo.jar"], |
| 245 | apex_available: [ |
| 246 | "myapex", |
| 247 | ], |
| 248 | } |
| 249 | |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 250 | java_import { |
| 251 | name: "bar", |
| 252 | jars: ["bar.jar"], |
| 253 | dex_preopt: { |
| 254 | profile_guided: true, |
| 255 | }, |
| 256 | apex_available: [ |
| 257 | "myapex", |
| 258 | ], |
| 259 | } |
| 260 | |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 261 | prebuilt_systemserverclasspath_fragment { |
| 262 | name: "mysystemserverclasspathfragment", |
| 263 | prefer: true, |
| 264 | contents: [ |
| 265 | "foo", |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 266 | "bar", |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 267 | ], |
| 268 | apex_available: [ |
| 269 | "myapex", |
| 270 | ], |
| 271 | } |
| 272 | `) |
| 273 | |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 274 | ctx := result.TestContext |
| 275 | |
| 276 | java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex", []string{ |
Spandan Das | 2069c3f | 2023-12-06 19:40:24 +0000 | [diff] [blame] | 277 | `dex2oatd`, |
Spandan Das | 3576e76 | 2024-01-03 18:57:03 +0000 | [diff] [blame] | 278 | `prebuilt_myapex.apex.selector`, |
| 279 | `prebuilt_myapex.deapexer`, |
Jiakai Zhang | 774dd30 | 2021-09-26 03:54:25 +0000 | [diff] [blame] | 280 | `prebuilt_mysystemserverclasspathfragment`, |
| 281 | }) |
| 282 | |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 283 | java.CheckModuleDependencies(t, ctx, "mysystemserverclasspathfragment", "android_common_myapex", []string{ |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 284 | `prebuilt_bar`, |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 285 | `prebuilt_foo`, |
Spandan Das | 3576e76 | 2024-01-03 18:57:03 +0000 | [diff] [blame] | 286 | `prebuilt_myapex.deapexer`, |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 287 | }) |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 288 | |
Spandan Das | 3576e76 | 2024-01-03 18:57:03 +0000 | [diff] [blame] | 289 | ensureExactDeapexedContents(t, ctx, "prebuilt_myapex", "android_common", []string{ |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 290 | "javalib/foo.jar", |
| 291 | "javalib/bar.jar", |
| 292 | "javalib/bar.jar.prof", |
| 293 | }) |
| 294 | |
Spandan Das | 2ea84dd | 2024-01-25 22:12:50 +0000 | [diff] [blame] | 295 | assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false) |
| 296 | assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true) |
Jiakai Zhang | c986427 | 2021-09-26 03:52:19 +0000 | [diff] [blame] | 297 | } |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 298 | |
| 299 | func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { |
| 300 | result := android.GroupFixturePreparers( |
| 301 | prepareForTestWithSystemserverclasspathFragment, |
| 302 | prepareForTestWithMyapex, |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 303 | dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"), |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 304 | ).RunTestWithBp(t, ` |
| 305 | apex { |
| 306 | name: "myapex", |
| 307 | key: "myapex.key", |
| 308 | systemserverclasspath_fragments: [ |
| 309 | "mysystemserverclasspathfragment", |
| 310 | ], |
| 311 | updatable: false, |
| 312 | } |
| 313 | |
| 314 | apex_key { |
| 315 | name: "myapex.key", |
| 316 | public_key: "testkey.avbpubkey", |
| 317 | private_key: "testkey.pem", |
| 318 | } |
| 319 | |
| 320 | java_library { |
| 321 | name: "foo", |
| 322 | srcs: ["b.java"], |
| 323 | installable: true, |
| 324 | apex_available: [ |
| 325 | "myapex", |
| 326 | ], |
| 327 | } |
| 328 | |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 329 | java_library { |
| 330 | name: "bar", |
| 331 | srcs: ["c.java"], |
| 332 | dex_preopt: { |
| 333 | profile: "bar-art-profile", |
| 334 | }, |
| 335 | installable: true, |
| 336 | apex_available: [ |
| 337 | "myapex", |
| 338 | ], |
| 339 | } |
| 340 | |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 341 | java_library { |
| 342 | name: "baz", |
| 343 | srcs: ["d.java"], |
| 344 | dex_preopt: { |
| 345 | profile_guided: true, // ignored |
| 346 | }, |
| 347 | installable: true, |
| 348 | apex_available: [ |
| 349 | "myapex", |
| 350 | ], |
| 351 | } |
| 352 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 353 | systemserverclasspath_fragment { |
| 354 | name: "mysystemserverclasspathfragment", |
| 355 | standalone_contents: [ |
| 356 | "foo", |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 357 | "bar", |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 358 | "baz", |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 359 | ], |
| 360 | apex_available: [ |
| 361 | "myapex", |
| 362 | ], |
| 363 | } |
| 364 | `) |
| 365 | |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 366 | ctx := result.TestContext |
| 367 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 368 | ensureExactContents(t, ctx, "myapex", "android_common_myapex", []string{ |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 369 | "etc/classpaths/systemserverclasspath.pb", |
| 370 | "javalib/foo.jar", |
Jiakai Zhang | 3317ce7 | 2023-02-08 01:19:19 +0800 | [diff] [blame] | 371 | "javalib/bar.jar", |
| 372 | "javalib/bar.jar.prof", |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 373 | "javalib/baz.jar", |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 374 | }) |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 375 | |
| 376 | assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false) |
| 377 | assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true) |
| 378 | assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) { |
| 382 | result := android.GroupFixturePreparers( |
| 383 | prepareForTestWithSystemserverclasspathFragment, |
| 384 | prepareForTestWithMyapex, |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 385 | dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar"), |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 386 | ).RunTestWithBp(t, ` |
| 387 | prebuilt_apex { |
| 388 | name: "myapex", |
| 389 | arch: { |
| 390 | arm64: { |
| 391 | src: "myapex-arm64.apex", |
| 392 | }, |
| 393 | arm: { |
| 394 | src: "myapex-arm.apex", |
| 395 | }, |
| 396 | }, |
| 397 | exported_systemserverclasspath_fragments: ["mysystemserverclasspathfragment"], |
| 398 | } |
| 399 | |
| 400 | java_import { |
| 401 | name: "foo", |
| 402 | jars: ["foo.jar"], |
| 403 | apex_available: [ |
| 404 | "myapex", |
| 405 | ], |
| 406 | } |
| 407 | |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 408 | java_import { |
| 409 | name: "bar", |
| 410 | jars: ["bar.jar"], |
| 411 | dex_preopt: { |
| 412 | profile_guided: true, |
| 413 | }, |
| 414 | apex_available: [ |
| 415 | "myapex", |
| 416 | ], |
| 417 | } |
| 418 | |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 419 | prebuilt_systemserverclasspath_fragment { |
| 420 | name: "mysystemserverclasspathfragment", |
| 421 | prefer: true, |
| 422 | standalone_contents: [ |
| 423 | "foo", |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 424 | "bar", |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 425 | ], |
| 426 | apex_available: [ |
| 427 | "myapex", |
| 428 | ], |
| 429 | } |
| 430 | `) |
| 431 | |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 432 | ctx := result.TestContext |
| 433 | |
| 434 | java.CheckModuleDependencies(t, ctx, "mysystemserverclasspathfragment", "android_common_myapex", []string{ |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 435 | `prebuilt_bar`, |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 436 | `prebuilt_foo`, |
Spandan Das | 3576e76 | 2024-01-03 18:57:03 +0000 | [diff] [blame] | 437 | `prebuilt_myapex.deapexer`, |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 438 | }) |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 439 | |
Spandan Das | 3576e76 | 2024-01-03 18:57:03 +0000 | [diff] [blame] | 440 | ensureExactDeapexedContents(t, ctx, "prebuilt_myapex", "android_common", []string{ |
Jiakai Zhang | 81e4681 | 2023-02-08 21:56:07 +0800 | [diff] [blame] | 441 | "javalib/foo.jar", |
| 442 | "javalib/bar.jar", |
| 443 | "javalib/bar.jar.prof", |
| 444 | }) |
| 445 | |
Spandan Das | 2ea84dd | 2024-01-25 22:12:50 +0000 | [diff] [blame] | 446 | assertProfileGuidedPrebuilt(t, ctx, "myapex", "foo", false) |
| 447 | assertProfileGuidedPrebuilt(t, ctx, "myapex", "bar", true) |
Jiakai Zhang | cee9e19 | 2021-10-29 19:46:45 +0000 | [diff] [blame] | 448 | } |
Jiakai Zhang | 1f4542c | 2023-02-15 22:43:09 +0000 | [diff] [blame] | 449 | |
| 450 | func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName string, variant string, expected bool) { |
| 451 | dexpreopt := ctx.ModuleForTests(moduleName, variant).Rule("dexpreopt") |
| 452 | actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=") |
| 453 | if expected != actual { |
| 454 | t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual) |
| 455 | } |
| 456 | } |
Spandan Das | 2ea84dd | 2024-01-25 22:12:50 +0000 | [diff] [blame] | 457 | |
| 458 | func assertProfileGuidedPrebuilt(t *testing.T, ctx *android.TestContext, apexName string, moduleName string, expected bool) { |
| 459 | dexpreopt := ctx.ModuleForTests(apexName, "android_common_"+apexName).Rule("dexpreopt." + moduleName) |
| 460 | actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=") |
| 461 | if expected != actual { |
| 462 | t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual) |
| 463 | } |
| 464 | } |