Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 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 filesystem |
| 16 | |
| 17 | import ( |
| 18 | "os" |
| 19 | "testing" |
| 20 | |
| 21 | "android/soong/android" |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 22 | "android/soong/bpf" |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 23 | "android/soong/cc" |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 24 | "android/soong/etc" |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 25 | "android/soong/java" |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 26 | "android/soong/phony" |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 27 | |
| 28 | "github.com/google/blueprint/proptools" |
Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 29 | ) |
| 30 | |
| 31 | func TestMain(m *testing.M) { |
| 32 | os.Exit(m.Run()) |
| 33 | } |
| 34 | |
| 35 | var fixture = android.GroupFixturePreparers( |
| 36 | android.PrepareForIntegrationTestWithAndroid, |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 37 | android.PrepareForTestWithAndroidBuildComponents, |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 38 | bpf.PrepareForTestWithBpf, |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 39 | cc.PrepareForIntegrationTestWithCc, |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 40 | etc.PrepareForTestWithPrebuiltEtc, |
| 41 | java.PrepareForTestWithJavaBuildComponents, |
| 42 | java.PrepareForTestWithJavaDefaultModules, |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 43 | phony.PrepareForTestWithPhony, |
Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 44 | PrepareForTestWithFilesystemBuildComponents, |
| 45 | ) |
| 46 | |
| 47 | func TestFileSystemDeps(t *testing.T) { |
| 48 | result := fixture.RunTestWithBp(t, ` |
| 49 | android_filesystem { |
| 50 | name: "myfilesystem", |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 51 | multilib: { |
| 52 | common: { |
| 53 | deps: [ |
| 54 | "bpf.o", |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 55 | "phony", |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 56 | ], |
| 57 | }, |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 58 | lib32: { |
| 59 | deps: [ |
| 60 | "foo", |
| 61 | "libbar", |
| 62 | ], |
| 63 | }, |
| 64 | lib64: { |
| 65 | deps: [ |
| 66 | "libbar", |
| 67 | ], |
| 68 | }, |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 69 | }, |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 70 | compile_multilib: "both", |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | bpf { |
| 74 | name: "bpf.o", |
| 75 | srcs: ["bpf.c"], |
Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 76 | } |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 77 | |
| 78 | cc_binary { |
| 79 | name: "foo", |
| 80 | compile_multilib: "prefer32", |
| 81 | } |
| 82 | |
| 83 | cc_library { |
| 84 | name: "libbar", |
Jiyong Park | 8bcf3c6 | 2024-03-18 18:37:10 +0900 | [diff] [blame] | 85 | required: ["libbaz"], |
Jiyong Park | f21dd65 | 2024-04-17 05:22:37 +0000 | [diff] [blame] | 86 | target: { |
| 87 | platform: { |
| 88 | required: ["lib_platform_only"], |
| 89 | }, |
| 90 | }, |
Jiyong Park | 8bcf3c6 | 2024-03-18 18:37:10 +0900 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | cc_library { |
| 94 | name: "libbaz", |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 95 | } |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 96 | |
Jiyong Park | f21dd65 | 2024-04-17 05:22:37 +0000 | [diff] [blame] | 97 | cc_library { |
| 98 | name: "lib_platform_only", |
| 99 | } |
| 100 | |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 101 | phony { |
| 102 | name: "phony", |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 103 | required: [ |
| 104 | "libquz", |
| 105 | "myapp", |
| 106 | ], |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | cc_library { |
| 110 | name: "libquz", |
| 111 | } |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 112 | |
| 113 | android_app { |
| 114 | name: "myapp", |
| 115 | platform_apis: true, |
| 116 | installable: true, |
| 117 | } |
Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 118 | `) |
| 119 | |
| 120 | // produces "myfilesystem.img" |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 121 | result.ModuleForTests(t, "myfilesystem", "android_common").Output("myfilesystem.img") |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 122 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 123 | fs := result.ModuleForTests(t, "myfilesystem", "android_common").Module().(*filesystem) |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 124 | expected := []string{ |
Jiyong Park | 73e5bab | 2024-04-05 13:37:21 +0900 | [diff] [blame] | 125 | "app/myapp/myapp.apk", |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 126 | "bin/foo", |
| 127 | "lib/libbar.so", |
| 128 | "lib64/libbar.so", |
Jiyong Park | 8bcf3c6 | 2024-03-18 18:37:10 +0900 | [diff] [blame] | 129 | "lib64/libbaz.so", |
Jiyong Park | 9c540c8 | 2024-03-26 10:48:27 +0900 | [diff] [blame] | 130 | "lib64/libquz.so", |
Jiyong Park | f21dd65 | 2024-04-17 05:22:37 +0000 | [diff] [blame] | 131 | "lib64/lib_platform_only.so", |
Jiyong Park | eec7c38 | 2024-02-16 16:10:13 +0900 | [diff] [blame] | 132 | "etc/bpf/bpf.o", |
| 133 | } |
Jiyong Park | 06c4cdc | 2024-02-16 15:35:03 +0900 | [diff] [blame] | 134 | for _, e := range expected { |
| 135 | android.AssertStringListContains(t, "missing entry", fs.entries, e) |
| 136 | } |
Jooyung Han | 9706cbc | 2021-04-15 22:43:48 +0900 | [diff] [blame] | 137 | } |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 138 | |
| 139 | func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) { |
| 140 | result := fixture.RunTestWithBp(t, ` |
Jooyung Han | 0fbbc2b | 2022-03-25 12:35:46 +0900 | [diff] [blame] | 141 | android_system_image { |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 142 | name: "myfilesystem", |
Kiyoung Kim | 6711821 | 2024-11-07 13:23:44 +0900 | [diff] [blame] | 143 | base_dir: "system", |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 144 | deps: [ |
| 145 | "libfoo", |
Jooyung Han | 0fbbc2b | 2022-03-25 12:35:46 +0900 | [diff] [blame] | 146 | "libbar", |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 147 | ], |
Spandan Das | 2047a4c | 2024-11-11 21:24:58 +0000 | [diff] [blame] | 148 | linker_config: { |
Kiyoung Kim | 6711821 | 2024-11-07 13:23:44 +0900 | [diff] [blame] | 149 | gen_linker_config: true, |
| 150 | linker_config_srcs: ["linker.config.json"], |
| 151 | }, |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | cc_library { |
| 155 | name: "libfoo", |
| 156 | stubs: { |
| 157 | symbol_file: "libfoo.map.txt", |
| 158 | }, |
| 159 | } |
| 160 | |
| 161 | cc_library { |
| 162 | name: "libbar", |
| 163 | } |
| 164 | `) |
| 165 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 166 | module := result.ModuleForTests(t, "myfilesystem", "android_common") |
Cole Faust | fee2701 | 2024-12-13 14:10:31 -0800 | [diff] [blame] | 167 | output := module.Output("out/soong/.intermediates/myfilesystem/android_common/linker.config.pb") |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 168 | |
Cole Faust | fee2701 | 2024-12-13 14:10:31 -0800 | [diff] [blame] | 169 | linkerConfigCommand := output.RuleParams.Command |
Cole Faust | d7556eb | 2024-12-02 13:18:58 -0800 | [diff] [blame] | 170 | |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 171 | android.AssertStringDoesContain(t, "linker.config.pb should have libfoo", |
Cole Faust | d7556eb | 2024-12-02 13:18:58 -0800 | [diff] [blame] | 172 | linkerConfigCommand, "libfoo.so") |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 173 | android.AssertStringDoesNotContain(t, "linker.config.pb should not have libbar", |
Cole Faust | d7556eb | 2024-12-02 13:18:58 -0800 | [diff] [blame] | 174 | linkerConfigCommand, "libbar.so") |
Jiyong Park | fa61613 | 2021-04-20 11:36:40 +0900 | [diff] [blame] | 175 | } |
Jooyung Han | 0fbbc2b | 2022-03-25 12:35:46 +0900 | [diff] [blame] | 176 | |
| 177 | func registerComponent(ctx android.RegistrationContext) { |
| 178 | ctx.RegisterModuleType("component", componentFactory) |
| 179 | } |
| 180 | |
| 181 | func componentFactory() android.Module { |
| 182 | m := &component{} |
| 183 | m.AddProperties(&m.properties) |
| 184 | android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) |
| 185 | return m |
| 186 | } |
| 187 | |
| 188 | type component struct { |
| 189 | android.ModuleBase |
| 190 | properties struct { |
| 191 | Install_copy_in_data []string |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | func (c *component) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 196 | output := android.PathForModuleOut(ctx, c.Name()) |
| 197 | dir := android.PathForModuleInstall(ctx, "components") |
| 198 | ctx.InstallFile(dir, c.Name(), output) |
| 199 | |
| 200 | dataDir := android.PathForModuleInPartitionInstall(ctx, "data", "components") |
| 201 | for _, d := range c.properties.Install_copy_in_data { |
| 202 | ctx.InstallFile(dataDir, d, output) |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | func TestFileSystemGathersItemsOnlyInSystemPartition(t *testing.T) { |
| 207 | f := android.GroupFixturePreparers(fixture, android.FixtureRegisterWithContext(registerComponent)) |
| 208 | result := f.RunTestWithBp(t, ` |
| 209 | android_system_image { |
| 210 | name: "myfilesystem", |
| 211 | multilib: { |
| 212 | common: { |
| 213 | deps: ["foo"], |
| 214 | }, |
| 215 | }, |
Spandan Das | 2047a4c | 2024-11-11 21:24:58 +0000 | [diff] [blame] | 216 | linker_config: { |
Kiyoung Kim | 6711821 | 2024-11-07 13:23:44 +0900 | [diff] [blame] | 217 | gen_linker_config: true, |
| 218 | linker_config_srcs: ["linker.config.json"], |
| 219 | }, |
Jooyung Han | 0fbbc2b | 2022-03-25 12:35:46 +0900 | [diff] [blame] | 220 | } |
| 221 | component { |
| 222 | name: "foo", |
| 223 | install_copy_in_data: ["bar"], |
| 224 | } |
| 225 | `) |
| 226 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 227 | module := result.ModuleForTests(t, "myfilesystem", "android_common").Module().(*systemImage) |
Spandan Das | 978f453 | 2024-12-05 21:05:43 +0000 | [diff] [blame] | 228 | android.AssertDeepEquals(t, "entries should have foo and not bar", []string{"components/foo", "etc/linker.config.pb"}, module.entries) |
Jooyung Han | 0fbbc2b | 2022-03-25 12:35:46 +0900 | [diff] [blame] | 229 | } |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 230 | |
Alice Wang | 000e3a3 | 2023-01-03 16:11:20 +0000 | [diff] [blame] | 231 | func TestAvbGenVbmetaImage(t *testing.T) { |
| 232 | result := fixture.RunTestWithBp(t, ` |
| 233 | avb_gen_vbmeta_image { |
| 234 | name: "input_hashdesc", |
| 235 | src: "input.img", |
| 236 | partition_name: "input_partition_name", |
| 237 | salt: "2222", |
| 238 | }`) |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 239 | cmd := result.ModuleForTests(t, "input_hashdesc", "android_arm64_armv8-a").Rule("avbGenVbmetaImage").RuleParams.Command |
Alice Wang | 000e3a3 | 2023-01-03 16:11:20 +0000 | [diff] [blame] | 240 | android.AssertStringDoesContain(t, "Can't find correct --partition_name argument", |
| 241 | cmd, "--partition_name input_partition_name") |
| 242 | android.AssertStringDoesContain(t, "Can't find --do_not_append_vbmeta_image", |
| 243 | cmd, "--do_not_append_vbmeta_image") |
| 244 | android.AssertStringDoesContain(t, "Can't find --output_vbmeta_image", |
| 245 | cmd, "--output_vbmeta_image ") |
| 246 | android.AssertStringDoesContain(t, "Can't find --salt argument", |
| 247 | cmd, "--salt 2222") |
| 248 | } |
| 249 | |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 250 | func TestAvbAddHashFooter(t *testing.T) { |
| 251 | result := fixture.RunTestWithBp(t, ` |
Alice Wang | 000e3a3 | 2023-01-03 16:11:20 +0000 | [diff] [blame] | 252 | avb_gen_vbmeta_image { |
| 253 | name: "input_hashdesc", |
| 254 | src: "input.img", |
| 255 | partition_name: "input", |
| 256 | salt: "2222", |
| 257 | } |
| 258 | |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 259 | avb_add_hash_footer { |
| 260 | name: "myfooter", |
| 261 | src: "input.img", |
| 262 | filename: "output.img", |
| 263 | partition_name: "mypartition", |
| 264 | private_key: "mykey", |
| 265 | salt: "1111", |
| 266 | props: [ |
| 267 | { |
| 268 | name: "prop1", |
| 269 | value: "value1", |
| 270 | }, |
| 271 | { |
| 272 | name: "prop2", |
| 273 | file: "value_file", |
| 274 | }, |
| 275 | ], |
Alice Wang | 000e3a3 | 2023-01-03 16:11:20 +0000 | [diff] [blame] | 276 | include_descriptors_from_images: ["input_hashdesc"], |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 277 | } |
| 278 | `) |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 279 | cmd := result.ModuleForTests(t, "myfooter", "android_arm64_armv8-a").Rule("avbAddHashFooter").RuleParams.Command |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 280 | android.AssertStringDoesContain(t, "Can't find correct --partition_name argument", |
| 281 | cmd, "--partition_name mypartition") |
| 282 | android.AssertStringDoesContain(t, "Can't find correct --key argument", |
| 283 | cmd, "--key mykey") |
| 284 | android.AssertStringDoesContain(t, "Can't find --salt argument", |
| 285 | cmd, "--salt 1111") |
| 286 | android.AssertStringDoesContain(t, "Can't find --prop argument", |
| 287 | cmd, "--prop 'prop1:value1'") |
| 288 | android.AssertStringDoesContain(t, "Can't find --prop_from_file argument", |
| 289 | cmd, "--prop_from_file 'prop2:value_file'") |
Alice Wang | 000e3a3 | 2023-01-03 16:11:20 +0000 | [diff] [blame] | 290 | android.AssertStringDoesContain(t, "Can't find --include_descriptors_from_image", |
| 291 | cmd, "--include_descriptors_from_image ") |
Jiyong Park | bc48548 | 2022-11-15 22:31:49 +0900 | [diff] [blame] | 292 | } |
Jooyung Han | 54f7805 | 2023-02-20 18:17:47 +0900 | [diff] [blame] | 293 | |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 294 | func TestFileSystemWithCoverageVariants(t *testing.T) { |
| 295 | context := android.GroupFixturePreparers( |
| 296 | fixture, |
| 297 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 298 | variables.GcovCoverage = proptools.BoolPtr(true) |
| 299 | variables.Native_coverage = proptools.BoolPtr(true) |
| 300 | }), |
| 301 | ) |
| 302 | |
| 303 | result := context.RunTestWithBp(t, ` |
| 304 | prebuilt_etc { |
| 305 | name: "prebuilt", |
| 306 | src: ":myfilesystem", |
| 307 | } |
| 308 | |
| 309 | android_system_image { |
| 310 | name: "myfilesystem", |
| 311 | deps: [ |
| 312 | "libfoo", |
| 313 | ], |
Spandan Das | 2047a4c | 2024-11-11 21:24:58 +0000 | [diff] [blame] | 314 | linker_config: { |
Kiyoung Kim | 6711821 | 2024-11-07 13:23:44 +0900 | [diff] [blame] | 315 | gen_linker_config: true, |
| 316 | linker_config_srcs: ["linker.config.json"], |
| 317 | }, |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | cc_library { |
| 321 | name: "libfoo", |
| 322 | shared_libs: [ |
| 323 | "libbar", |
| 324 | ], |
| 325 | stl: "none", |
| 326 | } |
| 327 | |
| 328 | cc_library { |
| 329 | name: "libbar", |
| 330 | stl: "none", |
| 331 | } |
| 332 | `) |
| 333 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 334 | filesystem := result.ModuleForTests(t, "myfilesystem", "android_common_cov") |
Spandan Das | 5ef1a9c | 2025-02-11 18:50:17 +0000 | [diff] [blame] | 335 | inputs := filesystem.Output("staging_dir.timestamp").Implicits |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 336 | android.AssertStringListContains(t, "filesystem should have libfoo(cov)", |
| 337 | inputs.Strings(), |
| 338 | "out/soong/.intermediates/libfoo/android_arm64_armv8-a_shared_cov/libfoo.so") |
| 339 | android.AssertStringListContains(t, "filesystem should have libbar(cov)", |
| 340 | inputs.Strings(), |
| 341 | "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared_cov/libbar.so") |
| 342 | |
Spandan Das | 1f0a5a1 | 2025-01-15 00:53:15 +0000 | [diff] [blame] | 343 | filesystemOutput := filesystem.OutputFiles(result.TestContext, t, "")[0] |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 344 | prebuiltInput := result.ModuleForTests(t, "prebuilt", "android_arm64_armv8-a").Rule("Cp").Input |
Jooyung Han | e606759 | 2023-03-16 13:11:17 +0900 | [diff] [blame] | 345 | if filesystemOutput != prebuiltInput { |
| 346 | t.Error("prebuilt should use cov variant of filesystem") |
| 347 | } |
| 348 | } |
Jiyong Park | eaac823 | 2024-03-31 21:27:45 +0900 | [diff] [blame] | 349 | |
| 350 | func TestSystemImageDefaults(t *testing.T) { |
| 351 | result := fixture.RunTestWithBp(t, ` |
Jiyong Park | f46b1af | 2024-04-05 18:13:33 +0900 | [diff] [blame] | 352 | android_filesystem_defaults { |
Jiyong Park | eaac823 | 2024-03-31 21:27:45 +0900 | [diff] [blame] | 353 | name: "defaults", |
| 354 | multilib: { |
| 355 | common: { |
| 356 | deps: [ |
| 357 | "phony", |
| 358 | ], |
| 359 | }, |
| 360 | lib64: { |
| 361 | deps: [ |
| 362 | "libbar", |
| 363 | ], |
| 364 | }, |
| 365 | }, |
| 366 | compile_multilib: "both", |
| 367 | } |
| 368 | |
| 369 | android_system_image { |
| 370 | name: "system", |
| 371 | defaults: ["defaults"], |
| 372 | multilib: { |
| 373 | lib32: { |
| 374 | deps: [ |
| 375 | "foo", |
| 376 | "libbar", |
| 377 | ], |
| 378 | }, |
| 379 | }, |
| 380 | } |
| 381 | |
| 382 | cc_binary { |
| 383 | name: "foo", |
| 384 | compile_multilib: "prefer32", |
| 385 | } |
| 386 | |
| 387 | cc_library { |
| 388 | name: "libbar", |
| 389 | required: ["libbaz"], |
| 390 | } |
| 391 | |
| 392 | cc_library { |
| 393 | name: "libbaz", |
| 394 | } |
| 395 | |
| 396 | phony { |
| 397 | name: "phony", |
| 398 | required: ["libquz"], |
| 399 | } |
| 400 | |
| 401 | cc_library { |
| 402 | name: "libquz", |
| 403 | } |
| 404 | `) |
| 405 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 406 | fs := result.ModuleForTests(t, "system", "android_common").Module().(*systemImage) |
Jiyong Park | eaac823 | 2024-03-31 21:27:45 +0900 | [diff] [blame] | 407 | expected := []string{ |
| 408 | "bin/foo", |
| 409 | "lib/libbar.so", |
| 410 | "lib64/libbar.so", |
| 411 | "lib64/libbaz.so", |
| 412 | "lib64/libquz.so", |
| 413 | } |
| 414 | for _, e := range expected { |
| 415 | android.AssertStringListContains(t, "missing entry", fs.entries, e) |
| 416 | } |
| 417 | } |
Jiyong Park | f46b1af | 2024-04-05 18:13:33 +0900 | [diff] [blame] | 418 | |
| 419 | func TestInconsistentPartitionTypesInDefaults(t *testing.T) { |
| 420 | fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( |
| 421 | "doesn't match with the partition type")). |
| 422 | RunTestWithBp(t, ` |
| 423 | android_filesystem_defaults { |
| 424 | name: "system_ext_def", |
| 425 | partition_type: "system_ext", |
| 426 | } |
| 427 | |
| 428 | android_filesystem_defaults { |
| 429 | name: "system_def", |
| 430 | partition_type: "system", |
| 431 | defaults: ["system_ext_def"], |
| 432 | } |
| 433 | |
| 434 | android_system_image { |
| 435 | name: "system", |
| 436 | defaults: ["system_def"], |
| 437 | } |
| 438 | `) |
| 439 | } |
Jiyong Park | 16ef7ac | 2024-05-01 12:36:10 +0000 | [diff] [blame] | 440 | |
| 441 | func TestPreventDuplicatedEntries(t *testing.T) { |
| 442 | fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( |
| 443 | "packaging conflict at")). |
| 444 | RunTestWithBp(t, ` |
| 445 | android_filesystem { |
| 446 | name: "fs", |
| 447 | deps: [ |
| 448 | "foo", |
| 449 | "foo_dup", |
| 450 | ], |
| 451 | } |
| 452 | |
| 453 | cc_binary { |
| 454 | name: "foo", |
| 455 | } |
| 456 | |
| 457 | cc_binary { |
| 458 | name: "foo_dup", |
| 459 | stem: "foo", |
| 460 | } |
| 461 | `) |
| 462 | } |
Jiyong Park | c4b1d55 | 2024-05-13 16:47:30 +0900 | [diff] [blame] | 463 | |
| 464 | func TestTrackPhonyAsRequiredDep(t *testing.T) { |
| 465 | result := fixture.RunTestWithBp(t, ` |
| 466 | android_filesystem { |
| 467 | name: "fs", |
| 468 | deps: ["foo"], |
| 469 | } |
| 470 | |
| 471 | cc_binary { |
| 472 | name: "foo", |
| 473 | required: ["phony"], |
| 474 | } |
| 475 | |
| 476 | phony { |
| 477 | name: "phony", |
| 478 | required: ["libbar"], |
| 479 | } |
| 480 | |
| 481 | cc_library { |
| 482 | name: "libbar", |
| 483 | } |
| 484 | `) |
| 485 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 486 | fs := result.ModuleForTests(t, "fs", "android_common").Module().(*filesystem) |
Jiyong Park | c4b1d55 | 2024-05-13 16:47:30 +0900 | [diff] [blame] | 487 | expected := []string{ |
| 488 | "bin/foo", |
| 489 | "lib64/libbar.so", |
| 490 | } |
| 491 | for _, e := range expected { |
| 492 | android.AssertStringListContains(t, "missing entry", fs.entries, e) |
| 493 | } |
| 494 | } |
Jiyong Park | c6a773d | 2024-05-14 21:49:11 +0900 | [diff] [blame] | 495 | |
| 496 | func TestFilterOutUnsupportedArches(t *testing.T) { |
| 497 | result := fixture.RunTestWithBp(t, ` |
| 498 | android_filesystem { |
| 499 | name: "fs_64_only", |
| 500 | deps: ["foo"], |
| 501 | } |
| 502 | |
| 503 | android_filesystem { |
| 504 | name: "fs_64_32", |
| 505 | compile_multilib: "both", |
Jiyong Park | 3ea9b65 | 2024-05-15 23:01:54 +0900 | [diff] [blame] | 506 | deps: ["foo"], |
Jiyong Park | c6a773d | 2024-05-14 21:49:11 +0900 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | cc_binary { |
| 510 | name: "foo", |
| 511 | required: ["phony"], |
| 512 | } |
| 513 | |
| 514 | phony { |
| 515 | name: "phony", |
| 516 | required: [ |
| 517 | "libbar", |
| 518 | "app", |
| 519 | ], |
| 520 | } |
| 521 | |
| 522 | cc_library { |
| 523 | name: "libbar", |
| 524 | } |
| 525 | |
| 526 | android_app { |
| 527 | name: "app", |
| 528 | srcs: ["a.java"], |
| 529 | platform_apis: true, |
| 530 | } |
| 531 | `) |
| 532 | testcases := []struct { |
| 533 | fsName string |
| 534 | expected []string |
| 535 | unexpected []string |
| 536 | }{ |
| 537 | { |
| 538 | fsName: "fs_64_only", |
| 539 | expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so"}, |
| 540 | unexpected: []string{"lib/libbar.so"}, |
| 541 | }, |
| 542 | { |
| 543 | fsName: "fs_64_32", |
| 544 | expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so", "lib/libbar.so"}, |
| 545 | unexpected: []string{}, |
| 546 | }, |
| 547 | } |
| 548 | for _, c := range testcases { |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 549 | fs := result.ModuleForTests(t, c.fsName, "android_common").Module().(*filesystem) |
Jiyong Park | c6a773d | 2024-05-14 21:49:11 +0900 | [diff] [blame] | 550 | for _, e := range c.expected { |
| 551 | android.AssertStringListContains(t, "missing entry", fs.entries, e) |
| 552 | } |
| 553 | for _, e := range c.unexpected { |
| 554 | android.AssertStringListDoesNotContain(t, "unexpected entry", fs.entries, e) |
| 555 | } |
| 556 | } |
| 557 | } |
Spandan Das | c35d6fb | 2024-10-10 17:51:14 +0000 | [diff] [blame] | 558 | |
| 559 | func TestErofsPartition(t *testing.T) { |
| 560 | result := fixture.RunTestWithBp(t, ` |
| 561 | android_filesystem { |
| 562 | name: "erofs_partition", |
| 563 | type: "erofs", |
| 564 | erofs: { |
| 565 | compressor: "lz4hc,9", |
| 566 | compress_hints: "compress_hints.txt", |
| 567 | }, |
| 568 | deps: ["binfoo"], |
| 569 | } |
| 570 | |
| 571 | cc_binary { |
| 572 | name: "binfoo", |
| 573 | } |
| 574 | `) |
| 575 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 576 | partition := result.ModuleForTests(t, "erofs_partition", "android_common") |
Cole Faust | e167612 | 2024-12-03 17:32:25 -0800 | [diff] [blame] | 577 | buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop_pre_processing")) |
Spandan Das | c35d6fb | 2024-10-10 17:51:14 +0000 | [diff] [blame] | 578 | android.AssertStringDoesContain(t, "erofs fs type", buildImageConfig, "fs_type=erofs") |
| 579 | android.AssertStringDoesContain(t, "erofs fs type compress algorithm", buildImageConfig, "erofs_default_compressor=lz4hc,9") |
| 580 | android.AssertStringDoesContain(t, "erofs fs type compress hint", buildImageConfig, "erofs_default_compress_hints=compress_hints.txt") |
| 581 | android.AssertStringDoesContain(t, "erofs fs type sparse", buildImageConfig, "erofs_sparse_flag=-s") |
| 582 | } |
Hugo Drumond Jacob | 69d829a | 2024-10-21 09:55:45 +0000 | [diff] [blame] | 583 | |
mrziwang | 1a6291f | 2024-11-07 14:29:25 -0800 | [diff] [blame] | 584 | func TestF2fsPartition(t *testing.T) { |
| 585 | result := fixture.RunTestWithBp(t, ` |
| 586 | android_filesystem { |
| 587 | name: "f2fs_partition", |
| 588 | type: "f2fs", |
| 589 | } |
| 590 | `) |
| 591 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 592 | partition := result.ModuleForTests(t, "f2fs_partition", "android_common") |
Cole Faust | e167612 | 2024-12-03 17:32:25 -0800 | [diff] [blame] | 593 | buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop_pre_processing")) |
mrziwang | 1a6291f | 2024-11-07 14:29:25 -0800 | [diff] [blame] | 594 | android.AssertStringDoesContain(t, "f2fs fs type", buildImageConfig, "fs_type=f2fs") |
| 595 | android.AssertStringDoesContain(t, "f2fs fs type sparse", buildImageConfig, "f2fs_sparse_flag=-S") |
| 596 | } |
| 597 | |
| 598 | func TestFsTypesPropertyError(t *testing.T) { |
| 599 | fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( |
| 600 | "erofs: erofs is non-empty, but FS type is f2fs\n. Please delete erofs properties if this partition should use f2fs\n")). |
| 601 | RunTestWithBp(t, ` |
| 602 | android_filesystem { |
| 603 | name: "f2fs_partition", |
| 604 | type: "f2fs", |
| 605 | erofs: { |
| 606 | compressor: "lz4hc,9", |
| 607 | compress_hints: "compress_hints.txt", |
| 608 | }, |
| 609 | } |
| 610 | `) |
| 611 | } |
| 612 | |
Hugo Drumond Jacob | 69d829a | 2024-10-21 09:55:45 +0000 | [diff] [blame] | 613 | // If a system_ext/ module depends on system/ module, the dependency should *not* |
| 614 | // be installed in system_ext/ |
| 615 | func TestDoNotPackageCrossPartitionDependencies(t *testing.T) { |
Spandan Das | 6d05650 | 2024-10-21 15:40:32 +0000 | [diff] [blame] | 616 | t.Skip() // TODO (spandandas): Re-enable this |
Hugo Drumond Jacob | 69d829a | 2024-10-21 09:55:45 +0000 | [diff] [blame] | 617 | result := fixture.RunTestWithBp(t, ` |
| 618 | android_filesystem { |
| 619 | name: "myfilesystem", |
| 620 | deps: ["binfoo"], |
| 621 | partition_type: "system_ext", |
| 622 | } |
| 623 | |
| 624 | cc_binary { |
| 625 | name: "binfoo", |
| 626 | shared_libs: ["libfoo"], |
| 627 | system_ext_specific: true, |
| 628 | } |
| 629 | cc_library_shared { |
| 630 | name: "libfoo", // installed in system/ |
| 631 | } |
| 632 | `) |
| 633 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 634 | partition := result.ModuleForTests(t, "myfilesystem", "android_common") |
Hugo Drumond Jacob | 69d829a | 2024-10-21 09:55:45 +0000 | [diff] [blame] | 635 | fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) |
| 636 | android.AssertDeepEquals(t, "filesystem with dependencies on different partition", "bin/binfoo\n", fileList) |
| 637 | } |
Spandan Das | 405f2d4 | 2024-10-22 18:31:25 +0000 | [diff] [blame] | 638 | |
| 639 | // If a cc_library is listed in `deps`, and it has a shared and static variant, then the shared variant |
| 640 | // should be installed. |
| 641 | func TestUseSharedVariationOfNativeLib(t *testing.T) { |
| 642 | result := fixture.RunTestWithBp(t, ` |
| 643 | android_filesystem { |
| 644 | name: "myfilesystem", |
| 645 | deps: ["libfoo"], |
| 646 | } |
| 647 | // cc_library will create a static and shared variant. |
| 648 | cc_library { |
| 649 | name: "libfoo", |
| 650 | } |
| 651 | `) |
| 652 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 653 | partition := result.ModuleForTests(t, "myfilesystem", "android_common") |
Spandan Das | 405f2d4 | 2024-10-22 18:31:25 +0000 | [diff] [blame] | 654 | fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) |
Colin Cross | 386afeb | 2024-11-13 15:20:13 -0800 | [diff] [blame] | 655 | android.AssertDeepEquals(t, "cc_library listed in deps", |
| 656 | "lib64/bootstrap/libc.so\nlib64/bootstrap/libdl.so\nlib64/bootstrap/libm.so\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n", |
| 657 | fileList) |
Spandan Das | 405f2d4 | 2024-10-22 18:31:25 +0000 | [diff] [blame] | 658 | } |
Spandan Das | 6c2b01d | 2024-10-22 22:16:04 +0000 | [diff] [blame] | 659 | |
| 660 | // binfoo1 overrides binbar. transitive deps of binbar should not be installed. |
| 661 | func TestDoNotInstallTransitiveDepOfOverriddenModule(t *testing.T) { |
| 662 | result := fixture.RunTestWithBp(t, ` |
| 663 | android_filesystem { |
| 664 | name: "myfilesystem", |
| 665 | deps: ["binfoo1", "libfoo2", "binbar"], |
| 666 | } |
| 667 | cc_binary { |
| 668 | name: "binfoo1", |
| 669 | shared_libs: ["libfoo"], |
| 670 | overrides: ["binbar"], |
| 671 | } |
| 672 | cc_library { |
| 673 | name: "libfoo", |
| 674 | } |
| 675 | cc_library { |
| 676 | name: "libfoo2", |
| 677 | overrides: ["libfoo"], |
| 678 | } |
| 679 | // binbar gets overridden by binfoo1 |
| 680 | // therefore, libbar should not be installed |
| 681 | cc_binary { |
| 682 | name: "binbar", |
| 683 | shared_libs: ["libbar"] |
| 684 | } |
| 685 | cc_library { |
| 686 | name: "libbar", |
| 687 | } |
| 688 | `) |
| 689 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 690 | partition := result.ModuleForTests(t, "myfilesystem", "android_common") |
Spandan Das | 6c2b01d | 2024-10-22 22:16:04 +0000 | [diff] [blame] | 691 | fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) |
Colin Cross | 386afeb | 2024-11-13 15:20:13 -0800 | [diff] [blame] | 692 | android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed", |
| 693 | "bin/binfoo1\nlib64/bootstrap/libc.so\nlib64/bootstrap/libdl.so\nlib64/bootstrap/libm.so\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n", |
| 694 | fileList) |
Spandan Das | 6c2b01d | 2024-10-22 22:16:04 +0000 | [diff] [blame] | 695 | } |
Spandan Das | 9263188 | 2024-10-28 22:49:38 +0000 | [diff] [blame] | 696 | |
| 697 | func TestInstallLinkerConfigFile(t *testing.T) { |
| 698 | result := fixture.RunTestWithBp(t, ` |
| 699 | android_filesystem { |
| 700 | name: "myfilesystem", |
| 701 | deps: ["libfoo_has_no_stubs", "libfoo_has_stubs"], |
Spandan Das | 2047a4c | 2024-11-11 21:24:58 +0000 | [diff] [blame] | 702 | linker_config: { |
Kiyoung Kim | 6711821 | 2024-11-07 13:23:44 +0900 | [diff] [blame] | 703 | gen_linker_config: true, |
| 704 | linker_config_srcs: ["linker.config.json"], |
Spandan Das | 173256b | 2024-10-31 19:59:30 +0000 | [diff] [blame] | 705 | }, |
Spandan Das | 918191e | 2024-10-31 18:27:23 +0000 | [diff] [blame] | 706 | partition_type: "vendor", |
Spandan Das | 9263188 | 2024-10-28 22:49:38 +0000 | [diff] [blame] | 707 | } |
| 708 | cc_library { |
| 709 | name: "libfoo_has_no_stubs", |
Spandan Das | 918191e | 2024-10-31 18:27:23 +0000 | [diff] [blame] | 710 | vendor: true, |
Spandan Das | 9263188 | 2024-10-28 22:49:38 +0000 | [diff] [blame] | 711 | } |
| 712 | cc_library { |
| 713 | name: "libfoo_has_stubs", |
| 714 | stubs: {symbol_file: "libfoo.map.txt"}, |
Spandan Das | 918191e | 2024-10-31 18:27:23 +0000 | [diff] [blame] | 715 | vendor: true, |
Spandan Das | 9263188 | 2024-10-28 22:49:38 +0000 | [diff] [blame] | 716 | } |
| 717 | `) |
| 718 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 719 | linkerConfigCmd := result.ModuleForTests(t, "myfilesystem", "android_common").Output("out/soong/.intermediates/myfilesystem/android_common/linker.config.pb").RuleParams.Command |
Spandan Das | 918191e | 2024-10-31 18:27:23 +0000 | [diff] [blame] | 720 | android.AssertStringDoesContain(t, "Could not find linker.config.json file in cmd", linkerConfigCmd, "conv_linker_config proto --force -s linker.config.json") |
| 721 | android.AssertStringDoesContain(t, "Could not find stub in `provideLibs`", linkerConfigCmd, "--key provideLibs --value libfoo_has_stubs.so") |
Spandan Das | 9263188 | 2024-10-28 22:49:38 +0000 | [diff] [blame] | 722 | } |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 723 | |
| 724 | // override_android_* modules implicitly override their base module. |
| 725 | // If both of these are listed in `deps`, the base module should not be installed. |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 726 | // Also, required deps should be updated too. |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 727 | func TestOverrideModulesInDeps(t *testing.T) { |
| 728 | result := fixture.RunTestWithBp(t, ` |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 729 | cc_library_shared { |
| 730 | name: "libfoo", |
| 731 | stl: "none", |
| 732 | system_shared_libs: [], |
| 733 | } |
| 734 | cc_library_shared { |
| 735 | name: "libbar", |
| 736 | stl: "none", |
| 737 | system_shared_libs: [], |
| 738 | } |
Inseob Kim | 7615049 | 2025-03-20 10:46:06 +0900 | [diff] [blame] | 739 | phony { |
| 740 | name: "myapp_phony", |
| 741 | required: ["myapp"], |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 742 | } |
Inseob Kim | 7615049 | 2025-03-20 10:46:06 +0900 | [diff] [blame] | 743 | phony { |
| 744 | name: "myoverrideapp_phony", |
| 745 | required: ["myoverrideapp"], |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 746 | } |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 747 | android_app { |
| 748 | name: "myapp", |
| 749 | platform_apis: true, |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 750 | required: ["libfoo"], |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 751 | } |
| 752 | override_android_app { |
| 753 | name: "myoverrideapp", |
| 754 | base: "myapp", |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 755 | required: ["libbar"], |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 756 | } |
Inseob Kim | 7615049 | 2025-03-20 10:46:06 +0900 | [diff] [blame] | 757 | android_filesystem { |
| 758 | name: "myfilesystem", |
| 759 | deps: ["myapp"], |
| 760 | } |
| 761 | android_filesystem { |
| 762 | name: "myfilesystem_overridden", |
| 763 | deps: ["myapp", "myoverrideapp"], |
| 764 | } |
| 765 | android_filesystem { |
| 766 | name: "myfilesystem_overridden_indirect", |
| 767 | deps: ["myapp_phony", "myoverrideapp_phony"], |
| 768 | } |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 769 | `) |
| 770 | |
Colin Cross | 90607e9 | 2025-02-11 14:58:07 -0800 | [diff] [blame] | 771 | partition := result.ModuleForTests(t, "myfilesystem", "android_common") |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 772 | fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList")) |
Inseob Kim | 0c67c8e | 2025-03-14 18:33:55 +0900 | [diff] [blame] | 773 | android.AssertStringEquals(t, "filesystem without override app", "app/myapp/myapp.apk\nlib64/libfoo.so\n", fileList) |
| 774 | |
Inseob Kim | 7615049 | 2025-03-20 10:46:06 +0900 | [diff] [blame] | 775 | for _, overridden := range []string{"myfilesystem_overridden", "myfilesystem_overridden_indirect"} { |
| 776 | overriddenPartition := result.ModuleForTests(t, overridden, "android_common") |
| 777 | overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList")) |
| 778 | android.AssertStringEquals(t, "filesystem with "+overridden, "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList) |
| 779 | } |
Spandan Das | c1ded7e | 2024-11-01 00:52:33 +0000 | [diff] [blame] | 780 | } |
Jihoon Kang | 6c03c8e | 2024-11-18 21:30:22 +0000 | [diff] [blame] | 781 | |
| 782 | func TestRamdiskPartitionSetsDevNodes(t *testing.T) { |
| 783 | result := android.GroupFixturePreparers( |
| 784 | fixture, |
| 785 | android.FixtureMergeMockFs(android.MockFS{ |
| 786 | "ramdisk_node_list": nil, |
| 787 | }), |
| 788 | ).RunTestWithBp(t, ` |
| 789 | android_filesystem { |
| 790 | name: "ramdisk_filesystem", |
| 791 | partition_name: "ramdisk", |
| 792 | } |
| 793 | filegroup { |
| 794 | name: "ramdisk_node_list", |
| 795 | srcs: ["ramdisk_node_list"], |
| 796 | } |
| 797 | `) |
| 798 | |
| 799 | android.AssertBoolEquals( |
| 800 | t, |
| 801 | "Generated ramdisk image expected to depend on \"ramdisk_node_list\" module", |
| 802 | true, |
| 803 | java.CheckModuleHasDependency(t, result.TestContext, "ramdisk_filesystem", "android_common", "ramdisk_node_list"), |
| 804 | ) |
| 805 | } |