blob: 8fe5daca06269abe6f3c376196e082d3766f37df [file] [log] [blame]
Jooyung Han9706cbc2021-04-15 22:43:48 +09001// 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
15package filesystem
16
17import (
18 "os"
19 "testing"
20
21 "android/soong/android"
Jiyong Park06c4cdc2024-02-16 15:35:03 +090022 "android/soong/bpf"
Jiyong Parkfa616132021-04-20 11:36:40 +090023 "android/soong/cc"
Jooyung Hane6067592023-03-16 13:11:17 +090024 "android/soong/etc"
Jiyong Park73e5bab2024-04-05 13:37:21 +090025 "android/soong/java"
Jiyong Park9c540c82024-03-26 10:48:27 +090026 "android/soong/phony"
Jooyung Hane6067592023-03-16 13:11:17 +090027
28 "github.com/google/blueprint/proptools"
Jooyung Han9706cbc2021-04-15 22:43:48 +090029)
30
31func TestMain(m *testing.M) {
32 os.Exit(m.Run())
33}
34
35var fixture = android.GroupFixturePreparers(
36 android.PrepareForIntegrationTestWithAndroid,
Jiyong Park73e5bab2024-04-05 13:37:21 +090037 android.PrepareForTestWithAndroidBuildComponents,
Jiyong Park06c4cdc2024-02-16 15:35:03 +090038 bpf.PrepareForTestWithBpf,
Jiyong Parkfa616132021-04-20 11:36:40 +090039 cc.PrepareForIntegrationTestWithCc,
Jiyong Park73e5bab2024-04-05 13:37:21 +090040 etc.PrepareForTestWithPrebuiltEtc,
41 java.PrepareForTestWithJavaBuildComponents,
42 java.PrepareForTestWithJavaDefaultModules,
Jiyong Park9c540c82024-03-26 10:48:27 +090043 phony.PrepareForTestWithPhony,
Jooyung Han9706cbc2021-04-15 22:43:48 +090044 PrepareForTestWithFilesystemBuildComponents,
45)
46
47func TestFileSystemDeps(t *testing.T) {
48 result := fixture.RunTestWithBp(t, `
49 android_filesystem {
50 name: "myfilesystem",
Jiyong Park06c4cdc2024-02-16 15:35:03 +090051 multilib: {
52 common: {
53 deps: [
54 "bpf.o",
Jiyong Park9c540c82024-03-26 10:48:27 +090055 "phony",
Jiyong Park06c4cdc2024-02-16 15:35:03 +090056 ],
57 },
Jiyong Parkeec7c382024-02-16 16:10:13 +090058 lib32: {
59 deps: [
60 "foo",
61 "libbar",
62 ],
63 },
64 lib64: {
65 deps: [
66 "libbar",
67 ],
68 },
Jiyong Park06c4cdc2024-02-16 15:35:03 +090069 },
Jiyong Parkeec7c382024-02-16 16:10:13 +090070 compile_multilib: "both",
Jiyong Park06c4cdc2024-02-16 15:35:03 +090071 }
72
73 bpf {
74 name: "bpf.o",
75 srcs: ["bpf.c"],
Jooyung Han9706cbc2021-04-15 22:43:48 +090076 }
Jiyong Parkeec7c382024-02-16 16:10:13 +090077
78 cc_binary {
79 name: "foo",
80 compile_multilib: "prefer32",
81 }
82
83 cc_library {
84 name: "libbar",
Jiyong Park8bcf3c62024-03-18 18:37:10 +090085 required: ["libbaz"],
Jiyong Parkf21dd652024-04-17 05:22:37 +000086 target: {
87 platform: {
88 required: ["lib_platform_only"],
89 },
90 },
Jiyong Park8bcf3c62024-03-18 18:37:10 +090091 }
92
93 cc_library {
94 name: "libbaz",
Jiyong Parkeec7c382024-02-16 16:10:13 +090095 }
Jiyong Park9c540c82024-03-26 10:48:27 +090096
Jiyong Parkf21dd652024-04-17 05:22:37 +000097 cc_library {
98 name: "lib_platform_only",
99 }
100
Jiyong Park9c540c82024-03-26 10:48:27 +0900101 phony {
102 name: "phony",
Jiyong Park73e5bab2024-04-05 13:37:21 +0900103 required: [
104 "libquz",
105 "myapp",
106 ],
Jiyong Park9c540c82024-03-26 10:48:27 +0900107 }
108
109 cc_library {
110 name: "libquz",
111 }
Jiyong Park73e5bab2024-04-05 13:37:21 +0900112
113 android_app {
114 name: "myapp",
115 platform_apis: true,
116 installable: true,
117 }
Jooyung Han9706cbc2021-04-15 22:43:48 +0900118 `)
119
120 // produces "myfilesystem.img"
121 result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img")
Jiyong Park06c4cdc2024-02-16 15:35:03 +0900122
123 fs := result.ModuleForTests("myfilesystem", "android_common").Module().(*filesystem)
Jiyong Parkeec7c382024-02-16 16:10:13 +0900124 expected := []string{
Jiyong Park73e5bab2024-04-05 13:37:21 +0900125 "app/myapp/myapp.apk",
Jiyong Parkeec7c382024-02-16 16:10:13 +0900126 "bin/foo",
127 "lib/libbar.so",
128 "lib64/libbar.so",
Jiyong Park8bcf3c62024-03-18 18:37:10 +0900129 "lib64/libbaz.so",
Jiyong Park9c540c82024-03-26 10:48:27 +0900130 "lib64/libquz.so",
Jiyong Parkf21dd652024-04-17 05:22:37 +0000131 "lib64/lib_platform_only.so",
Jiyong Parkeec7c382024-02-16 16:10:13 +0900132 "etc/bpf/bpf.o",
133 }
Jiyong Park06c4cdc2024-02-16 15:35:03 +0900134 for _, e := range expected {
135 android.AssertStringListContains(t, "missing entry", fs.entries, e)
136 }
Jooyung Han9706cbc2021-04-15 22:43:48 +0900137}
Jiyong Parkfa616132021-04-20 11:36:40 +0900138
Cole Faust4a2a7c92024-03-12 12:44:40 -0700139func TestIncludeMakeBuiltFiles(t *testing.T) {
140 result := fixture.RunTestWithBp(t, `
141 android_filesystem {
142 name: "myfilesystem",
143 include_make_built_files: "system",
144 }
145 `)
146
147 output := result.ModuleForTests("myfilesystem", "android_common").Output("myfilesystem.img")
148
Colin Cross3b1c6842024-07-26 11:52:57 -0700149 stampFile := "out/target/product/test_device/obj/PACKAGING/system_intermediates/staging_dir.stamp"
150 fileListFile := "out/target/product/test_device/obj/PACKAGING/system_intermediates/file_list.txt"
Cole Faust4a2a7c92024-03-12 12:44:40 -0700151 android.AssertStringListContains(t, "deps of filesystem must include the staging dir stamp file", output.Implicits.Strings(), stampFile)
152 android.AssertStringListContains(t, "deps of filesystem must include the staging dir file list", output.Implicits.Strings(), fileListFile)
153}
154
Jiyong Parkfa616132021-04-20 11:36:40 +0900155func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) {
156 result := fixture.RunTestWithBp(t, `
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900157 android_system_image {
Jiyong Parkfa616132021-04-20 11:36:40 +0900158 name: "myfilesystem",
159 deps: [
160 "libfoo",
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900161 "libbar",
Jiyong Parkfa616132021-04-20 11:36:40 +0900162 ],
163 linker_config_src: "linker.config.json",
164 }
165
166 cc_library {
167 name: "libfoo",
168 stubs: {
169 symbol_file: "libfoo.map.txt",
170 },
171 }
172
173 cc_library {
174 name: "libbar",
175 }
176 `)
177
178 module := result.ModuleForTests("myfilesystem", "android_common")
179 output := module.Output("system/etc/linker.config.pb")
180
181 android.AssertStringDoesContain(t, "linker.config.pb should have libfoo",
182 output.RuleParams.Command, "libfoo.so")
183 android.AssertStringDoesNotContain(t, "linker.config.pb should not have libbar",
184 output.RuleParams.Command, "libbar.so")
185}
Jooyung Han0fbbc2b2022-03-25 12:35:46 +0900186
187func registerComponent(ctx android.RegistrationContext) {
188 ctx.RegisterModuleType("component", componentFactory)
189}
190
191func componentFactory() android.Module {
192 m := &component{}
193 m.AddProperties(&m.properties)
194 android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
195 return m
196}
197
198type component struct {
199 android.ModuleBase
200 properties struct {
201 Install_copy_in_data []string
202 }
203}
204
205func (c *component) GenerateAndroidBuildActions(ctx android.ModuleContext) {
206 output := android.PathForModuleOut(ctx, c.Name())
207 dir := android.PathForModuleInstall(ctx, "components")
208 ctx.InstallFile(dir, c.Name(), output)
209
210 dataDir := android.PathForModuleInPartitionInstall(ctx, "data", "components")
211 for _, d := range c.properties.Install_copy_in_data {
212 ctx.InstallFile(dataDir, d, output)
213 }
214}
215
216func TestFileSystemGathersItemsOnlyInSystemPartition(t *testing.T) {
217 f := android.GroupFixturePreparers(fixture, android.FixtureRegisterWithContext(registerComponent))
218 result := f.RunTestWithBp(t, `
219 android_system_image {
220 name: "myfilesystem",
221 multilib: {
222 common: {
223 deps: ["foo"],
224 },
225 },
226 linker_config_src: "linker.config.json",
227 }
228 component {
229 name: "foo",
230 install_copy_in_data: ["bar"],
231 }
232 `)
233
234 module := result.ModuleForTests("myfilesystem", "android_common").Module().(*systemImage)
235 android.AssertDeepEquals(t, "entries should have foo only", []string{"components/foo"}, module.entries)
236}
Jiyong Parkbc485482022-11-15 22:31:49 +0900237
Alice Wang000e3a32023-01-03 16:11:20 +0000238func TestAvbGenVbmetaImage(t *testing.T) {
239 result := fixture.RunTestWithBp(t, `
240 avb_gen_vbmeta_image {
241 name: "input_hashdesc",
242 src: "input.img",
243 partition_name: "input_partition_name",
244 salt: "2222",
245 }`)
246 cmd := result.ModuleForTests("input_hashdesc", "android_arm64_armv8-a").Rule("avbGenVbmetaImage").RuleParams.Command
247 android.AssertStringDoesContain(t, "Can't find correct --partition_name argument",
248 cmd, "--partition_name input_partition_name")
249 android.AssertStringDoesContain(t, "Can't find --do_not_append_vbmeta_image",
250 cmd, "--do_not_append_vbmeta_image")
251 android.AssertStringDoesContain(t, "Can't find --output_vbmeta_image",
252 cmd, "--output_vbmeta_image ")
253 android.AssertStringDoesContain(t, "Can't find --salt argument",
254 cmd, "--salt 2222")
255}
256
Jiyong Parkbc485482022-11-15 22:31:49 +0900257func TestAvbAddHashFooter(t *testing.T) {
258 result := fixture.RunTestWithBp(t, `
Alice Wang000e3a32023-01-03 16:11:20 +0000259 avb_gen_vbmeta_image {
260 name: "input_hashdesc",
261 src: "input.img",
262 partition_name: "input",
263 salt: "2222",
264 }
265
Jiyong Parkbc485482022-11-15 22:31:49 +0900266 avb_add_hash_footer {
267 name: "myfooter",
268 src: "input.img",
269 filename: "output.img",
270 partition_name: "mypartition",
271 private_key: "mykey",
272 salt: "1111",
273 props: [
274 {
275 name: "prop1",
276 value: "value1",
277 },
278 {
279 name: "prop2",
280 file: "value_file",
281 },
282 ],
Alice Wang000e3a32023-01-03 16:11:20 +0000283 include_descriptors_from_images: ["input_hashdesc"],
Jiyong Parkbc485482022-11-15 22:31:49 +0900284 }
285 `)
286 cmd := result.ModuleForTests("myfooter", "android_arm64_armv8-a").Rule("avbAddHashFooter").RuleParams.Command
287 android.AssertStringDoesContain(t, "Can't find correct --partition_name argument",
288 cmd, "--partition_name mypartition")
289 android.AssertStringDoesContain(t, "Can't find correct --key argument",
290 cmd, "--key mykey")
291 android.AssertStringDoesContain(t, "Can't find --salt argument",
292 cmd, "--salt 1111")
293 android.AssertStringDoesContain(t, "Can't find --prop argument",
294 cmd, "--prop 'prop1:value1'")
295 android.AssertStringDoesContain(t, "Can't find --prop_from_file argument",
296 cmd, "--prop_from_file 'prop2:value_file'")
Alice Wang000e3a32023-01-03 16:11:20 +0000297 android.AssertStringDoesContain(t, "Can't find --include_descriptors_from_image",
298 cmd, "--include_descriptors_from_image ")
Jiyong Parkbc485482022-11-15 22:31:49 +0900299}
Jooyung Han54f78052023-02-20 18:17:47 +0900300
Jooyung Hane6067592023-03-16 13:11:17 +0900301func TestFileSystemWithCoverageVariants(t *testing.T) {
302 context := android.GroupFixturePreparers(
303 fixture,
304 android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
305 variables.GcovCoverage = proptools.BoolPtr(true)
306 variables.Native_coverage = proptools.BoolPtr(true)
307 }),
308 )
309
310 result := context.RunTestWithBp(t, `
311 prebuilt_etc {
312 name: "prebuilt",
313 src: ":myfilesystem",
314 }
315
316 android_system_image {
317 name: "myfilesystem",
318 deps: [
319 "libfoo",
320 ],
321 linker_config_src: "linker.config.json",
322 }
323
324 cc_library {
325 name: "libfoo",
326 shared_libs: [
327 "libbar",
328 ],
329 stl: "none",
330 }
331
332 cc_library {
333 name: "libbar",
334 stl: "none",
335 }
336 `)
337
338 filesystem := result.ModuleForTests("myfilesystem", "android_common_cov")
Cole Faust3b806d32024-03-11 15:15:03 -0700339 inputs := filesystem.Output("myfilesystem.img").Implicits
Jooyung Hane6067592023-03-16 13:11:17 +0900340 android.AssertStringListContains(t, "filesystem should have libfoo(cov)",
341 inputs.Strings(),
342 "out/soong/.intermediates/libfoo/android_arm64_armv8-a_shared_cov/libfoo.so")
343 android.AssertStringListContains(t, "filesystem should have libbar(cov)",
344 inputs.Strings(),
345 "out/soong/.intermediates/libbar/android_arm64_armv8-a_shared_cov/libbar.so")
346
347 filesystemOutput := filesystem.Output("myfilesystem.img").Output
348 prebuiltInput := result.ModuleForTests("prebuilt", "android_arm64_armv8-a").Rule("Cp").Input
349 if filesystemOutput != prebuiltInput {
350 t.Error("prebuilt should use cov variant of filesystem")
351 }
352}
Jiyong Parkeaac8232024-03-31 21:27:45 +0900353
354func TestSystemImageDefaults(t *testing.T) {
355 result := fixture.RunTestWithBp(t, `
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900356 android_filesystem_defaults {
Jiyong Parkeaac8232024-03-31 21:27:45 +0900357 name: "defaults",
358 multilib: {
359 common: {
360 deps: [
361 "phony",
362 ],
363 },
364 lib64: {
365 deps: [
366 "libbar",
367 ],
368 },
369 },
370 compile_multilib: "both",
371 }
372
373 android_system_image {
374 name: "system",
375 defaults: ["defaults"],
376 multilib: {
377 lib32: {
378 deps: [
379 "foo",
380 "libbar",
381 ],
382 },
383 },
384 }
385
386 cc_binary {
387 name: "foo",
388 compile_multilib: "prefer32",
389 }
390
391 cc_library {
392 name: "libbar",
393 required: ["libbaz"],
394 }
395
396 cc_library {
397 name: "libbaz",
398 }
399
400 phony {
401 name: "phony",
402 required: ["libquz"],
403 }
404
405 cc_library {
406 name: "libquz",
407 }
408 `)
409
410 fs := result.ModuleForTests("system", "android_common").Module().(*systemImage)
411 expected := []string{
412 "bin/foo",
413 "lib/libbar.so",
414 "lib64/libbar.so",
415 "lib64/libbaz.so",
416 "lib64/libquz.so",
417 }
418 for _, e := range expected {
419 android.AssertStringListContains(t, "missing entry", fs.entries, e)
420 }
421}
Jiyong Parkf46b1af2024-04-05 18:13:33 +0900422
423func TestInconsistentPartitionTypesInDefaults(t *testing.T) {
424 fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(
425 "doesn't match with the partition type")).
426 RunTestWithBp(t, `
427 android_filesystem_defaults {
428 name: "system_ext_def",
429 partition_type: "system_ext",
430 }
431
432 android_filesystem_defaults {
433 name: "system_def",
434 partition_type: "system",
435 defaults: ["system_ext_def"],
436 }
437
438 android_system_image {
439 name: "system",
440 defaults: ["system_def"],
441 }
442 `)
443}
Jiyong Park16ef7ac2024-05-01 12:36:10 +0000444
445func TestPreventDuplicatedEntries(t *testing.T) {
446 fixture.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(
447 "packaging conflict at")).
448 RunTestWithBp(t, `
449 android_filesystem {
450 name: "fs",
451 deps: [
452 "foo",
453 "foo_dup",
454 ],
455 }
456
457 cc_binary {
458 name: "foo",
459 }
460
461 cc_binary {
462 name: "foo_dup",
463 stem: "foo",
464 }
465 `)
466}
Jiyong Parkc4b1d552024-05-13 16:47:30 +0900467
468func TestTrackPhonyAsRequiredDep(t *testing.T) {
469 result := fixture.RunTestWithBp(t, `
470 android_filesystem {
471 name: "fs",
472 deps: ["foo"],
473 }
474
475 cc_binary {
476 name: "foo",
477 required: ["phony"],
478 }
479
480 phony {
481 name: "phony",
482 required: ["libbar"],
483 }
484
485 cc_library {
486 name: "libbar",
487 }
488 `)
489
490 fs := result.ModuleForTests("fs", "android_common").Module().(*filesystem)
491 expected := []string{
492 "bin/foo",
493 "lib64/libbar.so",
494 }
495 for _, e := range expected {
496 android.AssertStringListContains(t, "missing entry", fs.entries, e)
497 }
498}
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900499
500func TestFilterOutUnsupportedArches(t *testing.T) {
501 result := fixture.RunTestWithBp(t, `
502 android_filesystem {
503 name: "fs_64_only",
504 deps: ["foo"],
505 }
506
507 android_filesystem {
508 name: "fs_64_32",
509 compile_multilib: "both",
Jiyong Park3ea9b652024-05-15 23:01:54 +0900510 deps: ["foo"],
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900511 }
512
513 cc_binary {
514 name: "foo",
515 required: ["phony"],
516 }
517
518 phony {
519 name: "phony",
520 required: [
521 "libbar",
522 "app",
523 ],
524 }
525
526 cc_library {
527 name: "libbar",
528 }
529
530 android_app {
531 name: "app",
532 srcs: ["a.java"],
533 platform_apis: true,
534 }
535 `)
536 testcases := []struct {
537 fsName string
538 expected []string
539 unexpected []string
540 }{
541 {
542 fsName: "fs_64_only",
543 expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so"},
544 unexpected: []string{"lib/libbar.so"},
545 },
546 {
547 fsName: "fs_64_32",
548 expected: []string{"app/app/app.apk", "bin/foo", "lib64/libbar.so", "lib/libbar.so"},
549 unexpected: []string{},
550 },
551 }
552 for _, c := range testcases {
553 fs := result.ModuleForTests(c.fsName, "android_common").Module().(*filesystem)
554 for _, e := range c.expected {
555 android.AssertStringListContains(t, "missing entry", fs.entries, e)
556 }
557 for _, e := range c.unexpected {
558 android.AssertStringListDoesNotContain(t, "unexpected entry", fs.entries, e)
559 }
560 }
561}
Spandan Dasc35d6fb2024-10-10 17:51:14 +0000562
563func TestErofsPartition(t *testing.T) {
564 result := fixture.RunTestWithBp(t, `
565 android_filesystem {
566 name: "erofs_partition",
567 type: "erofs",
568 erofs: {
569 compressor: "lz4hc,9",
570 compress_hints: "compress_hints.txt",
571 },
572 deps: ["binfoo"],
573 }
574
575 cc_binary {
576 name: "binfoo",
577 }
578 `)
579
580 partition := result.ModuleForTests("erofs_partition", "android_common")
581 buildImageConfig := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("prop"))
582 android.AssertStringDoesContain(t, "erofs fs type", buildImageConfig, "fs_type=erofs")
583 android.AssertStringDoesContain(t, "erofs fs type compress algorithm", buildImageConfig, "erofs_default_compressor=lz4hc,9")
584 android.AssertStringDoesContain(t, "erofs fs type compress hint", buildImageConfig, "erofs_default_compress_hints=compress_hints.txt")
585 android.AssertStringDoesContain(t, "erofs fs type sparse", buildImageConfig, "erofs_sparse_flag=-s")
586}
Hugo Drumond Jacob69d829a2024-10-21 09:55:45 +0000587
588// If a system_ext/ module depends on system/ module, the dependency should *not*
589// be installed in system_ext/
590func TestDoNotPackageCrossPartitionDependencies(t *testing.T) {
Spandan Das6d056502024-10-21 15:40:32 +0000591 t.Skip() // TODO (spandandas): Re-enable this
Hugo Drumond Jacob69d829a2024-10-21 09:55:45 +0000592 result := fixture.RunTestWithBp(t, `
593 android_filesystem {
594 name: "myfilesystem",
595 deps: ["binfoo"],
596 partition_type: "system_ext",
597 }
598
599 cc_binary {
600 name: "binfoo",
601 shared_libs: ["libfoo"],
602 system_ext_specific: true,
603 }
604 cc_library_shared {
605 name: "libfoo", // installed in system/
606 }
607 `)
608
609 partition := result.ModuleForTests("myfilesystem", "android_common")
610 fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
611 android.AssertDeepEquals(t, "filesystem with dependencies on different partition", "bin/binfoo\n", fileList)
612}
Spandan Das405f2d42024-10-22 18:31:25 +0000613
614// If a cc_library is listed in `deps`, and it has a shared and static variant, then the shared variant
615// should be installed.
616func TestUseSharedVariationOfNativeLib(t *testing.T) {
617 result := fixture.RunTestWithBp(t, `
618 android_filesystem {
619 name: "myfilesystem",
620 deps: ["libfoo"],
621 }
622 // cc_library will create a static and shared variant.
623 cc_library {
624 name: "libfoo",
625 }
626 `)
627
628 partition := result.ModuleForTests("myfilesystem", "android_common")
629 fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
630 android.AssertDeepEquals(t, "cc_library listed in deps", "lib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo.so\nlib64/libm.so\n", fileList)
631}
Spandan Das6c2b01d2024-10-22 22:16:04 +0000632
633// binfoo1 overrides binbar. transitive deps of binbar should not be installed.
634func TestDoNotInstallTransitiveDepOfOverriddenModule(t *testing.T) {
635 result := fixture.RunTestWithBp(t, `
636android_filesystem {
637 name: "myfilesystem",
638 deps: ["binfoo1", "libfoo2", "binbar"],
639}
640cc_binary {
641 name: "binfoo1",
642 shared_libs: ["libfoo"],
643 overrides: ["binbar"],
644}
645cc_library {
646 name: "libfoo",
647}
648cc_library {
649 name: "libfoo2",
650 overrides: ["libfoo"],
651}
652// binbar gets overridden by binfoo1
653// therefore, libbar should not be installed
654cc_binary {
655 name: "binbar",
656 shared_libs: ["libbar"]
657}
658cc_library {
659 name: "libbar",
660}
661 `)
662
663 partition := result.ModuleForTests("myfilesystem", "android_common")
664 fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
665 android.AssertDeepEquals(t, "Shared library dep of overridden binary should not be installed", fileList, "bin/binfoo1\nlib64/libc++.so\nlib64/libc.so\nlib64/libdl.so\nlib64/libfoo2.so\nlib64/libm.so\n")
666}
Spandan Das92631882024-10-28 22:49:38 +0000667
668func TestInstallLinkerConfigFile(t *testing.T) {
669 result := fixture.RunTestWithBp(t, `
670android_filesystem {
671 name: "myfilesystem",
672 deps: ["libfoo_has_no_stubs", "libfoo_has_stubs"],
Spandan Das918191e2024-10-31 18:27:23 +0000673 linker_config_srcs: ["linker.config.json"],
674 partition_type: "vendor",
Spandan Das92631882024-10-28 22:49:38 +0000675}
676cc_library {
677 name: "libfoo_has_no_stubs",
Spandan Das918191e2024-10-31 18:27:23 +0000678 vendor: true,
Spandan Das92631882024-10-28 22:49:38 +0000679}
680cc_library {
681 name: "libfoo_has_stubs",
682 stubs: {symbol_file: "libfoo.map.txt"},
Spandan Das918191e2024-10-31 18:27:23 +0000683 vendor: true,
Spandan Das92631882024-10-28 22:49:38 +0000684}
685 `)
686
687 linkerConfigCmd := result.ModuleForTests("myfilesystem", "android_common").Rule("build_filesystem_image").RuleParams.Command
Spandan Das918191e2024-10-31 18:27:23 +0000688 android.AssertStringDoesContain(t, "Could not find linker.config.json file in cmd", linkerConfigCmd, "conv_linker_config proto --force -s linker.config.json")
689 android.AssertStringDoesContain(t, "Could not find stub in `provideLibs`", linkerConfigCmd, "--key provideLibs --value libfoo_has_stubs.so")
Spandan Das92631882024-10-28 22:49:38 +0000690}