blob: 2c7f285f75b35afc7f1bcf699d476d2878b367e5 [file] [log] [blame]
Jiyong Park25fc6a92018-11-18 18:02:45 +09001// Copyright 2018 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 apex
16
17import (
Jiyong Park25fc6a92018-11-18 18:02:45 +090018 "io/ioutil"
19 "os"
20 "strings"
21 "testing"
Jiyong Parkda6eb592018-12-19 17:12:36 +090022
23 "github.com/google/blueprint/proptools"
24
25 "android/soong/android"
26 "android/soong/cc"
Jiyong Park25fc6a92018-11-18 18:02:45 +090027)
28
29func testApex(t *testing.T, bp string) *android.TestContext {
30 config, buildDir := setup(t)
31 defer teardown(buildDir)
32
33 ctx := android.NewTestArchContext()
Alex Light0851b882019-02-07 13:20:53 -080034 ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(apexBundleFactory))
35 ctx.RegisterModuleType("apex_test", android.ModuleFactoryAdaptor(testApexBundleFactory))
Jiyong Park25fc6a92018-11-18 18:02:45 +090036 ctx.RegisterModuleType("apex_key", android.ModuleFactoryAdaptor(apexKeyFactory))
Jiyong Park30ca9372019-02-07 16:27:23 +090037 ctx.RegisterModuleType("apex_defaults", android.ModuleFactoryAdaptor(defaultsFactory))
38 ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
Jiyong Park25fc6a92018-11-18 18:02:45 +090039
40 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
41 ctx.TopDown("apex_deps", apexDepsMutator)
42 ctx.BottomUp("apex", apexMutator)
43 })
44
45 ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
46 ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
Jiyong Park7e636d02019-01-28 16:16:54 +090047 ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory))
Jiyong Park16e91a02018-12-20 18:18:08 +090048 ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory))
Jiyong Park25fc6a92018-11-18 18:02:45 +090049 ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
Jiyong Parkda6eb592018-12-19 17:12:36 +090050 ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
Jiyong Park25fc6a92018-11-18 18:02:45 +090051 ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory))
Jiyong Park7c2ee712018-12-07 00:42:25 +090052 ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory))
Jiyong Park04480cf2019-02-06 00:16:29 +090053 ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory))
Jiyong Park25fc6a92018-11-18 18:02:45 +090054 ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Jiyong Parkda6eb592018-12-19 17:12:36 +090055 ctx.BottomUp("image", cc.ImageMutator).Parallel()
Jiyong Park25fc6a92018-11-18 18:02:45 +090056 ctx.BottomUp("link", cc.LinkageMutator).Parallel()
Jiyong Parkda6eb592018-12-19 17:12:36 +090057 ctx.BottomUp("vndk", cc.VndkMutator).Parallel()
Jiyong Park25fc6a92018-11-18 18:02:45 +090058 ctx.BottomUp("version", cc.VersionMutator).Parallel()
59 ctx.BottomUp("begin", cc.BeginMutator).Parallel()
60 })
61
62 ctx.Register()
63
64 bp = bp + `
65 toolchain_library {
66 name: "libcompiler_rt-extras",
67 src: "",
Jiyong Parkda6eb592018-12-19 17:12:36 +090068 vendor_available: true,
69 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +090070 }
71
72 toolchain_library {
73 name: "libatomic",
74 src: "",
Jiyong Parkda6eb592018-12-19 17:12:36 +090075 vendor_available: true,
76 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +090077 }
78
79 toolchain_library {
80 name: "libgcc",
81 src: "",
Jiyong Parkda6eb592018-12-19 17:12:36 +090082 vendor_available: true,
83 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +090084 }
85
86 toolchain_library {
87 name: "libclang_rt.builtins-aarch64-android",
88 src: "",
Jiyong Parkda6eb592018-12-19 17:12:36 +090089 vendor_available: true,
90 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +090091 }
92
93 toolchain_library {
94 name: "libclang_rt.builtins-arm-android",
95 src: "",
Jiyong Parkda6eb592018-12-19 17:12:36 +090096 vendor_available: true,
97 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +090098 }
99
100 cc_object {
101 name: "crtbegin_so",
102 stl: "none",
Jiyong Parkda6eb592018-12-19 17:12:36 +0900103 vendor_available: true,
104 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +0900105 }
106
107 cc_object {
108 name: "crtend_so",
109 stl: "none",
Jiyong Parkda6eb592018-12-19 17:12:36 +0900110 vendor_available: true,
111 recovery_available: true,
Jiyong Park25fc6a92018-11-18 18:02:45 +0900112 }
113
Alex Light3d673592019-01-18 14:37:31 -0800114 cc_object {
115 name: "crtbegin_static",
116 stl: "none",
117 }
118
119 cc_object {
120 name: "crtend_android",
121 stl: "none",
122 }
123
Jiyong Parkda6eb592018-12-19 17:12:36 +0900124 llndk_library {
125 name: "libc",
126 symbol_file: "",
127 }
128
129 llndk_library {
130 name: "libm",
131 symbol_file: "",
132 }
133
134 llndk_library {
135 name: "libdl",
136 symbol_file: "",
137 }
Jiyong Park25fc6a92018-11-18 18:02:45 +0900138 `
139
140 ctx.MockFileSystem(map[string][]byte{
Jiyong Park58e364a2019-01-19 19:24:06 +0900141 "Android.bp": []byte(bp),
142 "build/target/product/security": nil,
143 "apex_manifest.json": nil,
144 "system/sepolicy/apex/myapex-file_contexts": nil,
145 "system/sepolicy/apex/otherapex-file_contexts": nil,
146 "mylib.cpp": nil,
147 "myprebuilt": nil,
Jiyong Park7e636d02019-01-28 16:16:54 +0900148 "my_include": nil,
Jiyong Park58e364a2019-01-19 19:24:06 +0900149 "vendor/foo/devkeys/test.x509.pem": nil,
150 "vendor/foo/devkeys/test.pk8": nil,
151 "vendor/foo/devkeys/testkey.avbpubkey": nil,
152 "vendor/foo/devkeys/testkey.pem": nil,
Jiyong Park25fc6a92018-11-18 18:02:45 +0900153 })
154 _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
155 android.FailIfErrored(t, errs)
156 _, errs = ctx.PrepareBuildActions(config)
157 android.FailIfErrored(t, errs)
158
159 return ctx
160}
161
162func setup(t *testing.T) (config android.Config, buildDir string) {
163 buildDir, err := ioutil.TempDir("", "soong_apex_test")
164 if err != nil {
165 t.Fatal(err)
166 }
167
168 config = android.TestArchConfig(buildDir, nil)
Jiyong Parkda6eb592018-12-19 17:12:36 +0900169 config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current")
Jiyong Park9335a262018-12-24 11:31:58 +0900170 config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900171 return
172}
173
174func teardown(buildDir string) {
175 os.RemoveAll(buildDir)
176}
177
178// ensure that 'result' contains 'expected'
179func ensureContains(t *testing.T, result string, expected string) {
180 if !strings.Contains(result, expected) {
181 t.Errorf("%q is not found in %q", expected, result)
182 }
183}
184
185// ensures that 'result' does not contain 'notExpected'
186func ensureNotContains(t *testing.T, result string, notExpected string) {
187 if strings.Contains(result, notExpected) {
188 t.Errorf("%q is found in %q", notExpected, result)
189 }
190}
191
192func ensureListContains(t *testing.T, result []string, expected string) {
193 if !android.InList(expected, result) {
194 t.Errorf("%q is not found in %v", expected, result)
195 }
196}
197
198func ensureListNotContains(t *testing.T, result []string, notExpected string) {
199 if android.InList(notExpected, result) {
200 t.Errorf("%q is found in %v", notExpected, result)
201 }
202}
203
204// Minimal test
205func TestBasicApex(t *testing.T) {
206 ctx := testApex(t, `
Jiyong Park30ca9372019-02-07 16:27:23 +0900207 apex_defaults {
208 name: "myapex-defaults",
Jiyong Park25fc6a92018-11-18 18:02:45 +0900209 key: "myapex.key",
210 native_shared_libs: ["mylib"],
Alex Light3d673592019-01-18 14:37:31 -0800211 multilib: {
212 both: {
213 binaries: ["foo",],
214 }
215 }
Jiyong Park25fc6a92018-11-18 18:02:45 +0900216 }
217
Jiyong Park30ca9372019-02-07 16:27:23 +0900218 apex {
219 name: "myapex",
220 defaults: ["myapex-defaults"],
221 }
222
Jiyong Park25fc6a92018-11-18 18:02:45 +0900223 apex_key {
224 name: "myapex.key",
225 public_key: "testkey.avbpubkey",
226 private_key: "testkey.pem",
227 }
228
229 cc_library {
230 name: "mylib",
231 srcs: ["mylib.cpp"],
232 shared_libs: ["mylib2"],
233 system_shared_libs: [],
234 stl: "none",
235 }
236
Alex Light3d673592019-01-18 14:37:31 -0800237 cc_binary {
238 name: "foo",
239 srcs: ["mylib.cpp"],
240 compile_multilib: "both",
241 multilib: {
242 lib32: {
243 suffix: "32",
244 },
245 lib64: {
246 suffix: "64",
247 },
248 },
249 symlinks: ["foo_link_"],
250 symlink_preferred_arch: true,
251 system_shared_libs: [],
252 static_executable: true,
253 stl: "none",
254 }
255
Jiyong Park25fc6a92018-11-18 18:02:45 +0900256 cc_library {
257 name: "mylib2",
258 srcs: ["mylib.cpp"],
259 system_shared_libs: [],
260 stl: "none",
261 }
262 `)
263
264 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
265 copyCmds := apexRule.Args["copy_commands"]
266
267 // Ensure that main rule creates an output
268 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
269
270 // Ensure that apex variant is created for the direct dep
Jiyong Parkda6eb592018-12-19 17:12:36 +0900271 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900272
273 // Ensure that apex variant is created for the indirect dep
Jiyong Parkda6eb592018-12-19 17:12:36 +0900274 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900275
276 // Ensure that both direct and indirect deps are copied into apex
Alex Light5098a612018-11-29 17:12:15 -0800277 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
278 ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
Logan Chien3aeedc92018-12-26 15:32:21 +0800279
280 // Ensure that the platform variant ends with _core_shared
281 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
282 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
Alex Light3d673592019-01-18 14:37:31 -0800283
284 // Ensure that all symlinks are present.
285 found_foo_link_64 := false
286 found_foo := false
287 for _, cmd := range strings.Split(copyCmds, " && ") {
288 if strings.HasPrefix(cmd, "ln -s foo64") {
289 if strings.HasSuffix(cmd, "bin/foo") {
290 found_foo = true
291 } else if strings.HasSuffix(cmd, "bin/foo_link_64") {
292 found_foo_link_64 = true
293 }
294 }
295 }
296 good := found_foo && found_foo_link_64
297 if !good {
298 t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds)
299 }
Alex Light5098a612018-11-29 17:12:15 -0800300}
301
302func TestBasicZipApex(t *testing.T) {
303 ctx := testApex(t, `
304 apex {
305 name: "myapex",
306 key: "myapex.key",
307 payload_type: "zip",
308 native_shared_libs: ["mylib"],
309 }
310
311 apex_key {
312 name: "myapex.key",
313 public_key: "testkey.avbpubkey",
314 private_key: "testkey.pem",
315 }
316
317 cc_library {
318 name: "mylib",
319 srcs: ["mylib.cpp"],
320 shared_libs: ["mylib2"],
321 system_shared_libs: [],
322 stl: "none",
323 }
324
325 cc_library {
326 name: "mylib2",
327 srcs: ["mylib.cpp"],
328 system_shared_libs: [],
329 stl: "none",
330 }
331 `)
332
333 zipApexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("zipApexRule")
334 copyCmds := zipApexRule.Args["copy_commands"]
335
336 // Ensure that main rule creates an output
337 ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned")
338
339 // Ensure that APEX variant is created for the direct dep
Jiyong Parkda6eb592018-12-19 17:12:36 +0900340 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
Alex Light5098a612018-11-29 17:12:15 -0800341
342 // Ensure that APEX variant is created for the indirect dep
Jiyong Parkda6eb592018-12-19 17:12:36 +0900343 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
Alex Light5098a612018-11-29 17:12:15 -0800344
345 // Ensure that both direct and indirect deps are copied into apex
346 ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so")
347 ensureContains(t, copyCmds, "image.zipapex/lib64/mylib2.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900348}
349
350func TestApexWithStubs(t *testing.T) {
351 ctx := testApex(t, `
352 apex {
353 name: "myapex",
354 key: "myapex.key",
355 native_shared_libs: ["mylib", "mylib3"],
356 }
357
358 apex_key {
359 name: "myapex.key",
360 public_key: "testkey.avbpubkey",
361 private_key: "testkey.pem",
362 }
363
364 cc_library {
365 name: "mylib",
366 srcs: ["mylib.cpp"],
367 shared_libs: ["mylib2", "mylib3"],
368 system_shared_libs: [],
369 stl: "none",
370 }
371
372 cc_library {
373 name: "mylib2",
374 srcs: ["mylib.cpp"],
Jiyong Park64379952018-12-13 18:37:29 +0900375 cflags: ["-include mylib.h"],
Jiyong Park25fc6a92018-11-18 18:02:45 +0900376 system_shared_libs: [],
377 stl: "none",
378 stubs: {
379 versions: ["1", "2", "3"],
380 },
381 }
382
383 cc_library {
384 name: "mylib3",
Jiyong Park28d395a2018-12-07 22:42:47 +0900385 srcs: ["mylib.cpp"],
386 shared_libs: ["mylib4"],
387 system_shared_libs: [],
Jiyong Park25fc6a92018-11-18 18:02:45 +0900388 stl: "none",
389 stubs: {
390 versions: ["10", "11", "12"],
391 },
392 }
Jiyong Park28d395a2018-12-07 22:42:47 +0900393
394 cc_library {
395 name: "mylib4",
396 srcs: ["mylib.cpp"],
397 system_shared_libs: [],
398 stl: "none",
399 }
Jiyong Park25fc6a92018-11-18 18:02:45 +0900400 `)
401
402 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
403 copyCmds := apexRule.Args["copy_commands"]
404
405 // Ensure that direct non-stubs dep is always included
Alex Light5098a612018-11-29 17:12:15 -0800406 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900407
408 // Ensure that indirect stubs dep is not included
Alex Light5098a612018-11-29 17:12:15 -0800409 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900410
411 // Ensure that direct stubs dep is included
Alex Light5098a612018-11-29 17:12:15 -0800412 ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900413
Jiyong Parkda6eb592018-12-19 17:12:36 +0900414 mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
Jiyong Park25fc6a92018-11-18 18:02:45 +0900415
416 // Ensure that mylib is linking with the latest version of stubs for mylib2
Jiyong Parkda6eb592018-12-19 17:12:36 +0900417 ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_3_myapex/mylib2.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900418 // ... and not linking to the non-stub (impl) variant of mylib2
Jiyong Parkda6eb592018-12-19 17:12:36 +0900419 ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_myapex/mylib2.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900420
421 // Ensure that mylib is linking with the non-stub (impl) of mylib3 (because mylib3 is in the same apex)
Jiyong Parkda6eb592018-12-19 17:12:36 +0900422 ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_myapex/mylib3.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900423 // .. and not linking to the stubs variant of mylib3
Jiyong Parkda6eb592018-12-19 17:12:36 +0900424 ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_12_myapex/mylib3.so")
Jiyong Park64379952018-12-13 18:37:29 +0900425
426 // Ensure that stubs libs are built without -include flags
Jiyong Parkda6eb592018-12-19 17:12:36 +0900427 mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
Jiyong Park64379952018-12-13 18:37:29 +0900428 ensureNotContains(t, mylib2Cflags, "-include ")
Jiyong Park3fd0baf2018-12-07 16:25:39 +0900429
430 // Ensure that genstub is invoked with --apex
Jiyong Parkda6eb592018-12-19 17:12:36 +0900431 ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_3_myapex").Rule("genStubSrc").Args["flags"])
Jiyong Park25fc6a92018-11-18 18:02:45 +0900432}
433
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900434func TestApexWithExplicitStubsDependency(t *testing.T) {
435 ctx := testApex(t, `
436 apex {
437 name: "myapex",
438 key: "myapex.key",
439 native_shared_libs: ["mylib"],
440 }
441
442 apex_key {
443 name: "myapex.key",
444 public_key: "testkey.avbpubkey",
445 private_key: "testkey.pem",
446 }
447
448 cc_library {
449 name: "mylib",
450 srcs: ["mylib.cpp"],
451 shared_libs: ["libfoo#10"],
452 system_shared_libs: [],
453 stl: "none",
454 }
455
456 cc_library {
457 name: "libfoo",
458 srcs: ["mylib.cpp"],
459 shared_libs: ["libbar"],
460 system_shared_libs: [],
461 stl: "none",
462 stubs: {
463 versions: ["10", "20", "30"],
464 },
465 }
466
467 cc_library {
468 name: "libbar",
469 srcs: ["mylib.cpp"],
470 system_shared_libs: [],
471 stl: "none",
472 }
473
474 `)
475
476 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
477 copyCmds := apexRule.Args["copy_commands"]
478
479 // Ensure that direct non-stubs dep is always included
480 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
481
482 // Ensure that indirect stubs dep is not included
483 ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so")
484
485 // Ensure that dependency of stubs is not included
486 ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
487
Jiyong Parkda6eb592018-12-19 17:12:36 +0900488 mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900489
490 // Ensure that mylib is linking with version 10 of libfoo
Jiyong Parkda6eb592018-12-19 17:12:36 +0900491 ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_10_myapex/libfoo.so")
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900492 // ... and not linking to the non-stub (impl) variant of libfoo
Jiyong Parkda6eb592018-12-19 17:12:36 +0900493 ensureNotContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_myapex/libfoo.so")
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900494
Jiyong Parkda6eb592018-12-19 17:12:36 +0900495 libFooStubsLdFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_core_shared_10_myapex").Rule("ld").Args["libFlags"]
Jiyong Park0ddfcd12018-12-11 01:35:25 +0900496
497 // Ensure that libfoo stubs is not linking to libbar (since it is a stubs)
498 ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
499}
500
Jiyong Park25fc6a92018-11-18 18:02:45 +0900501func TestApexWithSystemLibsStubs(t *testing.T) {
502 ctx := testApex(t, `
503 apex {
504 name: "myapex",
505 key: "myapex.key",
506 native_shared_libs: ["mylib", "mylib_shared", "libdl", "libm"],
507 }
508
509 apex_key {
510 name: "myapex.key",
511 public_key: "testkey.avbpubkey",
512 private_key: "testkey.pem",
513 }
514
515 cc_library {
516 name: "mylib",
517 srcs: ["mylib.cpp"],
518 shared_libs: ["libdl#27"],
519 stl: "none",
520 }
521
522 cc_library_shared {
523 name: "mylib_shared",
524 srcs: ["mylib.cpp"],
525 shared_libs: ["libdl#27"],
526 stl: "none",
527 }
528
529 cc_library {
530 name: "libc",
531 no_libgcc: true,
532 nocrt: true,
533 system_shared_libs: [],
534 stl: "none",
535 stubs: {
536 versions: ["27", "28", "29"],
537 },
538 }
539
540 cc_library {
541 name: "libm",
542 no_libgcc: true,
543 nocrt: true,
544 system_shared_libs: [],
545 stl: "none",
546 stubs: {
547 versions: ["27", "28", "29"],
548 },
549 }
550
551 cc_library {
552 name: "libdl",
553 no_libgcc: true,
554 nocrt: true,
555 system_shared_libs: [],
556 stl: "none",
557 stubs: {
558 versions: ["27", "28", "29"],
559 },
560 }
Jiyong Parkb0788572018-12-20 22:10:17 +0900561
562 cc_library {
563 name: "libBootstrap",
564 srcs: ["mylib.cpp"],
565 stl: "none",
566 bootstrap: true,
567 }
Jiyong Park25fc6a92018-11-18 18:02:45 +0900568 `)
569
570 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
571 copyCmds := apexRule.Args["copy_commands"]
572
573 // Ensure that mylib, libm, libdl are included.
Alex Light5098a612018-11-29 17:12:15 -0800574 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
Jiyong Parkb0788572018-12-20 22:10:17 +0900575 ensureContains(t, copyCmds, "image.apex/lib64/bionic/libm.so")
576 ensureContains(t, copyCmds, "image.apex/lib64/bionic/libdl.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900577
578 // Ensure that libc is not included (since it has stubs and not listed in native_shared_libs)
Jiyong Parkb0788572018-12-20 22:10:17 +0900579 ensureNotContains(t, copyCmds, "image.apex/lib64/bionic/libc.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900580
Jiyong Parkda6eb592018-12-19 17:12:36 +0900581 mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"]
582 mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
583 mylibSharedCFlags := ctx.ModuleForTests("mylib_shared", "android_arm64_armv8-a_core_shared_myapex").Rule("cc").Args["cFlags"]
Jiyong Park25fc6a92018-11-18 18:02:45 +0900584
585 // For dependency to libc
586 // Ensure that mylib is linking with the latest version of stubs
Jiyong Parkda6eb592018-12-19 17:12:36 +0900587 ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_29_myapex/libc.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900588 // ... and not linking to the non-stub (impl) variant
Jiyong Parkda6eb592018-12-19 17:12:36 +0900589 ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_myapex/libc.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900590 // ... Cflags from stub is correctly exported to mylib
591 ensureContains(t, mylibCFlags, "__LIBC_API__=29")
592 ensureContains(t, mylibSharedCFlags, "__LIBC_API__=29")
593
594 // For dependency to libm
595 // Ensure that mylib is linking with the non-stub (impl) variant
Jiyong Parkda6eb592018-12-19 17:12:36 +0900596 ensureContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_myapex/libm.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900597 // ... and not linking to the stub variant
Jiyong Parkda6eb592018-12-19 17:12:36 +0900598 ensureNotContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_29_myapex/libm.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900599 // ... and is not compiling with the stub
600 ensureNotContains(t, mylibCFlags, "__LIBM_API__=29")
601 ensureNotContains(t, mylibSharedCFlags, "__LIBM_API__=29")
602
603 // For dependency to libdl
604 // Ensure that mylib is linking with the specified version of stubs
Jiyong Parkda6eb592018-12-19 17:12:36 +0900605 ensureContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_27_myapex/libdl.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900606 // ... and not linking to the other versions of stubs
Jiyong Parkda6eb592018-12-19 17:12:36 +0900607 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_28_myapex/libdl.so")
608 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_29_myapex/libdl.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900609 // ... and not linking to the non-stub (impl) variant
Jiyong Parkda6eb592018-12-19 17:12:36 +0900610 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_myapex/libdl.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900611 // ... Cflags from stub is correctly exported to mylib
612 ensureContains(t, mylibCFlags, "__LIBDL_API__=27")
613 ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27")
Jiyong Parkb0788572018-12-20 22:10:17 +0900614
615 // Ensure that libBootstrap is depending on the platform variant of bionic libs
616 libFlags := ctx.ModuleForTests("libBootstrap", "android_arm64_armv8-a_core_shared").Rule("ld").Args["libFlags"]
617 ensureContains(t, libFlags, "libc/android_arm64_armv8-a_core_shared/libc.so")
618 ensureContains(t, libFlags, "libm/android_arm64_armv8-a_core_shared/libm.so")
619 ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_core_shared/libdl.so")
Jiyong Park25fc6a92018-11-18 18:02:45 +0900620}
Jiyong Park7c2ee712018-12-07 00:42:25 +0900621
622func TestFilesInSubDir(t *testing.T) {
623 ctx := testApex(t, `
624 apex {
625 name: "myapex",
626 key: "myapex.key",
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900627 native_shared_libs: ["mylib"],
628 binaries: ["mybin"],
Jiyong Park7c2ee712018-12-07 00:42:25 +0900629 prebuilts: ["myetc"],
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900630 compile_multilib: "both",
Jiyong Park7c2ee712018-12-07 00:42:25 +0900631 }
632
633 apex_key {
634 name: "myapex.key",
635 public_key: "testkey.avbpubkey",
636 private_key: "testkey.pem",
637 }
638
639 prebuilt_etc {
640 name: "myetc",
641 src: "myprebuilt",
642 sub_dir: "foo/bar",
643 }
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900644
645 cc_library {
646 name: "mylib",
647 srcs: ["mylib.cpp"],
648 relative_install_path: "foo/bar",
649 system_shared_libs: [],
650 stl: "none",
651 }
652
653 cc_binary {
654 name: "mybin",
655 srcs: ["mylib.cpp"],
656 relative_install_path: "foo/bar",
657 system_shared_libs: [],
658 static_executable: true,
659 stl: "none",
660 }
Jiyong Park7c2ee712018-12-07 00:42:25 +0900661 `)
662
663 generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig")
664 dirs := strings.Split(generateFsRule.Args["exec_paths"], " ")
665
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900666 // Ensure that the subdirectories are all listed
Jiyong Park7c2ee712018-12-07 00:42:25 +0900667 ensureListContains(t, dirs, "etc")
668 ensureListContains(t, dirs, "etc/foo")
669 ensureListContains(t, dirs, "etc/foo/bar")
Jiyong Parkb7c24df2019-02-01 12:03:59 +0900670 ensureListContains(t, dirs, "lib64")
671 ensureListContains(t, dirs, "lib64/foo")
672 ensureListContains(t, dirs, "lib64/foo/bar")
673 ensureListContains(t, dirs, "lib")
674 ensureListContains(t, dirs, "lib/foo")
675 ensureListContains(t, dirs, "lib/foo/bar")
676
677 // TODO(b/123721777) respect relative path for binaries
678 // ensureListContains(t, dirs, "bin")
679 // ensureListContains(t, dirs, "bin/foo")
680 // ensureListContains(t, dirs, "bin/foo/bar")
Jiyong Park7c2ee712018-12-07 00:42:25 +0900681}
Jiyong Parkda6eb592018-12-19 17:12:36 +0900682
683func TestUseVendor(t *testing.T) {
684 ctx := testApex(t, `
685 apex {
686 name: "myapex",
687 key: "myapex.key",
688 native_shared_libs: ["mylib"],
689 use_vendor: true,
690 }
691
692 apex_key {
693 name: "myapex.key",
694 public_key: "testkey.avbpubkey",
695 private_key: "testkey.pem",
696 }
697
698 cc_library {
699 name: "mylib",
700 srcs: ["mylib.cpp"],
701 shared_libs: ["mylib2"],
702 system_shared_libs: [],
703 vendor_available: true,
704 stl: "none",
705 }
706
707 cc_library {
708 name: "mylib2",
709 srcs: ["mylib.cpp"],
710 system_shared_libs: [],
711 vendor_available: true,
712 stl: "none",
713 }
714 `)
715
716 inputsList := []string{}
717 for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex").Module().BuildParamsForTests() {
718 for _, implicit := range i.Implicits {
719 inputsList = append(inputsList, implicit.String())
720 }
721 }
722 inputsString := strings.Join(inputsList, " ")
723
724 // ensure that the apex includes vendor variants of the direct and indirect deps
725 ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib.so")
726 ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib2.so")
727
728 // ensure that the apex does not include core variants
729 ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib.so")
730 ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib2.so")
731}
Jiyong Park16e91a02018-12-20 18:18:08 +0900732
733func TestStaticLinking(t *testing.T) {
734 ctx := testApex(t, `
735 apex {
736 name: "myapex",
737 key: "myapex.key",
738 native_shared_libs: ["mylib"],
739 }
740
741 apex_key {
742 name: "myapex.key",
743 public_key: "testkey.avbpubkey",
744 private_key: "testkey.pem",
745 }
746
747 cc_library {
748 name: "mylib",
749 srcs: ["mylib.cpp"],
750 system_shared_libs: [],
751 stl: "none",
752 stubs: {
753 versions: ["1", "2", "3"],
754 },
755 }
756
757 cc_binary {
758 name: "not_in_apex",
759 srcs: ["mylib.cpp"],
760 static_libs: ["mylib"],
761 static_executable: true,
762 system_shared_libs: [],
763 stl: "none",
764 }
Jiyong Park16e91a02018-12-20 18:18:08 +0900765 `)
766
767 ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"]
768
769 // Ensure that not_in_apex is linking with the static variant of mylib
Logan Chien3aeedc92018-12-26 15:32:21 +0800770 ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_core_static/mylib.a")
Jiyong Park16e91a02018-12-20 18:18:08 +0900771}
Jiyong Park9335a262018-12-24 11:31:58 +0900772
773func TestKeys(t *testing.T) {
774 ctx := testApex(t, `
775 apex {
776 name: "myapex",
777 key: "myapex.key",
778 native_shared_libs: ["mylib"],
779 }
780
781 cc_library {
782 name: "mylib",
783 srcs: ["mylib.cpp"],
784 system_shared_libs: [],
785 stl: "none",
786 }
787
788 apex_key {
789 name: "myapex.key",
790 public_key: "testkey.avbpubkey",
791 private_key: "testkey.pem",
792 }
793
794 `)
795
796 // check the APEX keys
797 keys := ctx.ModuleForTests("myapex.key", "").Module().(*apexKey)
798
799 if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
800 t.Errorf("public key %q is not %q", keys.public_key_file.String(),
801 "vendor/foo/devkeys/testkey.avbpubkey")
802 }
803 if keys.private_key_file.String() != "vendor/foo/devkeys/testkey.pem" {
804 t.Errorf("private key %q is not %q", keys.private_key_file.String(),
805 "vendor/foo/devkeys/testkey.pem")
806 }
807
808 // check the APK certs
809 certs := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("signapk").Args["certificates"]
810 if certs != "vendor/foo/devkeys/test.x509.pem vendor/foo/devkeys/test.pk8" {
811 t.Errorf("cert and private key %q are not %q", certs,
812 "vendor/foo/devkeys/test.x509.pem vendor/foo/devkeys/test.pk8")
813 }
814}
Jiyong Park58e364a2019-01-19 19:24:06 +0900815
816func TestMacro(t *testing.T) {
817 ctx := testApex(t, `
818 apex {
819 name: "myapex",
820 key: "myapex.key",
821 native_shared_libs: ["mylib"],
822 }
823
824 apex {
825 name: "otherapex",
826 key: "myapex.key",
827 native_shared_libs: ["mylib"],
828 }
829
830 apex_key {
831 name: "myapex.key",
832 public_key: "testkey.avbpubkey",
833 private_key: "testkey.pem",
834 }
835
836 cc_library {
837 name: "mylib",
838 srcs: ["mylib.cpp"],
839 system_shared_libs: [],
840 stl: "none",
841 }
842 `)
843
844 // non-APEX variant does not have __ANDROID__APEX__ defined
845 mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
846 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
847 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
848
849 // APEX variant has __ANDROID_APEX__=<apexname> defined
850 mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"]
851 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
852 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
853
854 // APEX variant has __ANDROID_APEX__=<apexname> defined
855 mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_otherapex").Rule("cc").Args["cFlags"]
856 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
857 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
858}
Jiyong Park7e636d02019-01-28 16:16:54 +0900859
860func TestHeaderLibsDependency(t *testing.T) {
861 ctx := testApex(t, `
862 apex {
863 name: "myapex",
864 key: "myapex.key",
865 native_shared_libs: ["mylib"],
866 }
867
868 apex_key {
869 name: "myapex.key",
870 public_key: "testkey.avbpubkey",
871 private_key: "testkey.pem",
872 }
873
874 cc_library_headers {
875 name: "mylib_headers",
876 export_include_dirs: ["my_include"],
877 system_shared_libs: [],
878 stl: "none",
879 }
880
881 cc_library {
882 name: "mylib",
883 srcs: ["mylib.cpp"],
884 system_shared_libs: [],
885 stl: "none",
886 header_libs: ["mylib_headers"],
887 export_header_lib_headers: ["mylib_headers"],
888 stubs: {
889 versions: ["1", "2", "3"],
890 },
891 }
892
893 cc_library {
894 name: "otherlib",
895 srcs: ["mylib.cpp"],
896 system_shared_libs: [],
897 stl: "none",
898 shared_libs: ["mylib"],
899 }
900 `)
901
902 cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
903
904 // Ensure that the include path of the header lib is exported to 'otherlib'
905 ensureContains(t, cFlags, "-Imy_include")
906}
Alex Light9670d332019-01-29 18:07:33 -0800907
Alex Light0851b882019-02-07 13:20:53 -0800908func TestNonTestApex(t *testing.T) {
909 ctx := testApex(t, `
910 apex {
911 name: "myapex",
912 key: "myapex.key",
913 native_shared_libs: ["mylib_common"],
914 }
915
916 apex_key {
917 name: "myapex.key",
918 public_key: "testkey.avbpubkey",
919 private_key: "testkey.pem",
920 }
921
922 cc_library {
923 name: "mylib_common",
924 srcs: ["mylib.cpp"],
925 system_shared_libs: [],
926 stl: "none",
927 }
928 `)
929
930 module := ctx.ModuleForTests("myapex", "android_common_myapex")
931 apexRule := module.Rule("apexRule")
932 copyCmds := apexRule.Args["copy_commands"]
933
934 if apex, ok := module.Module().(*apexBundle); !ok || apex.testApex {
935 t.Log("Apex was a test apex!")
936 t.Fail()
937 }
938 // Ensure that main rule creates an output
939 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
940
941 // Ensure that apex variant is created for the direct dep
942 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex")
943
944 // Ensure that both direct and indirect deps are copied into apex
945 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
946
947 // Ensure that the platform variant ends with _core_shared
948 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared")
949
950 if !android.InAnyApex("mylib_common") {
951 t.Log("Found mylib_common not in any apex!")
952 t.Fail()
953 }
954}
955
956func TestTestApex(t *testing.T) {
957 if android.InAnyApex("mylib_common_test") {
958 t.Fatal("mylib_common_test must not be used in any other tests since this checks that global state is not updated in an illegal way!")
959 }
960 ctx := testApex(t, `
961 apex_test {
962 name: "myapex",
963 key: "myapex.key",
964 native_shared_libs: ["mylib_common_test"],
965 }
966
967 apex_key {
968 name: "myapex.key",
969 public_key: "testkey.avbpubkey",
970 private_key: "testkey.pem",
971 }
972
973 cc_library {
974 name: "mylib_common_test",
975 srcs: ["mylib.cpp"],
976 system_shared_libs: [],
977 stl: "none",
978 }
979 `)
980
981 module := ctx.ModuleForTests("myapex", "android_common_myapex")
982 apexRule := module.Rule("apexRule")
983 copyCmds := apexRule.Args["copy_commands"]
984
985 if apex, ok := module.Module().(*apexBundle); !ok || !apex.testApex {
986 t.Log("Apex was not a test apex!")
987 t.Fail()
988 }
989 // Ensure that main rule creates an output
990 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
991
992 // Ensure that apex variant is created for the direct dep
993 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared_myapex")
994
995 // Ensure that both direct and indirect deps are copied into apex
996 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common_test.so")
997
998 // Ensure that the platform variant ends with _core_shared
999 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared")
1000
1001 if android.InAnyApex("mylib_common_test") {
1002 t.Log("Found mylib_common_test in some apex!")
1003 t.Fail()
1004 }
1005}
1006
Alex Light9670d332019-01-29 18:07:33 -08001007func TestApexWithTarget(t *testing.T) {
1008 ctx := testApex(t, `
1009 apex {
1010 name: "myapex",
1011 key: "myapex.key",
1012 multilib: {
1013 first: {
1014 native_shared_libs: ["mylib_common"],
1015 }
1016 },
1017 target: {
1018 android: {
1019 multilib: {
1020 first: {
1021 native_shared_libs: ["mylib"],
1022 }
1023 }
1024 },
1025 host: {
1026 multilib: {
1027 first: {
1028 native_shared_libs: ["mylib2"],
1029 }
1030 }
1031 }
1032 }
1033 }
1034
1035 apex_key {
1036 name: "myapex.key",
1037 public_key: "testkey.avbpubkey",
1038 private_key: "testkey.pem",
1039 }
1040
1041 cc_library {
1042 name: "mylib",
1043 srcs: ["mylib.cpp"],
1044 system_shared_libs: [],
1045 stl: "none",
1046 }
1047
1048 cc_library {
1049 name: "mylib_common",
1050 srcs: ["mylib.cpp"],
1051 system_shared_libs: [],
1052 stl: "none",
1053 compile_multilib: "first",
1054 }
1055
1056 cc_library {
1057 name: "mylib2",
1058 srcs: ["mylib.cpp"],
1059 system_shared_libs: [],
1060 stl: "none",
1061 compile_multilib: "first",
1062 }
1063 `)
1064
1065 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
1066 copyCmds := apexRule.Args["copy_commands"]
1067
1068 // Ensure that main rule creates an output
1069 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
1070
1071 // Ensure that apex variant is created for the direct dep
1072 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex")
1073 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex")
1074 ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex")
1075
1076 // Ensure that both direct and indirect deps are copied into apex
1077 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
1078 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
1079 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
1080
1081 // Ensure that the platform variant ends with _core_shared
1082 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared")
1083 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared")
1084 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared")
1085}
Jiyong Park04480cf2019-02-06 00:16:29 +09001086
1087func TestApexWithShBinary(t *testing.T) {
1088 ctx := testApex(t, `
1089 apex {
1090 name: "myapex",
1091 key: "myapex.key",
1092 binaries: ["myscript"],
1093 }
1094
1095 apex_key {
1096 name: "myapex.key",
1097 public_key: "testkey.avbpubkey",
1098 private_key: "testkey.pem",
1099 }
1100
1101 sh_binary {
1102 name: "myscript",
1103 src: "mylib.cpp",
1104 filename: "myscript.sh",
1105 sub_dir: "script",
1106 }
1107 `)
1108
1109 apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule")
1110 copyCmds := apexRule.Args["copy_commands"]
1111
1112 ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh")
1113}