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