Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1 | // 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 | |
| 15 | package apex |
| 16 | |
| 17 | import ( |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 18 | "io/ioutil" |
| 19 | "os" |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 20 | "reflect" |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 21 | "strings" |
| 22 | "testing" |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 23 | |
| 24 | "github.com/google/blueprint/proptools" |
| 25 | |
| 26 | "android/soong/android" |
| 27 | "android/soong/cc" |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 28 | "android/soong/java" |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 29 | ) |
| 30 | |
Jaewoong Jung | 14f5ff6 | 2019-06-18 13:09:13 -0700 | [diff] [blame] | 31 | var buildDir string |
| 32 | |
Jooyung Han | d363955 | 2019-08-09 12:57:43 +0900 | [diff] [blame] | 33 | // names returns name list from white space separated string |
| 34 | func names(s string) (ns []string) { |
| 35 | for _, n := range strings.Split(s, " ") { |
| 36 | if len(n) > 0 { |
| 37 | ns = append(ns, n) |
| 38 | } |
| 39 | } |
| 40 | return |
| 41 | } |
| 42 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 43 | func testApexError(t *testing.T, pattern, bp string) { |
| 44 | ctx, config := testApexContext(t, bp) |
| 45 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 46 | if len(errs) > 0 { |
| 47 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 48 | return |
| 49 | } |
| 50 | _, errs = ctx.PrepareBuildActions(config) |
| 51 | if len(errs) > 0 { |
| 52 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | t.Fatalf("missing expected error %q (0 errors are returned)", pattern) |
| 57 | } |
| 58 | |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 59 | func testApex(t *testing.T, bp string) (*android.TestContext, android.Config) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 60 | ctx, config := testApexContext(t, bp) |
| 61 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 62 | android.FailIfErrored(t, errs) |
| 63 | _, errs = ctx.PrepareBuildActions(config) |
| 64 | android.FailIfErrored(t, errs) |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 65 | return ctx, config |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | func testApexContext(t *testing.T, bp string) (*android.TestContext, android.Config) { |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 69 | config := android.TestArchConfig(buildDir, nil) |
| 70 | config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") |
| 71 | config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") |
| 72 | config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} |
| 73 | config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q") |
| 74 | config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 75 | |
| 76 | ctx := android.NewTestArchContext() |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 77 | ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(apexBundleFactory)) |
| 78 | ctx.RegisterModuleType("apex_test", android.ModuleFactoryAdaptor(testApexBundleFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 79 | ctx.RegisterModuleType("apex_key", android.ModuleFactoryAdaptor(apexKeyFactory)) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 80 | ctx.RegisterModuleType("apex_defaults", android.ModuleFactoryAdaptor(defaultsFactory)) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 81 | ctx.RegisterModuleType("prebuilt_apex", android.ModuleFactoryAdaptor(PrebuiltFactory)) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 82 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 83 | |
| 84 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 85 | ctx.TopDown("apex_deps", apexDepsMutator) |
| 86 | ctx.BottomUp("apex", apexMutator) |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 87 | ctx.BottomUp("apex_uses", apexUsesMutator) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 88 | ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel() |
| 89 | ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 90 | }) |
| 91 | |
| 92 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory)) |
| 93 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory)) |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 94 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory)) |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 95 | ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 96 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory)) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 97 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(cc.TestFactory)) |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 98 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 99 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory)) |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 100 | ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory)) |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 101 | ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory)) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 102 | ctx.RegisterModuleType("android_app_certificate", android.ModuleFactoryAdaptor(java.AndroidAppCertificateFactory)) |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 103 | ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory)) |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 104 | ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(java.LibraryFactory)) |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 105 | ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(java.ImportFactory)) |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 106 | |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 107 | ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) { |
| 108 | ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel() |
| 109 | }) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 110 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 111 | ctx.BottomUp("image", cc.ImageMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 112 | ctx.BottomUp("link", cc.LinkageMutator).Parallel() |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 113 | ctx.BottomUp("vndk", cc.VndkMutator).Parallel() |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 114 | ctx.BottomUp("test_per_src", cc.TestPerSrcMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 115 | ctx.BottomUp("version", cc.VersionMutator).Parallel() |
| 116 | ctx.BottomUp("begin", cc.BeginMutator).Parallel() |
| 117 | }) |
| 118 | |
| 119 | ctx.Register() |
| 120 | |
| 121 | bp = bp + ` |
| 122 | toolchain_library { |
| 123 | name: "libcompiler_rt-extras", |
| 124 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 125 | vendor_available: true, |
| 126 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | toolchain_library { |
| 130 | name: "libatomic", |
| 131 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 132 | vendor_available: true, |
| 133 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | toolchain_library { |
| 137 | name: "libgcc", |
| 138 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 139 | vendor_available: true, |
| 140 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | toolchain_library { |
Yi Kong | acee27c | 2019-03-29 20:05:14 -0700 | [diff] [blame] | 144 | name: "libgcc_stripped", |
| 145 | src: "", |
| 146 | vendor_available: true, |
| 147 | recovery_available: true, |
| 148 | } |
| 149 | |
| 150 | toolchain_library { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 151 | name: "libclang_rt.builtins-aarch64-android", |
| 152 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 153 | vendor_available: true, |
| 154 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | toolchain_library { |
| 158 | name: "libclang_rt.builtins-arm-android", |
| 159 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 160 | vendor_available: true, |
| 161 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | cc_object { |
| 165 | name: "crtbegin_so", |
| 166 | stl: "none", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 167 | vendor_available: true, |
| 168 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | cc_object { |
| 172 | name: "crtend_so", |
| 173 | stl: "none", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 174 | vendor_available: true, |
| 175 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 176 | } |
| 177 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 178 | cc_object { |
| 179 | name: "crtbegin_static", |
| 180 | stl: "none", |
| 181 | } |
| 182 | |
| 183 | cc_object { |
| 184 | name: "crtend_android", |
| 185 | stl: "none", |
| 186 | } |
| 187 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 188 | llndk_library { |
| 189 | name: "libc", |
| 190 | symbol_file: "", |
| 191 | } |
| 192 | |
| 193 | llndk_library { |
| 194 | name: "libm", |
| 195 | symbol_file: "", |
| 196 | } |
| 197 | |
| 198 | llndk_library { |
| 199 | name: "libdl", |
| 200 | symbol_file: "", |
| 201 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 202 | ` |
| 203 | |
| 204 | ctx.MockFileSystem(map[string][]byte{ |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 205 | "Android.bp": []byte(bp), |
Dan Willemsen | 412160e | 2019-04-09 21:36:26 -0700 | [diff] [blame] | 206 | "build/make/target/product/security": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 207 | "apex_manifest.json": nil, |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 208 | "AndroidManifest.xml": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 209 | "system/sepolicy/apex/myapex-file_contexts": nil, |
| 210 | "system/sepolicy/apex/myapex_keytest-file_contexts": nil, |
| 211 | "system/sepolicy/apex/otherapex-file_contexts": nil, |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 212 | "system/sepolicy/apex/commonapex-file_contexts": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 213 | "mylib.cpp": nil, |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 214 | "mylib_common.cpp": nil, |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 215 | "mytest.cpp": nil, |
| 216 | "mytest1.cpp": nil, |
| 217 | "mytest2.cpp": nil, |
| 218 | "mytest3.cpp": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 219 | "myprebuilt": nil, |
| 220 | "my_include": nil, |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 221 | "foo/bar/MyClass.java": nil, |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 222 | "prebuilt.jar": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 223 | "vendor/foo/devkeys/test.x509.pem": nil, |
| 224 | "vendor/foo/devkeys/test.pk8": nil, |
| 225 | "testkey.x509.pem": nil, |
| 226 | "testkey.pk8": nil, |
| 227 | "testkey.override.x509.pem": nil, |
| 228 | "testkey.override.pk8": nil, |
| 229 | "vendor/foo/devkeys/testkey.avbpubkey": nil, |
| 230 | "vendor/foo/devkeys/testkey.pem": nil, |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 231 | "NOTICE": nil, |
| 232 | "custom_notice": nil, |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 233 | "testkey2.avbpubkey": nil, |
| 234 | "testkey2.pem": nil, |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 235 | "myapex-arm64.apex": nil, |
| 236 | "myapex-arm.apex": nil, |
Jiyong Park | 71b519d | 2019-04-18 17:25:49 +0900 | [diff] [blame] | 237 | "frameworks/base/api/current.txt": nil, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 238 | }) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 239 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 240 | return ctx, config |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 241 | } |
| 242 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 243 | func setUp() { |
| 244 | var err error |
| 245 | buildDir, err = ioutil.TempDir("", "soong_apex_test") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 246 | if err != nil { |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 247 | panic(err) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 248 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 249 | } |
| 250 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 251 | func tearDown() { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 252 | os.RemoveAll(buildDir) |
| 253 | } |
| 254 | |
| 255 | // ensure that 'result' contains 'expected' |
| 256 | func ensureContains(t *testing.T, result string, expected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 257 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 258 | if !strings.Contains(result, expected) { |
| 259 | t.Errorf("%q is not found in %q", expected, result) |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | // ensures that 'result' does not contain 'notExpected' |
| 264 | func ensureNotContains(t *testing.T, result string, notExpected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 265 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 266 | if strings.Contains(result, notExpected) { |
| 267 | t.Errorf("%q is found in %q", notExpected, result) |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | func ensureListContains(t *testing.T, result []string, expected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 272 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 273 | if !android.InList(expected, result) { |
| 274 | t.Errorf("%q is not found in %v", expected, result) |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | func ensureListNotContains(t *testing.T, result []string, notExpected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 279 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 280 | if android.InList(notExpected, result) { |
| 281 | t.Errorf("%q is found in %v", notExpected, result) |
| 282 | } |
| 283 | } |
| 284 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 285 | func ensureListEmpty(t *testing.T, result []string) { |
| 286 | t.Helper() |
| 287 | if len(result) > 0 { |
| 288 | t.Errorf("%q is expected to be empty", result) |
| 289 | } |
| 290 | } |
| 291 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 292 | // Minimal test |
| 293 | func TestBasicApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 294 | ctx, _ := testApex(t, ` |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 295 | apex_defaults { |
| 296 | name: "myapex-defaults", |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 297 | manifest: ":myapex.manifest", |
| 298 | androidManifest: ":myapex.androidmanifest", |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 299 | key: "myapex.key", |
| 300 | native_shared_libs: ["mylib"], |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 301 | multilib: { |
| 302 | both: { |
| 303 | binaries: ["foo",], |
| 304 | } |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 305 | }, |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 306 | java_libs: ["myjar", "myprebuiltjar"], |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 307 | } |
| 308 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 309 | apex { |
| 310 | name: "myapex", |
| 311 | defaults: ["myapex-defaults"], |
| 312 | } |
| 313 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 314 | apex_key { |
| 315 | name: "myapex.key", |
| 316 | public_key: "testkey.avbpubkey", |
| 317 | private_key: "testkey.pem", |
| 318 | } |
| 319 | |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 320 | filegroup { |
| 321 | name: "myapex.manifest", |
| 322 | srcs: ["apex_manifest.json"], |
| 323 | } |
| 324 | |
| 325 | filegroup { |
| 326 | name: "myapex.androidmanifest", |
| 327 | srcs: ["AndroidManifest.xml"], |
| 328 | } |
| 329 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 330 | cc_library { |
| 331 | name: "mylib", |
| 332 | srcs: ["mylib.cpp"], |
| 333 | shared_libs: ["mylib2"], |
| 334 | system_shared_libs: [], |
| 335 | stl: "none", |
| 336 | } |
| 337 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 338 | cc_binary { |
| 339 | name: "foo", |
| 340 | srcs: ["mylib.cpp"], |
| 341 | compile_multilib: "both", |
| 342 | multilib: { |
| 343 | lib32: { |
| 344 | suffix: "32", |
| 345 | }, |
| 346 | lib64: { |
| 347 | suffix: "64", |
| 348 | }, |
| 349 | }, |
| 350 | symlinks: ["foo_link_"], |
| 351 | symlink_preferred_arch: true, |
| 352 | system_shared_libs: [], |
| 353 | static_executable: true, |
| 354 | stl: "none", |
| 355 | } |
| 356 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 357 | cc_library { |
| 358 | name: "mylib2", |
| 359 | srcs: ["mylib.cpp"], |
| 360 | system_shared_libs: [], |
| 361 | stl: "none", |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 362 | notice: "custom_notice", |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 363 | } |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 364 | |
| 365 | java_library { |
| 366 | name: "myjar", |
| 367 | srcs: ["foo/bar/MyClass.java"], |
| 368 | sdk_version: "none", |
| 369 | system_modules: "none", |
| 370 | compile_dex: true, |
| 371 | static_libs: ["myotherjar"], |
| 372 | } |
| 373 | |
| 374 | java_library { |
| 375 | name: "myotherjar", |
| 376 | srcs: ["foo/bar/MyClass.java"], |
| 377 | sdk_version: "none", |
| 378 | system_modules: "none", |
| 379 | compile_dex: true, |
| 380 | } |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 381 | |
| 382 | java_import { |
| 383 | name: "myprebuiltjar", |
| 384 | jars: ["prebuilt.jar"], |
| 385 | installable: true, |
| 386 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 387 | `) |
| 388 | |
| 389 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 390 | |
| 391 | optFlags := apexRule.Args["opt_flags"] |
| 392 | ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey") |
Jaewoong Jung | 14f5ff6 | 2019-06-18 13:09:13 -0700 | [diff] [blame] | 393 | // Ensure that the NOTICE output is being packaged as an asset. |
| 394 | ensureContains(t, optFlags, "--assets_dir "+buildDir+"/.intermediates/myapex/android_common_myapex/NOTICE") |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 395 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 396 | copyCmds := apexRule.Args["copy_commands"] |
| 397 | |
| 398 | // Ensure that main rule creates an output |
| 399 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 400 | |
| 401 | // Ensure that apex variant is created for the direct dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 402 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 403 | ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_myapex") |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 404 | ensureListContains(t, ctx.ModuleVariantsForTests("myprebuiltjar"), "android_common_myapex") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 405 | |
| 406 | // Ensure that apex variant is created for the indirect dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 407 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 408 | ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common_myapex") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 409 | |
| 410 | // Ensure that both direct and indirect deps are copied into apex |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 411 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 412 | ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 413 | ensureContains(t, copyCmds, "image.apex/javalib/myjar.jar") |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 414 | ensureContains(t, copyCmds, "image.apex/javalib/myprebuiltjar.jar") |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 415 | // .. but not for java libs |
| 416 | ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar") |
Logan Chien | 3aeedc9 | 2018-12-26 15:32:21 +0800 | [diff] [blame] | 417 | |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 418 | // Ensure that the platform variant ends with _core_shared or _common |
Logan Chien | 3aeedc9 | 2018-12-26 15:32:21 +0800 | [diff] [blame] | 419 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared") |
| 420 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared") |
Jiyong Park | 7f7766d | 2019-07-25 22:02:35 +0900 | [diff] [blame] | 421 | ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common") |
| 422 | ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common") |
Jiyong Park | 9e6c242 | 2019-08-09 20:39:45 +0900 | [diff] [blame] | 423 | ensureListContains(t, ctx.ModuleVariantsForTests("myprebuiltjar"), "android_common") |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 424 | |
| 425 | // Ensure that all symlinks are present. |
| 426 | found_foo_link_64 := false |
| 427 | found_foo := false |
| 428 | for _, cmd := range strings.Split(copyCmds, " && ") { |
| 429 | if strings.HasPrefix(cmd, "ln -s foo64") { |
| 430 | if strings.HasSuffix(cmd, "bin/foo") { |
| 431 | found_foo = true |
| 432 | } else if strings.HasSuffix(cmd, "bin/foo_link_64") { |
| 433 | found_foo_link_64 = true |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | good := found_foo && found_foo_link_64 |
| 438 | if !good { |
| 439 | t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds) |
| 440 | } |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 441 | |
Jaewoong Jung | 5b425e2 | 2019-06-17 17:40:56 -0700 | [diff] [blame] | 442 | mergeNoticesRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("mergeNoticesRule") |
| 443 | noticeInputs := mergeNoticesRule.Inputs.Strings() |
Jaewoong Jung | 14f5ff6 | 2019-06-18 13:09:13 -0700 | [diff] [blame] | 444 | if len(noticeInputs) != 2 { |
| 445 | t.Errorf("number of input notice files: expected = 2, actual = %q", len(noticeInputs)) |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 446 | } |
| 447 | ensureListContains(t, noticeInputs, "NOTICE") |
| 448 | ensureListContains(t, noticeInputs, "custom_notice") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | func TestBasicZipApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 452 | ctx, _ := testApex(t, ` |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 453 | apex { |
| 454 | name: "myapex", |
| 455 | key: "myapex.key", |
| 456 | payload_type: "zip", |
| 457 | native_shared_libs: ["mylib"], |
| 458 | } |
| 459 | |
| 460 | apex_key { |
| 461 | name: "myapex.key", |
| 462 | public_key: "testkey.avbpubkey", |
| 463 | private_key: "testkey.pem", |
| 464 | } |
| 465 | |
| 466 | cc_library { |
| 467 | name: "mylib", |
| 468 | srcs: ["mylib.cpp"], |
| 469 | shared_libs: ["mylib2"], |
| 470 | system_shared_libs: [], |
| 471 | stl: "none", |
| 472 | } |
| 473 | |
| 474 | cc_library { |
| 475 | name: "mylib2", |
| 476 | srcs: ["mylib.cpp"], |
| 477 | system_shared_libs: [], |
| 478 | stl: "none", |
| 479 | } |
| 480 | `) |
| 481 | |
| 482 | zipApexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("zipApexRule") |
| 483 | copyCmds := zipApexRule.Args["copy_commands"] |
| 484 | |
| 485 | // Ensure that main rule creates an output |
| 486 | ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned") |
| 487 | |
| 488 | // Ensure that APEX variant is created for the direct dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 489 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 490 | |
| 491 | // Ensure that APEX variant is created for the indirect dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 492 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 493 | |
| 494 | // Ensure that both direct and indirect deps are copied into apex |
| 495 | ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so") |
| 496 | ensureContains(t, copyCmds, "image.zipapex/lib64/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | func TestApexWithStubs(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 500 | ctx, _ := testApex(t, ` |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 501 | apex { |
| 502 | name: "myapex", |
| 503 | key: "myapex.key", |
| 504 | native_shared_libs: ["mylib", "mylib3"], |
| 505 | } |
| 506 | |
| 507 | apex_key { |
| 508 | name: "myapex.key", |
| 509 | public_key: "testkey.avbpubkey", |
| 510 | private_key: "testkey.pem", |
| 511 | } |
| 512 | |
| 513 | cc_library { |
| 514 | name: "mylib", |
| 515 | srcs: ["mylib.cpp"], |
| 516 | shared_libs: ["mylib2", "mylib3"], |
| 517 | system_shared_libs: [], |
| 518 | stl: "none", |
| 519 | } |
| 520 | |
| 521 | cc_library { |
| 522 | name: "mylib2", |
| 523 | srcs: ["mylib.cpp"], |
Jiyong Park | 6437995 | 2018-12-13 18:37:29 +0900 | [diff] [blame] | 524 | cflags: ["-include mylib.h"], |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 525 | system_shared_libs: [], |
| 526 | stl: "none", |
| 527 | stubs: { |
| 528 | versions: ["1", "2", "3"], |
| 529 | }, |
| 530 | } |
| 531 | |
| 532 | cc_library { |
| 533 | name: "mylib3", |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 534 | srcs: ["mylib.cpp"], |
| 535 | shared_libs: ["mylib4"], |
| 536 | system_shared_libs: [], |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 537 | stl: "none", |
| 538 | stubs: { |
| 539 | versions: ["10", "11", "12"], |
| 540 | }, |
| 541 | } |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 542 | |
| 543 | cc_library { |
| 544 | name: "mylib4", |
| 545 | srcs: ["mylib.cpp"], |
| 546 | system_shared_libs: [], |
| 547 | stl: "none", |
| 548 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 549 | `) |
| 550 | |
| 551 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 552 | copyCmds := apexRule.Args["copy_commands"] |
| 553 | |
| 554 | // Ensure that direct non-stubs dep is always included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 555 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 556 | |
| 557 | // Ensure that indirect stubs dep is not included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 558 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 559 | |
| 560 | // Ensure that direct stubs dep is included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 561 | ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 562 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 563 | mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"] |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 564 | |
| 565 | // Ensure that mylib is linking with the latest version of stubs for mylib2 |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 566 | ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_3_myapex/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 567 | // ... and not linking to the non-stub (impl) variant of mylib2 |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 568 | ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_core_shared_myapex/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 569 | |
| 570 | // Ensure that mylib is linking with the non-stub (impl) of mylib3 (because mylib3 is in the same apex) |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 571 | ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_myapex/mylib3.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 572 | // .. and not linking to the stubs variant of mylib3 |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 573 | ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_core_shared_12_myapex/mylib3.so") |
Jiyong Park | 6437995 | 2018-12-13 18:37:29 +0900 | [diff] [blame] | 574 | |
| 575 | // Ensure that stubs libs are built without -include flags |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 576 | mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"] |
Jiyong Park | 6437995 | 2018-12-13 18:37:29 +0900 | [diff] [blame] | 577 | ensureNotContains(t, mylib2Cflags, "-include ") |
Jiyong Park | 3fd0baf | 2018-12-07 16:25:39 +0900 | [diff] [blame] | 578 | |
| 579 | // Ensure that genstub is invoked with --apex |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 580 | ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_core_static_3_myapex").Rule("genStubSrc").Args["flags"]) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 581 | } |
| 582 | |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 583 | func TestApexWithExplicitStubsDependency(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 584 | ctx, _ := testApex(t, ` |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 585 | apex { |
| 586 | name: "myapex", |
| 587 | key: "myapex.key", |
| 588 | native_shared_libs: ["mylib"], |
| 589 | } |
| 590 | |
| 591 | apex_key { |
| 592 | name: "myapex.key", |
| 593 | public_key: "testkey.avbpubkey", |
| 594 | private_key: "testkey.pem", |
| 595 | } |
| 596 | |
| 597 | cc_library { |
| 598 | name: "mylib", |
| 599 | srcs: ["mylib.cpp"], |
| 600 | shared_libs: ["libfoo#10"], |
| 601 | system_shared_libs: [], |
| 602 | stl: "none", |
| 603 | } |
| 604 | |
| 605 | cc_library { |
| 606 | name: "libfoo", |
| 607 | srcs: ["mylib.cpp"], |
| 608 | shared_libs: ["libbar"], |
| 609 | system_shared_libs: [], |
| 610 | stl: "none", |
| 611 | stubs: { |
| 612 | versions: ["10", "20", "30"], |
| 613 | }, |
| 614 | } |
| 615 | |
| 616 | cc_library { |
| 617 | name: "libbar", |
| 618 | srcs: ["mylib.cpp"], |
| 619 | system_shared_libs: [], |
| 620 | stl: "none", |
| 621 | } |
| 622 | |
| 623 | `) |
| 624 | |
| 625 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 626 | copyCmds := apexRule.Args["copy_commands"] |
| 627 | |
| 628 | // Ensure that direct non-stubs dep is always included |
| 629 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 630 | |
| 631 | // Ensure that indirect stubs dep is not included |
| 632 | ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so") |
| 633 | |
| 634 | // Ensure that dependency of stubs is not included |
| 635 | ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so") |
| 636 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 637 | mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"] |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 638 | |
| 639 | // Ensure that mylib is linking with version 10 of libfoo |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 640 | ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_10_myapex/libfoo.so") |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 641 | // ... and not linking to the non-stub (impl) variant of libfoo |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 642 | ensureNotContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_core_shared_myapex/libfoo.so") |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 643 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 644 | libFooStubsLdFlags := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_core_shared_10_myapex").Rule("ld").Args["libFlags"] |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 645 | |
| 646 | // Ensure that libfoo stubs is not linking to libbar (since it is a stubs) |
| 647 | ensureNotContains(t, libFooStubsLdFlags, "libbar.so") |
| 648 | } |
| 649 | |
Jooyung Han | d363955 | 2019-08-09 12:57:43 +0900 | [diff] [blame] | 650 | func TestApexWithRuntimeLibsDependency(t *testing.T) { |
| 651 | /* |
| 652 | myapex |
| 653 | | |
| 654 | v (runtime_libs) |
| 655 | mylib ------+------> libfoo [provides stub] |
| 656 | | |
| 657 | `------> libbar |
| 658 | */ |
| 659 | ctx, _ := testApex(t, ` |
| 660 | apex { |
| 661 | name: "myapex", |
| 662 | key: "myapex.key", |
| 663 | native_shared_libs: ["mylib"], |
| 664 | } |
| 665 | |
| 666 | apex_key { |
| 667 | name: "myapex.key", |
| 668 | public_key: "testkey.avbpubkey", |
| 669 | private_key: "testkey.pem", |
| 670 | } |
| 671 | |
| 672 | cc_library { |
| 673 | name: "mylib", |
| 674 | srcs: ["mylib.cpp"], |
| 675 | runtime_libs: ["libfoo", "libbar"], |
| 676 | system_shared_libs: [], |
| 677 | stl: "none", |
| 678 | } |
| 679 | |
| 680 | cc_library { |
| 681 | name: "libfoo", |
| 682 | srcs: ["mylib.cpp"], |
| 683 | system_shared_libs: [], |
| 684 | stl: "none", |
| 685 | stubs: { |
| 686 | versions: ["10", "20", "30"], |
| 687 | }, |
| 688 | } |
| 689 | |
| 690 | cc_library { |
| 691 | name: "libbar", |
| 692 | srcs: ["mylib.cpp"], |
| 693 | system_shared_libs: [], |
| 694 | stl: "none", |
| 695 | } |
| 696 | |
| 697 | `) |
| 698 | |
| 699 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 700 | copyCmds := apexRule.Args["copy_commands"] |
| 701 | |
| 702 | // Ensure that direct non-stubs dep is always included |
| 703 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 704 | |
| 705 | // Ensure that indirect stubs dep is not included |
| 706 | ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so") |
| 707 | |
| 708 | // Ensure that runtime_libs dep in included |
| 709 | ensureContains(t, copyCmds, "image.apex/lib64/libbar.so") |
| 710 | |
| 711 | injectRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("injectApexDependency") |
| 712 | ensureListEmpty(t, names(injectRule.Args["provideNativeLibs"])) |
| 713 | ensureListContains(t, names(injectRule.Args["requireNativeLibs"]), "libfoo.so") |
| 714 | |
| 715 | } |
| 716 | |
Jooyung Han | 9c80bae | 2019-08-20 17:30:57 +0900 | [diff] [blame] | 717 | func TestApexDependencyToLLNDK(t *testing.T) { |
| 718 | ctx, _ := testApex(t, ` |
| 719 | apex { |
| 720 | name: "myapex", |
| 721 | key: "myapex.key", |
| 722 | use_vendor: true, |
| 723 | native_shared_libs: ["mylib"], |
| 724 | } |
| 725 | |
| 726 | apex_key { |
| 727 | name: "myapex.key", |
| 728 | public_key: "testkey.avbpubkey", |
| 729 | private_key: "testkey.pem", |
| 730 | } |
| 731 | |
| 732 | cc_library { |
| 733 | name: "mylib", |
| 734 | srcs: ["mylib.cpp"], |
| 735 | vendor_available: true, |
| 736 | shared_libs: ["libbar"], |
| 737 | system_shared_libs: [], |
| 738 | stl: "none", |
| 739 | } |
| 740 | |
| 741 | cc_library { |
| 742 | name: "libbar", |
| 743 | srcs: ["mylib.cpp"], |
| 744 | system_shared_libs: [], |
| 745 | stl: "none", |
| 746 | } |
| 747 | |
| 748 | llndk_library { |
| 749 | name: "libbar", |
| 750 | symbol_file: "", |
| 751 | } |
| 752 | |
| 753 | `) |
| 754 | |
| 755 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 756 | copyCmds := apexRule.Args["copy_commands"] |
| 757 | |
| 758 | // Ensure that LLNDK dep is not included |
| 759 | ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so") |
| 760 | |
| 761 | injectRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("injectApexDependency") |
| 762 | ensureListEmpty(t, names(injectRule.Args["provideNativeLibs"])) |
| 763 | |
| 764 | // Ensure that LLNDK dep is required |
| 765 | ensureListContains(t, names(injectRule.Args["requireNativeLibs"]), "libbar.so") |
| 766 | |
| 767 | } |
| 768 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 769 | func TestApexWithSystemLibsStubs(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 770 | ctx, _ := testApex(t, ` |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 771 | apex { |
| 772 | name: "myapex", |
| 773 | key: "myapex.key", |
| 774 | native_shared_libs: ["mylib", "mylib_shared", "libdl", "libm"], |
| 775 | } |
| 776 | |
| 777 | apex_key { |
| 778 | name: "myapex.key", |
| 779 | public_key: "testkey.avbpubkey", |
| 780 | private_key: "testkey.pem", |
| 781 | } |
| 782 | |
| 783 | cc_library { |
| 784 | name: "mylib", |
| 785 | srcs: ["mylib.cpp"], |
| 786 | shared_libs: ["libdl#27"], |
| 787 | stl: "none", |
| 788 | } |
| 789 | |
| 790 | cc_library_shared { |
| 791 | name: "mylib_shared", |
| 792 | srcs: ["mylib.cpp"], |
| 793 | shared_libs: ["libdl#27"], |
| 794 | stl: "none", |
| 795 | } |
| 796 | |
| 797 | cc_library { |
| 798 | name: "libc", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 799 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 800 | nocrt: true, |
| 801 | system_shared_libs: [], |
| 802 | stl: "none", |
| 803 | stubs: { |
| 804 | versions: ["27", "28", "29"], |
| 805 | }, |
| 806 | } |
| 807 | |
| 808 | cc_library { |
| 809 | name: "libm", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 810 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 811 | nocrt: true, |
| 812 | system_shared_libs: [], |
| 813 | stl: "none", |
| 814 | stubs: { |
| 815 | versions: ["27", "28", "29"], |
| 816 | }, |
| 817 | } |
| 818 | |
| 819 | cc_library { |
| 820 | name: "libdl", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 821 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 822 | nocrt: true, |
| 823 | system_shared_libs: [], |
| 824 | stl: "none", |
| 825 | stubs: { |
| 826 | versions: ["27", "28", "29"], |
| 827 | }, |
| 828 | } |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 829 | |
| 830 | cc_library { |
| 831 | name: "libBootstrap", |
| 832 | srcs: ["mylib.cpp"], |
| 833 | stl: "none", |
| 834 | bootstrap: true, |
| 835 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 836 | `) |
| 837 | |
| 838 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 839 | copyCmds := apexRule.Args["copy_commands"] |
| 840 | |
| 841 | // Ensure that mylib, libm, libdl are included. |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 842 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 843 | ensureContains(t, copyCmds, "image.apex/lib64/bionic/libm.so") |
| 844 | ensureContains(t, copyCmds, "image.apex/lib64/bionic/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 845 | |
| 846 | // Ensure that libc is not included (since it has stubs and not listed in native_shared_libs) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 847 | ensureNotContains(t, copyCmds, "image.apex/lib64/bionic/libc.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 848 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 849 | mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"] |
| 850 | mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"] |
| 851 | mylibSharedCFlags := ctx.ModuleForTests("mylib_shared", "android_arm64_armv8-a_core_shared_myapex").Rule("cc").Args["cFlags"] |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 852 | |
| 853 | // For dependency to libc |
| 854 | // Ensure that mylib is linking with the latest version of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 855 | ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_29_myapex/libc.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 856 | // ... and not linking to the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 857 | ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_core_shared_myapex/libc.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 858 | // ... Cflags from stub is correctly exported to mylib |
| 859 | ensureContains(t, mylibCFlags, "__LIBC_API__=29") |
| 860 | ensureContains(t, mylibSharedCFlags, "__LIBC_API__=29") |
| 861 | |
| 862 | // For dependency to libm |
| 863 | // Ensure that mylib is linking with the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 864 | ensureContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_myapex/libm.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 865 | // ... and not linking to the stub variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 866 | ensureNotContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_core_shared_29_myapex/libm.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 867 | // ... and is not compiling with the stub |
| 868 | ensureNotContains(t, mylibCFlags, "__LIBM_API__=29") |
| 869 | ensureNotContains(t, mylibSharedCFlags, "__LIBM_API__=29") |
| 870 | |
| 871 | // For dependency to libdl |
| 872 | // Ensure that mylib is linking with the specified version of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 873 | ensureContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_27_myapex/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 874 | // ... and not linking to the other versions of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 875 | ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_28_myapex/libdl.so") |
| 876 | ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_29_myapex/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 877 | // ... and not linking to the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 878 | ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_myapex/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 879 | // ... Cflags from stub is correctly exported to mylib |
| 880 | ensureContains(t, mylibCFlags, "__LIBDL_API__=27") |
| 881 | ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 882 | |
| 883 | // Ensure that libBootstrap is depending on the platform variant of bionic libs |
| 884 | libFlags := ctx.ModuleForTests("libBootstrap", "android_arm64_armv8-a_core_shared").Rule("ld").Args["libFlags"] |
| 885 | ensureContains(t, libFlags, "libc/android_arm64_armv8-a_core_shared/libc.so") |
| 886 | ensureContains(t, libFlags, "libm/android_arm64_armv8-a_core_shared/libm.so") |
| 887 | ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_core_shared/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 888 | } |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 889 | |
| 890 | func TestFilesInSubDir(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 891 | ctx, _ := testApex(t, ` |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 892 | apex { |
| 893 | name: "myapex", |
| 894 | key: "myapex.key", |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 895 | native_shared_libs: ["mylib"], |
| 896 | binaries: ["mybin"], |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 897 | prebuilts: ["myetc"], |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 898 | compile_multilib: "both", |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | apex_key { |
| 902 | name: "myapex.key", |
| 903 | public_key: "testkey.avbpubkey", |
| 904 | private_key: "testkey.pem", |
| 905 | } |
| 906 | |
| 907 | prebuilt_etc { |
| 908 | name: "myetc", |
| 909 | src: "myprebuilt", |
| 910 | sub_dir: "foo/bar", |
| 911 | } |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 912 | |
| 913 | cc_library { |
| 914 | name: "mylib", |
| 915 | srcs: ["mylib.cpp"], |
| 916 | relative_install_path: "foo/bar", |
| 917 | system_shared_libs: [], |
| 918 | stl: "none", |
| 919 | } |
| 920 | |
| 921 | cc_binary { |
| 922 | name: "mybin", |
| 923 | srcs: ["mylib.cpp"], |
| 924 | relative_install_path: "foo/bar", |
| 925 | system_shared_libs: [], |
| 926 | static_executable: true, |
| 927 | stl: "none", |
| 928 | } |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 929 | `) |
| 930 | |
| 931 | generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") |
| 932 | dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") |
| 933 | |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 934 | // Ensure that the subdirectories are all listed |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 935 | ensureListContains(t, dirs, "etc") |
| 936 | ensureListContains(t, dirs, "etc/foo") |
| 937 | ensureListContains(t, dirs, "etc/foo/bar") |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 938 | ensureListContains(t, dirs, "lib64") |
| 939 | ensureListContains(t, dirs, "lib64/foo") |
| 940 | ensureListContains(t, dirs, "lib64/foo/bar") |
| 941 | ensureListContains(t, dirs, "lib") |
| 942 | ensureListContains(t, dirs, "lib/foo") |
| 943 | ensureListContains(t, dirs, "lib/foo/bar") |
| 944 | |
Jiyong Park | bd13e44 | 2019-03-15 18:10:35 +0900 | [diff] [blame] | 945 | ensureListContains(t, dirs, "bin") |
| 946 | ensureListContains(t, dirs, "bin/foo") |
| 947 | ensureListContains(t, dirs, "bin/foo/bar") |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 948 | } |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 949 | |
| 950 | func TestUseVendor(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 951 | ctx, _ := testApex(t, ` |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 952 | apex { |
| 953 | name: "myapex", |
| 954 | key: "myapex.key", |
| 955 | native_shared_libs: ["mylib"], |
| 956 | use_vendor: true, |
| 957 | } |
| 958 | |
| 959 | apex_key { |
| 960 | name: "myapex.key", |
| 961 | public_key: "testkey.avbpubkey", |
| 962 | private_key: "testkey.pem", |
| 963 | } |
| 964 | |
| 965 | cc_library { |
| 966 | name: "mylib", |
| 967 | srcs: ["mylib.cpp"], |
| 968 | shared_libs: ["mylib2"], |
| 969 | system_shared_libs: [], |
| 970 | vendor_available: true, |
| 971 | stl: "none", |
| 972 | } |
| 973 | |
| 974 | cc_library { |
| 975 | name: "mylib2", |
| 976 | srcs: ["mylib.cpp"], |
| 977 | system_shared_libs: [], |
| 978 | vendor_available: true, |
| 979 | stl: "none", |
| 980 | } |
| 981 | `) |
| 982 | |
| 983 | inputsList := []string{} |
| 984 | for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex").Module().BuildParamsForTests() { |
| 985 | for _, implicit := range i.Implicits { |
| 986 | inputsList = append(inputsList, implicit.String()) |
| 987 | } |
| 988 | } |
| 989 | inputsString := strings.Join(inputsList, " ") |
| 990 | |
| 991 | // ensure that the apex includes vendor variants of the direct and indirect deps |
| 992 | ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib.so") |
| 993 | ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib2.so") |
| 994 | |
| 995 | // ensure that the apex does not include core variants |
| 996 | ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib.so") |
| 997 | ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib2.so") |
| 998 | } |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 999 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1000 | func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) { |
| 1001 | testApexError(t, `dependency "mylib" of "myapex" missing variant:\n.*image:vendor`, ` |
| 1002 | apex { |
| 1003 | name: "myapex", |
| 1004 | key: "myapex.key", |
| 1005 | native_shared_libs: ["mylib"], |
| 1006 | use_vendor: true, |
| 1007 | } |
| 1008 | |
| 1009 | apex_key { |
| 1010 | name: "myapex.key", |
| 1011 | public_key: "testkey.avbpubkey", |
| 1012 | private_key: "testkey.pem", |
| 1013 | } |
| 1014 | |
| 1015 | cc_library { |
| 1016 | name: "mylib", |
| 1017 | srcs: ["mylib.cpp"], |
| 1018 | system_shared_libs: [], |
| 1019 | stl: "none", |
| 1020 | } |
| 1021 | `) |
| 1022 | } |
| 1023 | |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 1024 | func TestStaticLinking(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1025 | ctx, _ := testApex(t, ` |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 1026 | apex { |
| 1027 | name: "myapex", |
| 1028 | key: "myapex.key", |
| 1029 | native_shared_libs: ["mylib"], |
| 1030 | } |
| 1031 | |
| 1032 | apex_key { |
| 1033 | name: "myapex.key", |
| 1034 | public_key: "testkey.avbpubkey", |
| 1035 | private_key: "testkey.pem", |
| 1036 | } |
| 1037 | |
| 1038 | cc_library { |
| 1039 | name: "mylib", |
| 1040 | srcs: ["mylib.cpp"], |
| 1041 | system_shared_libs: [], |
| 1042 | stl: "none", |
| 1043 | stubs: { |
| 1044 | versions: ["1", "2", "3"], |
| 1045 | }, |
| 1046 | } |
| 1047 | |
| 1048 | cc_binary { |
| 1049 | name: "not_in_apex", |
| 1050 | srcs: ["mylib.cpp"], |
| 1051 | static_libs: ["mylib"], |
| 1052 | static_executable: true, |
| 1053 | system_shared_libs: [], |
| 1054 | stl: "none", |
| 1055 | } |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 1056 | `) |
| 1057 | |
| 1058 | ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"] |
| 1059 | |
| 1060 | // Ensure that not_in_apex is linking with the static variant of mylib |
Logan Chien | 3aeedc9 | 2018-12-26 15:32:21 +0800 | [diff] [blame] | 1061 | ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_core_static/mylib.a") |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 1062 | } |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1063 | |
| 1064 | func TestKeys(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1065 | ctx, _ := testApex(t, ` |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1066 | apex { |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1067 | name: "myapex_keytest", |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1068 | key: "myapex.key", |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1069 | certificate: ":myapex.certificate", |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1070 | native_shared_libs: ["mylib"], |
| 1071 | } |
| 1072 | |
| 1073 | cc_library { |
| 1074 | name: "mylib", |
| 1075 | srcs: ["mylib.cpp"], |
| 1076 | system_shared_libs: [], |
| 1077 | stl: "none", |
| 1078 | } |
| 1079 | |
| 1080 | apex_key { |
| 1081 | name: "myapex.key", |
| 1082 | public_key: "testkey.avbpubkey", |
| 1083 | private_key: "testkey.pem", |
| 1084 | } |
| 1085 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1086 | android_app_certificate { |
| 1087 | name: "myapex.certificate", |
| 1088 | certificate: "testkey", |
| 1089 | } |
| 1090 | |
| 1091 | android_app_certificate { |
| 1092 | name: "myapex.certificate.override", |
| 1093 | certificate: "testkey.override", |
| 1094 | } |
| 1095 | |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1096 | `) |
| 1097 | |
| 1098 | // check the APEX keys |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1099 | keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1100 | |
| 1101 | if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" { |
| 1102 | t.Errorf("public key %q is not %q", keys.public_key_file.String(), |
| 1103 | "vendor/foo/devkeys/testkey.avbpubkey") |
| 1104 | } |
| 1105 | if keys.private_key_file.String() != "vendor/foo/devkeys/testkey.pem" { |
| 1106 | t.Errorf("private key %q is not %q", keys.private_key_file.String(), |
| 1107 | "vendor/foo/devkeys/testkey.pem") |
| 1108 | } |
| 1109 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1110 | // check the APK certs. It should be overridden to myapex.certificate.override |
| 1111 | certs := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest").Rule("signapk").Args["certificates"] |
| 1112 | if certs != "testkey.override.x509.pem testkey.override.pk8" { |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1113 | t.Errorf("cert and private key %q are not %q", certs, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 1114 | "testkey.override.509.pem testkey.override.pk8") |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 1115 | } |
| 1116 | } |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 1117 | |
| 1118 | func TestMacro(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1119 | ctx, _ := testApex(t, ` |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 1120 | apex { |
| 1121 | name: "myapex", |
| 1122 | key: "myapex.key", |
| 1123 | native_shared_libs: ["mylib"], |
| 1124 | } |
| 1125 | |
| 1126 | apex { |
| 1127 | name: "otherapex", |
| 1128 | key: "myapex.key", |
| 1129 | native_shared_libs: ["mylib"], |
| 1130 | } |
| 1131 | |
| 1132 | apex_key { |
| 1133 | name: "myapex.key", |
| 1134 | public_key: "testkey.avbpubkey", |
| 1135 | private_key: "testkey.pem", |
| 1136 | } |
| 1137 | |
| 1138 | cc_library { |
| 1139 | name: "mylib", |
| 1140 | srcs: ["mylib.cpp"], |
| 1141 | system_shared_libs: [], |
| 1142 | stl: "none", |
| 1143 | } |
| 1144 | `) |
| 1145 | |
| 1146 | // non-APEX variant does not have __ANDROID__APEX__ defined |
| 1147 | mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"] |
| 1148 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 1149 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 1150 | |
| 1151 | // APEX variant has __ANDROID_APEX__=<apexname> defined |
| 1152 | mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"] |
| 1153 | ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 1154 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 1155 | |
| 1156 | // APEX variant has __ANDROID_APEX__=<apexname> defined |
| 1157 | mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_otherapex").Rule("cc").Args["cFlags"] |
| 1158 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 1159 | ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 1160 | } |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1161 | |
| 1162 | func TestHeaderLibsDependency(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1163 | ctx, _ := testApex(t, ` |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1164 | apex { |
| 1165 | name: "myapex", |
| 1166 | key: "myapex.key", |
| 1167 | native_shared_libs: ["mylib"], |
| 1168 | } |
| 1169 | |
| 1170 | apex_key { |
| 1171 | name: "myapex.key", |
| 1172 | public_key: "testkey.avbpubkey", |
| 1173 | private_key: "testkey.pem", |
| 1174 | } |
| 1175 | |
| 1176 | cc_library_headers { |
| 1177 | name: "mylib_headers", |
| 1178 | export_include_dirs: ["my_include"], |
| 1179 | system_shared_libs: [], |
| 1180 | stl: "none", |
| 1181 | } |
| 1182 | |
| 1183 | cc_library { |
| 1184 | name: "mylib", |
| 1185 | srcs: ["mylib.cpp"], |
| 1186 | system_shared_libs: [], |
| 1187 | stl: "none", |
| 1188 | header_libs: ["mylib_headers"], |
| 1189 | export_header_lib_headers: ["mylib_headers"], |
| 1190 | stubs: { |
| 1191 | versions: ["1", "2", "3"], |
| 1192 | }, |
| 1193 | } |
| 1194 | |
| 1195 | cc_library { |
| 1196 | name: "otherlib", |
| 1197 | srcs: ["mylib.cpp"], |
| 1198 | system_shared_libs: [], |
| 1199 | stl: "none", |
| 1200 | shared_libs: ["mylib"], |
| 1201 | } |
| 1202 | `) |
| 1203 | |
| 1204 | cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"] |
| 1205 | |
| 1206 | // Ensure that the include path of the header lib is exported to 'otherlib' |
| 1207 | ensureContains(t, cFlags, "-Imy_include") |
| 1208 | } |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1209 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1210 | func TestDependenciesInApexManifest(t *testing.T) { |
| 1211 | ctx, _ := testApex(t, ` |
| 1212 | apex { |
| 1213 | name: "myapex_nodep", |
| 1214 | key: "myapex.key", |
| 1215 | native_shared_libs: ["lib_nodep"], |
| 1216 | compile_multilib: "both", |
| 1217 | file_contexts: "myapex", |
| 1218 | } |
| 1219 | |
| 1220 | apex { |
| 1221 | name: "myapex_dep", |
| 1222 | key: "myapex.key", |
| 1223 | native_shared_libs: ["lib_dep"], |
| 1224 | compile_multilib: "both", |
| 1225 | file_contexts: "myapex", |
| 1226 | } |
| 1227 | |
| 1228 | apex { |
| 1229 | name: "myapex_provider", |
| 1230 | key: "myapex.key", |
| 1231 | native_shared_libs: ["libfoo"], |
| 1232 | compile_multilib: "both", |
| 1233 | file_contexts: "myapex", |
| 1234 | } |
| 1235 | |
| 1236 | apex { |
| 1237 | name: "myapex_selfcontained", |
| 1238 | key: "myapex.key", |
| 1239 | native_shared_libs: ["lib_dep", "libfoo"], |
| 1240 | compile_multilib: "both", |
| 1241 | file_contexts: "myapex", |
| 1242 | } |
| 1243 | |
| 1244 | apex_key { |
| 1245 | name: "myapex.key", |
| 1246 | public_key: "testkey.avbpubkey", |
| 1247 | private_key: "testkey.pem", |
| 1248 | } |
| 1249 | |
| 1250 | cc_library { |
| 1251 | name: "lib_nodep", |
| 1252 | srcs: ["mylib.cpp"], |
| 1253 | system_shared_libs: [], |
| 1254 | stl: "none", |
| 1255 | } |
| 1256 | |
| 1257 | cc_library { |
| 1258 | name: "lib_dep", |
| 1259 | srcs: ["mylib.cpp"], |
| 1260 | shared_libs: ["libfoo"], |
| 1261 | system_shared_libs: [], |
| 1262 | stl: "none", |
| 1263 | } |
| 1264 | |
| 1265 | cc_library { |
| 1266 | name: "libfoo", |
| 1267 | srcs: ["mytest.cpp"], |
| 1268 | stubs: { |
| 1269 | versions: ["1"], |
| 1270 | }, |
| 1271 | system_shared_libs: [], |
| 1272 | stl: "none", |
| 1273 | } |
| 1274 | `) |
| 1275 | |
Jooyung Han | e163303 | 2019-08-01 17:41:43 +0900 | [diff] [blame] | 1276 | var injectRule android.TestingBuildParams |
| 1277 | var provideNativeLibs, requireNativeLibs []string |
| 1278 | |
| 1279 | injectRule = ctx.ModuleForTests("myapex_nodep", "android_common_myapex_nodep").Rule("injectApexDependency") |
| 1280 | provideNativeLibs = names(injectRule.Args["provideNativeLibs"]) |
| 1281 | requireNativeLibs = names(injectRule.Args["requireNativeLibs"]) |
| 1282 | ensureListEmpty(t, provideNativeLibs) |
| 1283 | ensureListEmpty(t, requireNativeLibs) |
| 1284 | |
| 1285 | injectRule = ctx.ModuleForTests("myapex_dep", "android_common_myapex_dep").Rule("injectApexDependency") |
| 1286 | provideNativeLibs = names(injectRule.Args["provideNativeLibs"]) |
| 1287 | requireNativeLibs = names(injectRule.Args["requireNativeLibs"]) |
| 1288 | ensureListEmpty(t, provideNativeLibs) |
| 1289 | ensureListContains(t, requireNativeLibs, "libfoo.so") |
| 1290 | |
| 1291 | injectRule = ctx.ModuleForTests("myapex_provider", "android_common_myapex_provider").Rule("injectApexDependency") |
| 1292 | provideNativeLibs = names(injectRule.Args["provideNativeLibs"]) |
| 1293 | requireNativeLibs = names(injectRule.Args["requireNativeLibs"]) |
| 1294 | ensureListContains(t, provideNativeLibs, "libfoo.so") |
| 1295 | ensureListEmpty(t, requireNativeLibs) |
| 1296 | |
| 1297 | injectRule = ctx.ModuleForTests("myapex_selfcontained", "android_common_myapex_selfcontained").Rule("injectApexDependency") |
| 1298 | provideNativeLibs = names(injectRule.Args["provideNativeLibs"]) |
| 1299 | requireNativeLibs = names(injectRule.Args["requireNativeLibs"]) |
| 1300 | ensureListContains(t, provideNativeLibs, "libfoo.so") |
| 1301 | ensureListEmpty(t, requireNativeLibs) |
| 1302 | } |
| 1303 | |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1304 | func TestNonTestApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1305 | ctx, _ := testApex(t, ` |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1306 | apex { |
| 1307 | name: "myapex", |
| 1308 | key: "myapex.key", |
| 1309 | native_shared_libs: ["mylib_common"], |
| 1310 | } |
| 1311 | |
| 1312 | apex_key { |
| 1313 | name: "myapex.key", |
| 1314 | public_key: "testkey.avbpubkey", |
| 1315 | private_key: "testkey.pem", |
| 1316 | } |
| 1317 | |
| 1318 | cc_library { |
| 1319 | name: "mylib_common", |
| 1320 | srcs: ["mylib.cpp"], |
| 1321 | system_shared_libs: [], |
| 1322 | stl: "none", |
| 1323 | } |
| 1324 | `) |
| 1325 | |
| 1326 | module := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1327 | apexRule := module.Rule("apexRule") |
| 1328 | copyCmds := apexRule.Args["copy_commands"] |
| 1329 | |
| 1330 | if apex, ok := module.Module().(*apexBundle); !ok || apex.testApex { |
| 1331 | t.Log("Apex was a test apex!") |
| 1332 | t.Fail() |
| 1333 | } |
| 1334 | // Ensure that main rule creates an output |
| 1335 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1336 | |
| 1337 | // Ensure that apex variant is created for the direct dep |
| 1338 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex") |
| 1339 | |
| 1340 | // Ensure that both direct and indirect deps are copied into apex |
| 1341 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so") |
| 1342 | |
| 1343 | // Ensure that the platform variant ends with _core_shared |
| 1344 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared") |
| 1345 | |
| 1346 | if !android.InAnyApex("mylib_common") { |
| 1347 | t.Log("Found mylib_common not in any apex!") |
| 1348 | t.Fail() |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | func TestTestApex(t *testing.T) { |
| 1353 | if android.InAnyApex("mylib_common_test") { |
| 1354 | 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!") |
| 1355 | } |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1356 | ctx, _ := testApex(t, ` |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1357 | apex_test { |
| 1358 | name: "myapex", |
| 1359 | key: "myapex.key", |
| 1360 | native_shared_libs: ["mylib_common_test"], |
| 1361 | } |
| 1362 | |
| 1363 | apex_key { |
| 1364 | name: "myapex.key", |
| 1365 | public_key: "testkey.avbpubkey", |
| 1366 | private_key: "testkey.pem", |
| 1367 | } |
| 1368 | |
| 1369 | cc_library { |
| 1370 | name: "mylib_common_test", |
| 1371 | srcs: ["mylib.cpp"], |
| 1372 | system_shared_libs: [], |
| 1373 | stl: "none", |
| 1374 | } |
| 1375 | `) |
| 1376 | |
| 1377 | module := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1378 | apexRule := module.Rule("apexRule") |
| 1379 | copyCmds := apexRule.Args["copy_commands"] |
| 1380 | |
| 1381 | if apex, ok := module.Module().(*apexBundle); !ok || !apex.testApex { |
| 1382 | t.Log("Apex was not a test apex!") |
| 1383 | t.Fail() |
| 1384 | } |
| 1385 | // Ensure that main rule creates an output |
| 1386 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1387 | |
| 1388 | // Ensure that apex variant is created for the direct dep |
| 1389 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared_myapex") |
| 1390 | |
| 1391 | // Ensure that both direct and indirect deps are copied into apex |
| 1392 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common_test.so") |
| 1393 | |
| 1394 | // Ensure that the platform variant ends with _core_shared |
| 1395 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared") |
| 1396 | |
| 1397 | if android.InAnyApex("mylib_common_test") { |
| 1398 | t.Log("Found mylib_common_test in some apex!") |
| 1399 | t.Fail() |
| 1400 | } |
| 1401 | } |
| 1402 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1403 | func TestApexWithTarget(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1404 | ctx, _ := testApex(t, ` |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1405 | apex { |
| 1406 | name: "myapex", |
| 1407 | key: "myapex.key", |
| 1408 | multilib: { |
| 1409 | first: { |
| 1410 | native_shared_libs: ["mylib_common"], |
| 1411 | } |
| 1412 | }, |
| 1413 | target: { |
| 1414 | android: { |
| 1415 | multilib: { |
| 1416 | first: { |
| 1417 | native_shared_libs: ["mylib"], |
| 1418 | } |
| 1419 | } |
| 1420 | }, |
| 1421 | host: { |
| 1422 | multilib: { |
| 1423 | first: { |
| 1424 | native_shared_libs: ["mylib2"], |
| 1425 | } |
| 1426 | } |
| 1427 | } |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | apex_key { |
| 1432 | name: "myapex.key", |
| 1433 | public_key: "testkey.avbpubkey", |
| 1434 | private_key: "testkey.pem", |
| 1435 | } |
| 1436 | |
| 1437 | cc_library { |
| 1438 | name: "mylib", |
| 1439 | srcs: ["mylib.cpp"], |
| 1440 | system_shared_libs: [], |
| 1441 | stl: "none", |
| 1442 | } |
| 1443 | |
| 1444 | cc_library { |
| 1445 | name: "mylib_common", |
| 1446 | srcs: ["mylib.cpp"], |
| 1447 | system_shared_libs: [], |
| 1448 | stl: "none", |
| 1449 | compile_multilib: "first", |
| 1450 | } |
| 1451 | |
| 1452 | cc_library { |
| 1453 | name: "mylib2", |
| 1454 | srcs: ["mylib.cpp"], |
| 1455 | system_shared_libs: [], |
| 1456 | stl: "none", |
| 1457 | compile_multilib: "first", |
| 1458 | } |
| 1459 | `) |
| 1460 | |
| 1461 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1462 | copyCmds := apexRule.Args["copy_commands"] |
| 1463 | |
| 1464 | // Ensure that main rule creates an output |
| 1465 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1466 | |
| 1467 | // Ensure that apex variant is created for the direct dep |
| 1468 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
| 1469 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex") |
| 1470 | ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
| 1471 | |
| 1472 | // Ensure that both direct and indirect deps are copied into apex |
| 1473 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 1474 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so") |
| 1475 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
| 1476 | |
| 1477 | // Ensure that the platform variant ends with _core_shared |
| 1478 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared") |
| 1479 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared") |
| 1480 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared") |
| 1481 | } |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1482 | |
| 1483 | func TestApexWithShBinary(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1484 | ctx, _ := testApex(t, ` |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1485 | apex { |
| 1486 | name: "myapex", |
| 1487 | key: "myapex.key", |
| 1488 | binaries: ["myscript"], |
| 1489 | } |
| 1490 | |
| 1491 | apex_key { |
| 1492 | name: "myapex.key", |
| 1493 | public_key: "testkey.avbpubkey", |
| 1494 | private_key: "testkey.pem", |
| 1495 | } |
| 1496 | |
| 1497 | sh_binary { |
| 1498 | name: "myscript", |
| 1499 | src: "mylib.cpp", |
| 1500 | filename: "myscript.sh", |
| 1501 | sub_dir: "script", |
| 1502 | } |
| 1503 | `) |
| 1504 | |
| 1505 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1506 | copyCmds := apexRule.Args["copy_commands"] |
| 1507 | |
| 1508 | ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh") |
| 1509 | } |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1510 | |
| 1511 | func TestApexInProductPartition(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1512 | ctx, _ := testApex(t, ` |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1513 | apex { |
| 1514 | name: "myapex", |
| 1515 | key: "myapex.key", |
| 1516 | native_shared_libs: ["mylib"], |
| 1517 | product_specific: true, |
| 1518 | } |
| 1519 | |
| 1520 | apex_key { |
| 1521 | name: "myapex.key", |
| 1522 | public_key: "testkey.avbpubkey", |
| 1523 | private_key: "testkey.pem", |
| 1524 | product_specific: true, |
| 1525 | } |
| 1526 | |
| 1527 | cc_library { |
| 1528 | name: "mylib", |
| 1529 | srcs: ["mylib.cpp"], |
| 1530 | system_shared_libs: [], |
| 1531 | stl: "none", |
| 1532 | } |
| 1533 | `) |
| 1534 | |
| 1535 | apex := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) |
| 1536 | expected := "target/product/test_device/product/apex" |
| 1537 | actual := apex.installDir.RelPathString() |
| 1538 | if actual != expected { |
| 1539 | t.Errorf("wrong install path. expected %q. actual %q", expected, actual) |
| 1540 | } |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1541 | } |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 1542 | |
| 1543 | func TestApexKeyFromOtherModule(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1544 | ctx, _ := testApex(t, ` |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 1545 | apex_key { |
| 1546 | name: "myapex.key", |
| 1547 | public_key: ":my.avbpubkey", |
| 1548 | private_key: ":my.pem", |
| 1549 | product_specific: true, |
| 1550 | } |
| 1551 | |
| 1552 | filegroup { |
| 1553 | name: "my.avbpubkey", |
| 1554 | srcs: ["testkey2.avbpubkey"], |
| 1555 | } |
| 1556 | |
| 1557 | filegroup { |
| 1558 | name: "my.pem", |
| 1559 | srcs: ["testkey2.pem"], |
| 1560 | } |
| 1561 | `) |
| 1562 | |
| 1563 | apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) |
| 1564 | expected_pubkey := "testkey2.avbpubkey" |
| 1565 | actual_pubkey := apex_key.public_key_file.String() |
| 1566 | if actual_pubkey != expected_pubkey { |
| 1567 | t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey) |
| 1568 | } |
| 1569 | expected_privkey := "testkey2.pem" |
| 1570 | actual_privkey := apex_key.private_key_file.String() |
| 1571 | if actual_privkey != expected_privkey { |
| 1572 | t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey) |
| 1573 | } |
| 1574 | } |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1575 | |
| 1576 | func TestPrebuilt(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1577 | ctx, _ := testApex(t, ` |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1578 | prebuilt_apex { |
| 1579 | name: "myapex", |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 1580 | arch: { |
| 1581 | arm64: { |
| 1582 | src: "myapex-arm64.apex", |
| 1583 | }, |
| 1584 | arm: { |
| 1585 | src: "myapex-arm.apex", |
| 1586 | }, |
| 1587 | }, |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1588 | } |
| 1589 | `) |
| 1590 | |
| 1591 | prebuilt := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) |
| 1592 | |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 1593 | expectedInput := "myapex-arm64.apex" |
| 1594 | if prebuilt.inputApex.String() != expectedInput { |
| 1595 | t.Errorf("inputApex invalid. expected: %q, actual: %q", expectedInput, prebuilt.inputApex.String()) |
| 1596 | } |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1597 | } |
Nikita Ioffe | 7a41ebd | 2019-04-04 18:09:48 +0100 | [diff] [blame] | 1598 | |
| 1599 | func TestPrebuiltFilenameOverride(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1600 | ctx, _ := testApex(t, ` |
Nikita Ioffe | 7a41ebd | 2019-04-04 18:09:48 +0100 | [diff] [blame] | 1601 | prebuilt_apex { |
| 1602 | name: "myapex", |
| 1603 | src: "myapex-arm.apex", |
| 1604 | filename: "notmyapex.apex", |
| 1605 | } |
| 1606 | `) |
| 1607 | |
| 1608 | p := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) |
| 1609 | |
| 1610 | expected := "notmyapex.apex" |
| 1611 | if p.installFilename != expected { |
| 1612 | t.Errorf("installFilename invalid. expected: %q, actual: %q", expected, p.installFilename) |
| 1613 | } |
| 1614 | } |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 1615 | |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1616 | func TestPrebuiltOverrides(t *testing.T) { |
| 1617 | ctx, config := testApex(t, ` |
| 1618 | prebuilt_apex { |
| 1619 | name: "myapex.prebuilt", |
| 1620 | src: "myapex-arm.apex", |
| 1621 | overrides: [ |
| 1622 | "myapex", |
| 1623 | ], |
| 1624 | } |
| 1625 | `) |
| 1626 | |
| 1627 | p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt) |
| 1628 | |
| 1629 | expected := []string{"myapex"} |
| 1630 | actual := android.AndroidMkEntriesForTest(t, config, "", p).EntryMap["LOCAL_OVERRIDES_PACKAGES"] |
| 1631 | if !reflect.DeepEqual(actual, expected) { |
| 1632 | t.Errorf("Incorrect LOCAL_OVERRIDES_PACKAGES value '%s', expected '%s'", actual, expected) |
| 1633 | } |
| 1634 | } |
| 1635 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1636 | func TestApexWithTests(t *testing.T) { |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1637 | ctx, config := testApex(t, ` |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1638 | apex_test { |
| 1639 | name: "myapex", |
| 1640 | key: "myapex.key", |
| 1641 | tests: [ |
| 1642 | "mytest", |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1643 | "mytests", |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1644 | ], |
| 1645 | } |
| 1646 | |
| 1647 | apex_key { |
| 1648 | name: "myapex.key", |
| 1649 | public_key: "testkey.avbpubkey", |
| 1650 | private_key: "testkey.pem", |
| 1651 | } |
| 1652 | |
| 1653 | cc_test { |
| 1654 | name: "mytest", |
| 1655 | gtest: false, |
| 1656 | srcs: ["mytest.cpp"], |
| 1657 | relative_install_path: "test", |
| 1658 | system_shared_libs: [], |
| 1659 | static_executable: true, |
| 1660 | stl: "none", |
| 1661 | } |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1662 | |
| 1663 | cc_test { |
| 1664 | name: "mytests", |
| 1665 | gtest: false, |
| 1666 | srcs: [ |
| 1667 | "mytest1.cpp", |
| 1668 | "mytest2.cpp", |
| 1669 | "mytest3.cpp", |
| 1670 | ], |
| 1671 | test_per_src: true, |
| 1672 | relative_install_path: "test", |
| 1673 | system_shared_libs: [], |
| 1674 | static_executable: true, |
| 1675 | stl: "none", |
| 1676 | } |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1677 | `) |
| 1678 | |
| 1679 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1680 | copyCmds := apexRule.Args["copy_commands"] |
| 1681 | |
| 1682 | // Ensure that test dep is copied into apex. |
| 1683 | ensureContains(t, copyCmds, "image.apex/bin/test/mytest") |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1684 | |
| 1685 | // Ensure that test deps built with `test_per_src` are copied into apex. |
| 1686 | ensureContains(t, copyCmds, "image.apex/bin/test/mytest1") |
| 1687 | ensureContains(t, copyCmds, "image.apex/bin/test/mytest2") |
| 1688 | ensureContains(t, copyCmds, "image.apex/bin/test/mytest3") |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1689 | |
| 1690 | // Ensure the module is correctly translated. |
| 1691 | apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) |
| 1692 | data := android.AndroidMkDataForTest(t, config, "", apexBundle) |
| 1693 | name := apexBundle.BaseModuleName() |
| 1694 | prefix := "TARGET_" |
| 1695 | var builder strings.Builder |
| 1696 | data.Custom(&builder, name, prefix, "", data) |
| 1697 | androidMk := builder.String() |
| 1698 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest\n") |
| 1699 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest1\n") |
| 1700 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest2\n") |
| 1701 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.mytest3\n") |
| 1702 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.apex_manifest.json\n") |
| 1703 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex.apex_pubkey\n") |
| 1704 | ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n") |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1705 | } |
| 1706 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1707 | func TestApexUsesOtherApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame] | 1708 | ctx, _ := testApex(t, ` |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1709 | apex { |
| 1710 | name: "myapex", |
| 1711 | key: "myapex.key", |
| 1712 | native_shared_libs: ["mylib"], |
| 1713 | uses: ["commonapex"], |
| 1714 | } |
| 1715 | |
| 1716 | apex { |
| 1717 | name: "commonapex", |
| 1718 | key: "myapex.key", |
| 1719 | native_shared_libs: ["libcommon"], |
| 1720 | provide_cpp_shared_libs: true, |
| 1721 | } |
| 1722 | |
| 1723 | apex_key { |
| 1724 | name: "myapex.key", |
| 1725 | public_key: "testkey.avbpubkey", |
| 1726 | private_key: "testkey.pem", |
| 1727 | } |
| 1728 | |
| 1729 | cc_library { |
| 1730 | name: "mylib", |
| 1731 | srcs: ["mylib.cpp"], |
| 1732 | shared_libs: ["libcommon"], |
| 1733 | system_shared_libs: [], |
| 1734 | stl: "none", |
| 1735 | } |
| 1736 | |
| 1737 | cc_library { |
| 1738 | name: "libcommon", |
| 1739 | srcs: ["mylib_common.cpp"], |
| 1740 | system_shared_libs: [], |
| 1741 | stl: "none", |
| 1742 | } |
| 1743 | `) |
| 1744 | |
| 1745 | module1 := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1746 | apexRule1 := module1.Rule("apexRule") |
| 1747 | copyCmds1 := apexRule1.Args["copy_commands"] |
| 1748 | |
| 1749 | module2 := ctx.ModuleForTests("commonapex", "android_common_commonapex") |
| 1750 | apexRule2 := module2.Rule("apexRule") |
| 1751 | copyCmds2 := apexRule2.Args["copy_commands"] |
| 1752 | |
| 1753 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
| 1754 | ensureListContains(t, ctx.ModuleVariantsForTests("libcommon"), "android_arm64_armv8-a_core_shared_commonapex") |
| 1755 | ensureContains(t, copyCmds1, "image.apex/lib64/mylib.so") |
| 1756 | ensureContains(t, copyCmds2, "image.apex/lib64/libcommon.so") |
| 1757 | ensureNotContains(t, copyCmds1, "image.apex/lib64/libcommon.so") |
| 1758 | } |
| 1759 | |
| 1760 | func TestApexUsesFailsIfNotProvided(t *testing.T) { |
| 1761 | testApexError(t, `uses: "commonapex" does not provide native_shared_libs`, ` |
| 1762 | apex { |
| 1763 | name: "myapex", |
| 1764 | key: "myapex.key", |
| 1765 | uses: ["commonapex"], |
| 1766 | } |
| 1767 | |
| 1768 | apex { |
| 1769 | name: "commonapex", |
| 1770 | key: "myapex.key", |
| 1771 | } |
| 1772 | |
| 1773 | apex_key { |
| 1774 | name: "myapex.key", |
| 1775 | public_key: "testkey.avbpubkey", |
| 1776 | private_key: "testkey.pem", |
| 1777 | } |
| 1778 | `) |
| 1779 | testApexError(t, `uses: "commonapex" is not a provider`, ` |
| 1780 | apex { |
| 1781 | name: "myapex", |
| 1782 | key: "myapex.key", |
| 1783 | uses: ["commonapex"], |
| 1784 | } |
| 1785 | |
| 1786 | cc_library { |
| 1787 | name: "commonapex", |
| 1788 | system_shared_libs: [], |
| 1789 | stl: "none", |
| 1790 | } |
| 1791 | |
| 1792 | apex_key { |
| 1793 | name: "myapex.key", |
| 1794 | public_key: "testkey.avbpubkey", |
| 1795 | private_key: "testkey.pem", |
| 1796 | } |
| 1797 | `) |
| 1798 | } |
| 1799 | |
| 1800 | func TestApexUsesFailsIfUseVenderMismatch(t *testing.T) { |
| 1801 | testApexError(t, `use_vendor: "commonapex" has different value of use_vendor`, ` |
| 1802 | apex { |
| 1803 | name: "myapex", |
| 1804 | key: "myapex.key", |
| 1805 | use_vendor: true, |
| 1806 | uses: ["commonapex"], |
| 1807 | } |
| 1808 | |
| 1809 | apex { |
| 1810 | name: "commonapex", |
| 1811 | key: "myapex.key", |
| 1812 | provide_cpp_shared_libs: true, |
| 1813 | } |
| 1814 | |
| 1815 | apex_key { |
| 1816 | name: "myapex.key", |
| 1817 | public_key: "testkey.avbpubkey", |
| 1818 | private_key: "testkey.pem", |
| 1819 | } |
| 1820 | `) |
| 1821 | } |
| 1822 | |
Jiyong Park | 4f7dd9b | 2019-08-12 10:37:49 +0900 | [diff] [blame] | 1823 | func TestApexUsesFailsIfUseNoApex(t *testing.T) { |
| 1824 | testApexError(t, `tries to include no_apex module mylib2`, ` |
| 1825 | apex { |
| 1826 | name: "commonapex", |
| 1827 | key: "myapex.key", |
| 1828 | native_shared_libs: ["mylib"], |
| 1829 | } |
| 1830 | |
| 1831 | apex_key { |
| 1832 | name: "myapex.key", |
| 1833 | public_key: "testkey.avbpubkey", |
| 1834 | private_key: "testkey.pem", |
| 1835 | } |
| 1836 | |
| 1837 | cc_library { |
| 1838 | name: "mylib", |
| 1839 | srcs: ["mylib.cpp"], |
| 1840 | shared_libs: ["mylib2"], |
| 1841 | system_shared_libs: [], |
| 1842 | stl: "none", |
| 1843 | } |
| 1844 | |
| 1845 | cc_library { |
| 1846 | name: "mylib2", |
| 1847 | srcs: ["mylib.cpp"], |
| 1848 | system_shared_libs: [], |
| 1849 | stl: "none", |
| 1850 | no_apex: true, |
| 1851 | } |
| 1852 | `) |
| 1853 | |
Sundong Ahn | 2db7f46 | 2019-08-27 18:53:12 +0900 | [diff] [blame] | 1854 | testApexError(t, `tries to include no_apex module mylib2`, ` |
| 1855 | apex { |
| 1856 | name: "commonapex", |
| 1857 | key: "myapex.key", |
| 1858 | native_shared_libs: ["mylib"], |
| 1859 | } |
| 1860 | |
| 1861 | apex_key { |
| 1862 | name: "myapex.key", |
| 1863 | public_key: "testkey.avbpubkey", |
| 1864 | private_key: "testkey.pem", |
| 1865 | } |
| 1866 | |
| 1867 | cc_library { |
| 1868 | name: "mylib", |
| 1869 | srcs: ["mylib.cpp"], |
| 1870 | static_libs: ["mylib2"], |
| 1871 | system_shared_libs: [], |
| 1872 | stl: "none", |
| 1873 | } |
| 1874 | |
| 1875 | cc_library { |
| 1876 | name: "mylib2", |
| 1877 | srcs: ["mylib.cpp"], |
| 1878 | system_shared_libs: [], |
| 1879 | stl: "none", |
| 1880 | no_apex: true, |
| 1881 | } |
| 1882 | `) |
| 1883 | |
Jiyong Park | 4f7dd9b | 2019-08-12 10:37:49 +0900 | [diff] [blame] | 1884 | ctx, _ := testApex(t, ` |
| 1885 | apex { |
| 1886 | name: "myapex", |
| 1887 | key: "myapex.key", |
| 1888 | native_shared_libs: ["mylib"], |
| 1889 | } |
| 1890 | |
| 1891 | apex_key { |
| 1892 | name: "myapex.key", |
| 1893 | public_key: "testkey.avbpubkey", |
| 1894 | private_key: "testkey.pem", |
| 1895 | } |
| 1896 | |
| 1897 | cc_library { |
| 1898 | name: "mylib", |
| 1899 | srcs: ["mylib.cpp"], |
| 1900 | shared_libs: ["mylib2"], |
| 1901 | system_shared_libs: [], |
| 1902 | stl: "none", |
| 1903 | } |
| 1904 | |
| 1905 | cc_library { |
| 1906 | name: "mylib2", |
| 1907 | srcs: ["mylib.cpp"], |
| 1908 | shared_libs: ["mylib3"], |
| 1909 | system_shared_libs: [], |
| 1910 | stl: "none", |
| 1911 | stubs: { |
| 1912 | versions: ["1", "2", "3"], |
| 1913 | }, |
| 1914 | } |
| 1915 | |
| 1916 | cc_library { |
| 1917 | name: "mylib3", |
| 1918 | srcs: ["mylib.cpp"], |
| 1919 | system_shared_libs: [], |
| 1920 | stl: "none", |
| 1921 | no_apex: true, |
| 1922 | } |
| 1923 | `) |
| 1924 | |
| 1925 | module := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1926 | apexRule := module.Rule("apexRule") |
| 1927 | copyCmds := apexRule.Args["copy_commands"] |
| 1928 | |
| 1929 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 1930 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
| 1931 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib3.so") |
| 1932 | |
| 1933 | } |
| 1934 | |
Jooyung Han | d48f3c3 | 2019-08-23 11:18:57 +0900 | [diff] [blame] | 1935 | func TestErrorsIfDepsAreNotEnabled(t *testing.T) { |
| 1936 | testApexError(t, `module "myapex" .* depends on disabled module "libfoo"`, ` |
| 1937 | apex { |
| 1938 | name: "myapex", |
| 1939 | key: "myapex.key", |
| 1940 | native_shared_libs: ["libfoo"], |
| 1941 | } |
| 1942 | |
| 1943 | apex_key { |
| 1944 | name: "myapex.key", |
| 1945 | public_key: "testkey.avbpubkey", |
| 1946 | private_key: "testkey.pem", |
| 1947 | } |
| 1948 | |
| 1949 | cc_library { |
| 1950 | name: "libfoo", |
| 1951 | stl: "none", |
| 1952 | system_shared_libs: [], |
| 1953 | enabled: false, |
| 1954 | } |
| 1955 | `) |
| 1956 | testApexError(t, `module "myapex" .* depends on disabled module "myjar"`, ` |
| 1957 | apex { |
| 1958 | name: "myapex", |
| 1959 | key: "myapex.key", |
| 1960 | java_libs: ["myjar"], |
| 1961 | } |
| 1962 | |
| 1963 | apex_key { |
| 1964 | name: "myapex.key", |
| 1965 | public_key: "testkey.avbpubkey", |
| 1966 | private_key: "testkey.pem", |
| 1967 | } |
| 1968 | |
| 1969 | java_library { |
| 1970 | name: "myjar", |
| 1971 | srcs: ["foo/bar/MyClass.java"], |
| 1972 | sdk_version: "none", |
| 1973 | system_modules: "none", |
| 1974 | compile_dex: true, |
| 1975 | enabled: false, |
| 1976 | } |
| 1977 | `) |
| 1978 | } |
| 1979 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 1980 | func TestMain(m *testing.M) { |
| 1981 | run := func() int { |
| 1982 | setUp() |
| 1983 | defer tearDown() |
| 1984 | |
| 1985 | return m.Run() |
| 1986 | } |
| 1987 | |
| 1988 | os.Exit(run()) |
| 1989 | } |