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 | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 33 | func testApexError(t *testing.T, pattern, bp string) { |
| 34 | ctx, config := testApexContext(t, bp) |
| 35 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 36 | if len(errs) > 0 { |
| 37 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 38 | return |
| 39 | } |
| 40 | _, errs = ctx.PrepareBuildActions(config) |
| 41 | if len(errs) > 0 { |
| 42 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | t.Fatalf("missing expected error %q (0 errors are returned)", pattern) |
| 47 | } |
| 48 | |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 49 | func testApex(t *testing.T, bp string) (*android.TestContext, android.Config) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 50 | ctx, config := testApexContext(t, bp) |
| 51 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 52 | android.FailIfErrored(t, errs) |
| 53 | _, errs = ctx.PrepareBuildActions(config) |
| 54 | android.FailIfErrored(t, errs) |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 55 | return ctx, config |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | func testApexContext(t *testing.T, bp string) (*android.TestContext, android.Config) { |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 59 | config := android.TestArchConfig(buildDir, nil) |
| 60 | config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") |
| 61 | config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") |
| 62 | config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} |
| 63 | config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q") |
| 64 | config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 65 | |
| 66 | ctx := android.NewTestArchContext() |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 67 | ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(apexBundleFactory)) |
| 68 | ctx.RegisterModuleType("apex_test", android.ModuleFactoryAdaptor(testApexBundleFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 69 | ctx.RegisterModuleType("apex_key", android.ModuleFactoryAdaptor(apexKeyFactory)) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 70 | ctx.RegisterModuleType("apex_defaults", android.ModuleFactoryAdaptor(defaultsFactory)) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 71 | ctx.RegisterModuleType("prebuilt_apex", android.ModuleFactoryAdaptor(PrebuiltFactory)) |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 72 | ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 73 | |
| 74 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 75 | ctx.TopDown("apex_deps", apexDepsMutator) |
| 76 | ctx.BottomUp("apex", apexMutator) |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 77 | ctx.BottomUp("apex_uses", apexUsesMutator) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 78 | ctx.TopDown("prebuilt_select", android.PrebuiltSelectModuleMutator).Parallel() |
| 79 | ctx.BottomUp("prebuilt_postdeps", android.PrebuiltPostDepsMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 80 | }) |
| 81 | |
| 82 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory)) |
| 83 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory)) |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 84 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory)) |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 85 | ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 86 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory)) |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 87 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(cc.TestFactory)) |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 88 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory)) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 89 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc.ToolchainLibraryFactory)) |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 90 | ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory)) |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 91 | ctx.RegisterModuleType("sh_binary", android.ModuleFactoryAdaptor(android.ShBinaryFactory)) |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 92 | ctx.RegisterModuleType("android_app_certificate", android.ModuleFactoryAdaptor(java.AndroidAppCertificateFactory)) |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 93 | ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory)) |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 94 | ctx.PreArchMutators(func(ctx android.RegisterMutatorsContext) { |
| 95 | ctx.BottomUp("prebuilts", android.PrebuiltMutator).Parallel() |
| 96 | }) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 97 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 98 | ctx.BottomUp("image", cc.ImageMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 99 | ctx.BottomUp("link", cc.LinkageMutator).Parallel() |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 100 | ctx.BottomUp("vndk", cc.VndkMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 101 | ctx.BottomUp("version", cc.VersionMutator).Parallel() |
| 102 | ctx.BottomUp("begin", cc.BeginMutator).Parallel() |
| 103 | }) |
| 104 | |
| 105 | ctx.Register() |
| 106 | |
| 107 | bp = bp + ` |
| 108 | toolchain_library { |
| 109 | name: "libcompiler_rt-extras", |
| 110 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 111 | vendor_available: true, |
| 112 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | toolchain_library { |
| 116 | name: "libatomic", |
| 117 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 118 | vendor_available: true, |
| 119 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | toolchain_library { |
| 123 | name: "libgcc", |
| 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 { |
Yi Kong | acee27c | 2019-03-29 20:05:14 -0700 | [diff] [blame] | 130 | name: "libgcc_stripped", |
| 131 | src: "", |
| 132 | vendor_available: true, |
| 133 | recovery_available: true, |
| 134 | } |
| 135 | |
| 136 | toolchain_library { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 137 | name: "libclang_rt.builtins-aarch64-android", |
| 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 { |
| 144 | name: "libclang_rt.builtins-arm-android", |
| 145 | src: "", |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 146 | vendor_available: true, |
| 147 | recovery_available: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | cc_object { |
| 151 | name: "crtbegin_so", |
| 152 | stl: "none", |
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 | cc_object { |
| 158 | name: "crtend_so", |
| 159 | stl: "none", |
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 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 164 | cc_object { |
| 165 | name: "crtbegin_static", |
| 166 | stl: "none", |
| 167 | } |
| 168 | |
| 169 | cc_object { |
| 170 | name: "crtend_android", |
| 171 | stl: "none", |
| 172 | } |
| 173 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 174 | llndk_library { |
| 175 | name: "libc", |
| 176 | symbol_file: "", |
| 177 | } |
| 178 | |
| 179 | llndk_library { |
| 180 | name: "libm", |
| 181 | symbol_file: "", |
| 182 | } |
| 183 | |
| 184 | llndk_library { |
| 185 | name: "libdl", |
| 186 | symbol_file: "", |
| 187 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 188 | ` |
| 189 | |
| 190 | ctx.MockFileSystem(map[string][]byte{ |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 191 | "Android.bp": []byte(bp), |
Dan Willemsen | 412160e | 2019-04-09 21:36:26 -0700 | [diff] [blame] | 192 | "build/make/target/product/security": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 193 | "apex_manifest.json": nil, |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 194 | "AndroidManifest.xml": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 195 | "system/sepolicy/apex/myapex-file_contexts": nil, |
| 196 | "system/sepolicy/apex/myapex_keytest-file_contexts": nil, |
| 197 | "system/sepolicy/apex/otherapex-file_contexts": nil, |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 198 | "system/sepolicy/apex/commonapex-file_contexts": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 199 | "mylib.cpp": nil, |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 200 | "mytest.cpp": nil, |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 201 | "mylib_common.cpp": nil, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 202 | "myprebuilt": nil, |
| 203 | "my_include": nil, |
| 204 | "vendor/foo/devkeys/test.x509.pem": nil, |
| 205 | "vendor/foo/devkeys/test.pk8": nil, |
| 206 | "testkey.x509.pem": nil, |
| 207 | "testkey.pk8": nil, |
| 208 | "testkey.override.x509.pem": nil, |
| 209 | "testkey.override.pk8": nil, |
| 210 | "vendor/foo/devkeys/testkey.avbpubkey": nil, |
| 211 | "vendor/foo/devkeys/testkey.pem": nil, |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 212 | "NOTICE": nil, |
| 213 | "custom_notice": nil, |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 214 | "testkey2.avbpubkey": nil, |
| 215 | "testkey2.pem": nil, |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 216 | "myapex-arm64.apex": nil, |
| 217 | "myapex-arm.apex": nil, |
Jiyong Park | 71b519d | 2019-04-18 17:25:49 +0900 | [diff] [blame] | 218 | "frameworks/base/api/current.txt": nil, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 219 | }) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 220 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 221 | return ctx, config |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 222 | } |
| 223 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 224 | func setUp() { |
| 225 | var err error |
| 226 | buildDir, err = ioutil.TempDir("", "soong_apex_test") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 227 | if err != nil { |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 228 | panic(err) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 229 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 230 | } |
| 231 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 232 | func tearDown() { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 233 | os.RemoveAll(buildDir) |
| 234 | } |
| 235 | |
| 236 | // ensure that 'result' contains 'expected' |
| 237 | func ensureContains(t *testing.T, result string, expected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 238 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 239 | if !strings.Contains(result, expected) { |
| 240 | t.Errorf("%q is not found in %q", expected, result) |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | // ensures that 'result' does not contain 'notExpected' |
| 245 | func ensureNotContains(t *testing.T, result string, notExpected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 246 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 247 | if strings.Contains(result, notExpected) { |
| 248 | t.Errorf("%q is found in %q", notExpected, result) |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | func ensureListContains(t *testing.T, result []string, expected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 253 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 254 | if !android.InList(expected, result) { |
| 255 | t.Errorf("%q is not found in %v", expected, result) |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | func ensureListNotContains(t *testing.T, result []string, notExpected string) { |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 260 | t.Helper() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 261 | if android.InList(notExpected, result) { |
| 262 | t.Errorf("%q is found in %v", notExpected, result) |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // Minimal test |
| 267 | func TestBasicApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 268 | ctx, _ := testApex(t, ` |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 269 | apex_defaults { |
| 270 | name: "myapex-defaults", |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 271 | manifest: ":myapex.manifest", |
| 272 | androidManifest: ":myapex.androidmanifest", |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 273 | key: "myapex.key", |
| 274 | native_shared_libs: ["mylib"], |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 275 | multilib: { |
| 276 | both: { |
| 277 | binaries: ["foo",], |
| 278 | } |
| 279 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 280 | } |
| 281 | |
Jiyong Park | 30ca937 | 2019-02-07 16:27:23 +0900 | [diff] [blame] | 282 | apex { |
| 283 | name: "myapex", |
| 284 | defaults: ["myapex-defaults"], |
| 285 | } |
| 286 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 287 | apex_key { |
| 288 | name: "myapex.key", |
| 289 | public_key: "testkey.avbpubkey", |
| 290 | private_key: "testkey.pem", |
| 291 | } |
| 292 | |
Jiyong Park | 809bb72 | 2019-02-13 21:33:49 +0900 | [diff] [blame] | 293 | filegroup { |
| 294 | name: "myapex.manifest", |
| 295 | srcs: ["apex_manifest.json"], |
| 296 | } |
| 297 | |
| 298 | filegroup { |
| 299 | name: "myapex.androidmanifest", |
| 300 | srcs: ["AndroidManifest.xml"], |
| 301 | } |
| 302 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 303 | cc_library { |
| 304 | name: "mylib", |
| 305 | srcs: ["mylib.cpp"], |
| 306 | shared_libs: ["mylib2"], |
| 307 | system_shared_libs: [], |
| 308 | stl: "none", |
| 309 | } |
| 310 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 311 | cc_binary { |
| 312 | name: "foo", |
| 313 | srcs: ["mylib.cpp"], |
| 314 | compile_multilib: "both", |
| 315 | multilib: { |
| 316 | lib32: { |
| 317 | suffix: "32", |
| 318 | }, |
| 319 | lib64: { |
| 320 | suffix: "64", |
| 321 | }, |
| 322 | }, |
| 323 | symlinks: ["foo_link_"], |
| 324 | symlink_preferred_arch: true, |
| 325 | system_shared_libs: [], |
| 326 | static_executable: true, |
| 327 | stl: "none", |
| 328 | } |
| 329 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 330 | cc_library { |
| 331 | name: "mylib2", |
| 332 | srcs: ["mylib.cpp"], |
| 333 | system_shared_libs: [], |
| 334 | stl: "none", |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 335 | notice: "custom_notice", |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 336 | } |
| 337 | `) |
| 338 | |
| 339 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 340 | |
| 341 | optFlags := apexRule.Args["opt_flags"] |
| 342 | ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey") |
Jaewoong Jung | 14f5ff6 | 2019-06-18 13:09:13 -0700 | [diff] [blame] | 343 | // Ensure that the NOTICE output is being packaged as an asset. |
| 344 | ensureContains(t, optFlags, "--assets_dir "+buildDir+"/.intermediates/myapex/android_common_myapex/NOTICE") |
Jiyong Park | 42cca6c | 2019-04-01 11:15:50 +0900 | [diff] [blame] | 345 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 346 | copyCmds := apexRule.Args["copy_commands"] |
| 347 | |
| 348 | // Ensure that main rule creates an output |
| 349 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 350 | |
| 351 | // Ensure that apex variant is created for the direct dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 352 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 353 | |
| 354 | // Ensure that apex variant is created for the indirect dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 355 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 356 | |
| 357 | // Ensure that both direct and indirect deps are copied into apex |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 358 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 359 | ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
Logan Chien | 3aeedc9 | 2018-12-26 15:32:21 +0800 | [diff] [blame] | 360 | |
| 361 | // Ensure that the platform variant ends with _core_shared |
| 362 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared") |
| 363 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared") |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 364 | |
| 365 | // Ensure that all symlinks are present. |
| 366 | found_foo_link_64 := false |
| 367 | found_foo := false |
| 368 | for _, cmd := range strings.Split(copyCmds, " && ") { |
| 369 | if strings.HasPrefix(cmd, "ln -s foo64") { |
| 370 | if strings.HasSuffix(cmd, "bin/foo") { |
| 371 | found_foo = true |
| 372 | } else if strings.HasSuffix(cmd, "bin/foo_link_64") { |
| 373 | found_foo_link_64 = true |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | good := found_foo && found_foo_link_64 |
| 378 | if !good { |
| 379 | t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds) |
| 380 | } |
Jiyong Park | 52818fc | 2019-03-18 12:01:38 +0900 | [diff] [blame] | 381 | |
Jaewoong Jung | 5b425e2 | 2019-06-17 17:40:56 -0700 | [diff] [blame] | 382 | mergeNoticesRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("mergeNoticesRule") |
| 383 | noticeInputs := mergeNoticesRule.Inputs.Strings() |
Jaewoong Jung | 14f5ff6 | 2019-06-18 13:09:13 -0700 | [diff] [blame] | 384 | if len(noticeInputs) != 2 { |
| 385 | 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] | 386 | } |
| 387 | ensureListContains(t, noticeInputs, "NOTICE") |
| 388 | ensureListContains(t, noticeInputs, "custom_notice") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | func TestBasicZipApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 392 | ctx, _ := testApex(t, ` |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 393 | apex { |
| 394 | name: "myapex", |
| 395 | key: "myapex.key", |
| 396 | payload_type: "zip", |
| 397 | native_shared_libs: ["mylib"], |
| 398 | } |
| 399 | |
| 400 | apex_key { |
| 401 | name: "myapex.key", |
| 402 | public_key: "testkey.avbpubkey", |
| 403 | private_key: "testkey.pem", |
| 404 | } |
| 405 | |
| 406 | cc_library { |
| 407 | name: "mylib", |
| 408 | srcs: ["mylib.cpp"], |
| 409 | shared_libs: ["mylib2"], |
| 410 | system_shared_libs: [], |
| 411 | stl: "none", |
| 412 | } |
| 413 | |
| 414 | cc_library { |
| 415 | name: "mylib2", |
| 416 | srcs: ["mylib.cpp"], |
| 417 | system_shared_libs: [], |
| 418 | stl: "none", |
| 419 | } |
| 420 | `) |
| 421 | |
| 422 | zipApexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("zipApexRule") |
| 423 | copyCmds := zipApexRule.Args["copy_commands"] |
| 424 | |
| 425 | // Ensure that main rule creates an output |
| 426 | ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned") |
| 427 | |
| 428 | // Ensure that APEX variant is created for the direct dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 429 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 430 | |
| 431 | // Ensure that APEX variant is created for the indirect dep |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 432 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 433 | |
| 434 | // Ensure that both direct and indirect deps are copied into apex |
| 435 | ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so") |
| 436 | ensureContains(t, copyCmds, "image.zipapex/lib64/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | func TestApexWithStubs(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 440 | ctx, _ := testApex(t, ` |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 441 | apex { |
| 442 | name: "myapex", |
| 443 | key: "myapex.key", |
| 444 | native_shared_libs: ["mylib", "mylib3"], |
| 445 | } |
| 446 | |
| 447 | apex_key { |
| 448 | name: "myapex.key", |
| 449 | public_key: "testkey.avbpubkey", |
| 450 | private_key: "testkey.pem", |
| 451 | } |
| 452 | |
| 453 | cc_library { |
| 454 | name: "mylib", |
| 455 | srcs: ["mylib.cpp"], |
| 456 | shared_libs: ["mylib2", "mylib3"], |
| 457 | system_shared_libs: [], |
| 458 | stl: "none", |
| 459 | } |
| 460 | |
| 461 | cc_library { |
| 462 | name: "mylib2", |
| 463 | srcs: ["mylib.cpp"], |
Jiyong Park | 6437995 | 2018-12-13 18:37:29 +0900 | [diff] [blame] | 464 | cflags: ["-include mylib.h"], |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 465 | system_shared_libs: [], |
| 466 | stl: "none", |
| 467 | stubs: { |
| 468 | versions: ["1", "2", "3"], |
| 469 | }, |
| 470 | } |
| 471 | |
| 472 | cc_library { |
| 473 | name: "mylib3", |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 474 | srcs: ["mylib.cpp"], |
| 475 | shared_libs: ["mylib4"], |
| 476 | system_shared_libs: [], |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 477 | stl: "none", |
| 478 | stubs: { |
| 479 | versions: ["10", "11", "12"], |
| 480 | }, |
| 481 | } |
Jiyong Park | 28d395a | 2018-12-07 22:42:47 +0900 | [diff] [blame] | 482 | |
| 483 | cc_library { |
| 484 | name: "mylib4", |
| 485 | srcs: ["mylib.cpp"], |
| 486 | system_shared_libs: [], |
| 487 | stl: "none", |
| 488 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 489 | `) |
| 490 | |
| 491 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 492 | copyCmds := apexRule.Args["copy_commands"] |
| 493 | |
| 494 | // Ensure that direct non-stubs dep is always included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 495 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 496 | |
| 497 | // Ensure that indirect stubs dep is not included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 498 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 499 | |
| 500 | // Ensure that direct stubs dep is included |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 501 | ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 502 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 503 | 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] | 504 | |
| 505 | // 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] | 506 | 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] | 507 | // ... and not linking to the non-stub (impl) variant of mylib2 |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 508 | 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] | 509 | |
| 510 | // 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] | 511 | 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] | 512 | // .. and not linking to the stubs variant of mylib3 |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 513 | 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] | 514 | |
| 515 | // Ensure that stubs libs are built without -include flags |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 516 | 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] | 517 | ensureNotContains(t, mylib2Cflags, "-include ") |
Jiyong Park | 3fd0baf | 2018-12-07 16:25:39 +0900 | [diff] [blame] | 518 | |
| 519 | // Ensure that genstub is invoked with --apex |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 520 | 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] | 521 | } |
| 522 | |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 523 | func TestApexWithExplicitStubsDependency(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 524 | ctx, _ := testApex(t, ` |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 525 | apex { |
| 526 | name: "myapex", |
| 527 | key: "myapex.key", |
| 528 | native_shared_libs: ["mylib"], |
| 529 | } |
| 530 | |
| 531 | apex_key { |
| 532 | name: "myapex.key", |
| 533 | public_key: "testkey.avbpubkey", |
| 534 | private_key: "testkey.pem", |
| 535 | } |
| 536 | |
| 537 | cc_library { |
| 538 | name: "mylib", |
| 539 | srcs: ["mylib.cpp"], |
| 540 | shared_libs: ["libfoo#10"], |
| 541 | system_shared_libs: [], |
| 542 | stl: "none", |
| 543 | } |
| 544 | |
| 545 | cc_library { |
| 546 | name: "libfoo", |
| 547 | srcs: ["mylib.cpp"], |
| 548 | shared_libs: ["libbar"], |
| 549 | system_shared_libs: [], |
| 550 | stl: "none", |
| 551 | stubs: { |
| 552 | versions: ["10", "20", "30"], |
| 553 | }, |
| 554 | } |
| 555 | |
| 556 | cc_library { |
| 557 | name: "libbar", |
| 558 | srcs: ["mylib.cpp"], |
| 559 | system_shared_libs: [], |
| 560 | stl: "none", |
| 561 | } |
| 562 | |
| 563 | `) |
| 564 | |
| 565 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 566 | copyCmds := apexRule.Args["copy_commands"] |
| 567 | |
| 568 | // Ensure that direct non-stubs dep is always included |
| 569 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 570 | |
| 571 | // Ensure that indirect stubs dep is not included |
| 572 | ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so") |
| 573 | |
| 574 | // Ensure that dependency of stubs is not included |
| 575 | ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so") |
| 576 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 577 | 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] | 578 | |
| 579 | // Ensure that mylib is linking with version 10 of libfoo |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 580 | 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] | 581 | // ... and not linking to the non-stub (impl) variant of libfoo |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 582 | 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] | 583 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 584 | 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] | 585 | |
| 586 | // Ensure that libfoo stubs is not linking to libbar (since it is a stubs) |
| 587 | ensureNotContains(t, libFooStubsLdFlags, "libbar.so") |
| 588 | } |
| 589 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 590 | func TestApexWithSystemLibsStubs(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 591 | ctx, _ := testApex(t, ` |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 592 | apex { |
| 593 | name: "myapex", |
| 594 | key: "myapex.key", |
| 595 | native_shared_libs: ["mylib", "mylib_shared", "libdl", "libm"], |
| 596 | } |
| 597 | |
| 598 | apex_key { |
| 599 | name: "myapex.key", |
| 600 | public_key: "testkey.avbpubkey", |
| 601 | private_key: "testkey.pem", |
| 602 | } |
| 603 | |
| 604 | cc_library { |
| 605 | name: "mylib", |
| 606 | srcs: ["mylib.cpp"], |
| 607 | shared_libs: ["libdl#27"], |
| 608 | stl: "none", |
| 609 | } |
| 610 | |
| 611 | cc_library_shared { |
| 612 | name: "mylib_shared", |
| 613 | srcs: ["mylib.cpp"], |
| 614 | shared_libs: ["libdl#27"], |
| 615 | stl: "none", |
| 616 | } |
| 617 | |
| 618 | cc_library { |
| 619 | name: "libc", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 620 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 621 | nocrt: true, |
| 622 | system_shared_libs: [], |
| 623 | stl: "none", |
| 624 | stubs: { |
| 625 | versions: ["27", "28", "29"], |
| 626 | }, |
| 627 | } |
| 628 | |
| 629 | cc_library { |
| 630 | name: "libm", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 631 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 632 | nocrt: true, |
| 633 | system_shared_libs: [], |
| 634 | stl: "none", |
| 635 | stubs: { |
| 636 | versions: ["27", "28", "29"], |
| 637 | }, |
| 638 | } |
| 639 | |
| 640 | cc_library { |
| 641 | name: "libdl", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 642 | no_libcrt: true, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 643 | nocrt: true, |
| 644 | system_shared_libs: [], |
| 645 | stl: "none", |
| 646 | stubs: { |
| 647 | versions: ["27", "28", "29"], |
| 648 | }, |
| 649 | } |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 650 | |
| 651 | cc_library { |
| 652 | name: "libBootstrap", |
| 653 | srcs: ["mylib.cpp"], |
| 654 | stl: "none", |
| 655 | bootstrap: true, |
| 656 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 657 | `) |
| 658 | |
| 659 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 660 | copyCmds := apexRule.Args["copy_commands"] |
| 661 | |
| 662 | // Ensure that mylib, libm, libdl are included. |
Alex Light | 5098a61 | 2018-11-29 17:12:15 -0800 | [diff] [blame] | 663 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 664 | ensureContains(t, copyCmds, "image.apex/lib64/bionic/libm.so") |
| 665 | ensureContains(t, copyCmds, "image.apex/lib64/bionic/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 666 | |
| 667 | // 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] | 668 | ensureNotContains(t, copyCmds, "image.apex/lib64/bionic/libc.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 669 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 670 | mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_shared_myapex").Rule("ld").Args["libFlags"] |
| 671 | mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"] |
| 672 | 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] | 673 | |
| 674 | // For dependency to libc |
| 675 | // Ensure that mylib is linking with the latest version of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 676 | 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] | 677 | // ... and not linking to the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 678 | 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] | 679 | // ... Cflags from stub is correctly exported to mylib |
| 680 | ensureContains(t, mylibCFlags, "__LIBC_API__=29") |
| 681 | ensureContains(t, mylibSharedCFlags, "__LIBC_API__=29") |
| 682 | |
| 683 | // For dependency to libm |
| 684 | // Ensure that mylib is linking with the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 685 | 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] | 686 | // ... and not linking to the stub variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 687 | 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] | 688 | // ... and is not compiling with the stub |
| 689 | ensureNotContains(t, mylibCFlags, "__LIBM_API__=29") |
| 690 | ensureNotContains(t, mylibSharedCFlags, "__LIBM_API__=29") |
| 691 | |
| 692 | // For dependency to libdl |
| 693 | // Ensure that mylib is linking with the specified version of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 694 | 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] | 695 | // ... and not linking to the other versions of stubs |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 696 | ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_core_shared_28_myapex/libdl.so") |
| 697 | 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] | 698 | // ... and not linking to the non-stub (impl) variant |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 699 | 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] | 700 | // ... Cflags from stub is correctly exported to mylib |
| 701 | ensureContains(t, mylibCFlags, "__LIBDL_API__=27") |
| 702 | ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27") |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 703 | |
| 704 | // Ensure that libBootstrap is depending on the platform variant of bionic libs |
| 705 | libFlags := ctx.ModuleForTests("libBootstrap", "android_arm64_armv8-a_core_shared").Rule("ld").Args["libFlags"] |
| 706 | ensureContains(t, libFlags, "libc/android_arm64_armv8-a_core_shared/libc.so") |
| 707 | ensureContains(t, libFlags, "libm/android_arm64_armv8-a_core_shared/libm.so") |
| 708 | ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_core_shared/libdl.so") |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 709 | } |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 710 | |
| 711 | func TestFilesInSubDir(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 712 | ctx, _ := testApex(t, ` |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 713 | apex { |
| 714 | name: "myapex", |
| 715 | key: "myapex.key", |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 716 | native_shared_libs: ["mylib"], |
| 717 | binaries: ["mybin"], |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 718 | prebuilts: ["myetc"], |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 719 | compile_multilib: "both", |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | apex_key { |
| 723 | name: "myapex.key", |
| 724 | public_key: "testkey.avbpubkey", |
| 725 | private_key: "testkey.pem", |
| 726 | } |
| 727 | |
| 728 | prebuilt_etc { |
| 729 | name: "myetc", |
| 730 | src: "myprebuilt", |
| 731 | sub_dir: "foo/bar", |
| 732 | } |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 733 | |
| 734 | cc_library { |
| 735 | name: "mylib", |
| 736 | srcs: ["mylib.cpp"], |
| 737 | relative_install_path: "foo/bar", |
| 738 | system_shared_libs: [], |
| 739 | stl: "none", |
| 740 | } |
| 741 | |
| 742 | cc_binary { |
| 743 | name: "mybin", |
| 744 | srcs: ["mylib.cpp"], |
| 745 | relative_install_path: "foo/bar", |
| 746 | system_shared_libs: [], |
| 747 | static_executable: true, |
| 748 | stl: "none", |
| 749 | } |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 750 | `) |
| 751 | |
| 752 | generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("generateFsConfig") |
| 753 | dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") |
| 754 | |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 755 | // Ensure that the subdirectories are all listed |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 756 | ensureListContains(t, dirs, "etc") |
| 757 | ensureListContains(t, dirs, "etc/foo") |
| 758 | ensureListContains(t, dirs, "etc/foo/bar") |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 759 | ensureListContains(t, dirs, "lib64") |
| 760 | ensureListContains(t, dirs, "lib64/foo") |
| 761 | ensureListContains(t, dirs, "lib64/foo/bar") |
| 762 | ensureListContains(t, dirs, "lib") |
| 763 | ensureListContains(t, dirs, "lib/foo") |
| 764 | ensureListContains(t, dirs, "lib/foo/bar") |
| 765 | |
Jiyong Park | bd13e44 | 2019-03-15 18:10:35 +0900 | [diff] [blame] | 766 | ensureListContains(t, dirs, "bin") |
| 767 | ensureListContains(t, dirs, "bin/foo") |
| 768 | ensureListContains(t, dirs, "bin/foo/bar") |
Jiyong Park | 7c2ee71 | 2018-12-07 00:42:25 +0900 | [diff] [blame] | 769 | } |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 770 | |
| 771 | func TestUseVendor(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 772 | ctx, _ := testApex(t, ` |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 773 | apex { |
| 774 | name: "myapex", |
| 775 | key: "myapex.key", |
| 776 | native_shared_libs: ["mylib"], |
| 777 | use_vendor: true, |
| 778 | } |
| 779 | |
| 780 | apex_key { |
| 781 | name: "myapex.key", |
| 782 | public_key: "testkey.avbpubkey", |
| 783 | private_key: "testkey.pem", |
| 784 | } |
| 785 | |
| 786 | cc_library { |
| 787 | name: "mylib", |
| 788 | srcs: ["mylib.cpp"], |
| 789 | shared_libs: ["mylib2"], |
| 790 | system_shared_libs: [], |
| 791 | vendor_available: true, |
| 792 | stl: "none", |
| 793 | } |
| 794 | |
| 795 | cc_library { |
| 796 | name: "mylib2", |
| 797 | srcs: ["mylib.cpp"], |
| 798 | system_shared_libs: [], |
| 799 | vendor_available: true, |
| 800 | stl: "none", |
| 801 | } |
| 802 | `) |
| 803 | |
| 804 | inputsList := []string{} |
| 805 | for _, i := range ctx.ModuleForTests("myapex", "android_common_myapex").Module().BuildParamsForTests() { |
| 806 | for _, implicit := range i.Implicits { |
| 807 | inputsList = append(inputsList, implicit.String()) |
| 808 | } |
| 809 | } |
| 810 | inputsString := strings.Join(inputsList, " ") |
| 811 | |
| 812 | // ensure that the apex includes vendor variants of the direct and indirect deps |
| 813 | ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib.so") |
| 814 | ensureContains(t, inputsString, "android_arm64_armv8-a_vendor_shared_myapex/mylib2.so") |
| 815 | |
| 816 | // ensure that the apex does not include core variants |
| 817 | ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib.so") |
| 818 | ensureNotContains(t, inputsString, "android_arm64_armv8-a_core_shared_myapex/mylib2.so") |
| 819 | } |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 820 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 821 | func TestUseVendorFailsIfNotVendorAvailable(t *testing.T) { |
| 822 | testApexError(t, `dependency "mylib" of "myapex" missing variant:\n.*image:vendor`, ` |
| 823 | apex { |
| 824 | name: "myapex", |
| 825 | key: "myapex.key", |
| 826 | native_shared_libs: ["mylib"], |
| 827 | use_vendor: true, |
| 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 | |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 845 | func TestStaticLinking(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 846 | ctx, _ := testApex(t, ` |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 847 | apex { |
| 848 | name: "myapex", |
| 849 | key: "myapex.key", |
| 850 | native_shared_libs: ["mylib"], |
| 851 | } |
| 852 | |
| 853 | apex_key { |
| 854 | name: "myapex.key", |
| 855 | public_key: "testkey.avbpubkey", |
| 856 | private_key: "testkey.pem", |
| 857 | } |
| 858 | |
| 859 | cc_library { |
| 860 | name: "mylib", |
| 861 | srcs: ["mylib.cpp"], |
| 862 | system_shared_libs: [], |
| 863 | stl: "none", |
| 864 | stubs: { |
| 865 | versions: ["1", "2", "3"], |
| 866 | }, |
| 867 | } |
| 868 | |
| 869 | cc_binary { |
| 870 | name: "not_in_apex", |
| 871 | srcs: ["mylib.cpp"], |
| 872 | static_libs: ["mylib"], |
| 873 | static_executable: true, |
| 874 | system_shared_libs: [], |
| 875 | stl: "none", |
| 876 | } |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 877 | `) |
| 878 | |
| 879 | ldFlags := ctx.ModuleForTests("not_in_apex", "android_arm64_armv8-a_core").Rule("ld").Args["libFlags"] |
| 880 | |
| 881 | // 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] | 882 | ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_core_static/mylib.a") |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 883 | } |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 884 | |
| 885 | func TestKeys(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 886 | ctx, _ := testApex(t, ` |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 887 | apex { |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 888 | name: "myapex_keytest", |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 889 | key: "myapex.key", |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 890 | certificate: ":myapex.certificate", |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 891 | native_shared_libs: ["mylib"], |
| 892 | } |
| 893 | |
| 894 | cc_library { |
| 895 | name: "mylib", |
| 896 | srcs: ["mylib.cpp"], |
| 897 | system_shared_libs: [], |
| 898 | stl: "none", |
| 899 | } |
| 900 | |
| 901 | apex_key { |
| 902 | name: "myapex.key", |
| 903 | public_key: "testkey.avbpubkey", |
| 904 | private_key: "testkey.pem", |
| 905 | } |
| 906 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 907 | android_app_certificate { |
| 908 | name: "myapex.certificate", |
| 909 | certificate: "testkey", |
| 910 | } |
| 911 | |
| 912 | android_app_certificate { |
| 913 | name: "myapex.certificate.override", |
| 914 | certificate: "testkey.override", |
| 915 | } |
| 916 | |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 917 | `) |
| 918 | |
| 919 | // check the APEX keys |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 920 | keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 921 | |
| 922 | if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" { |
| 923 | t.Errorf("public key %q is not %q", keys.public_key_file.String(), |
| 924 | "vendor/foo/devkeys/testkey.avbpubkey") |
| 925 | } |
| 926 | if keys.private_key_file.String() != "vendor/foo/devkeys/testkey.pem" { |
| 927 | t.Errorf("private key %q is not %q", keys.private_key_file.String(), |
| 928 | "vendor/foo/devkeys/testkey.pem") |
| 929 | } |
| 930 | |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 931 | // check the APK certs. It should be overridden to myapex.certificate.override |
| 932 | certs := ctx.ModuleForTests("myapex_keytest", "android_common_myapex_keytest").Rule("signapk").Args["certificates"] |
| 933 | if certs != "testkey.override.x509.pem testkey.override.pk8" { |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 934 | t.Errorf("cert and private key %q are not %q", certs, |
Jiyong Park | b2742fd | 2019-02-11 11:38:15 +0900 | [diff] [blame] | 935 | "testkey.override.509.pem testkey.override.pk8") |
Jiyong Park | 9335a26 | 2018-12-24 11:31:58 +0900 | [diff] [blame] | 936 | } |
| 937 | } |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 938 | |
| 939 | func TestMacro(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 940 | ctx, _ := testApex(t, ` |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 941 | apex { |
| 942 | name: "myapex", |
| 943 | key: "myapex.key", |
| 944 | native_shared_libs: ["mylib"], |
| 945 | } |
| 946 | |
| 947 | apex { |
| 948 | name: "otherapex", |
| 949 | key: "myapex.key", |
| 950 | native_shared_libs: ["mylib"], |
| 951 | } |
| 952 | |
| 953 | apex_key { |
| 954 | name: "myapex.key", |
| 955 | public_key: "testkey.avbpubkey", |
| 956 | private_key: "testkey.pem", |
| 957 | } |
| 958 | |
| 959 | cc_library { |
| 960 | name: "mylib", |
| 961 | srcs: ["mylib.cpp"], |
| 962 | system_shared_libs: [], |
| 963 | stl: "none", |
| 964 | } |
| 965 | `) |
| 966 | |
| 967 | // non-APEX variant does not have __ANDROID__APEX__ defined |
| 968 | mylibCFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"] |
| 969 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 970 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 971 | |
| 972 | // APEX variant has __ANDROID_APEX__=<apexname> defined |
| 973 | mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_myapex").Rule("cc").Args["cFlags"] |
| 974 | ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 975 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 976 | |
| 977 | // APEX variant has __ANDROID_APEX__=<apexname> defined |
| 978 | mylibCFlags = ctx.ModuleForTests("mylib", "android_arm64_armv8-a_core_static_otherapex").Rule("cc").Args["cFlags"] |
| 979 | ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex") |
| 980 | ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex") |
| 981 | } |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 982 | |
| 983 | func TestHeaderLibsDependency(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 984 | ctx, _ := testApex(t, ` |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 985 | apex { |
| 986 | name: "myapex", |
| 987 | key: "myapex.key", |
| 988 | native_shared_libs: ["mylib"], |
| 989 | } |
| 990 | |
| 991 | apex_key { |
| 992 | name: "myapex.key", |
| 993 | public_key: "testkey.avbpubkey", |
| 994 | private_key: "testkey.pem", |
| 995 | } |
| 996 | |
| 997 | cc_library_headers { |
| 998 | name: "mylib_headers", |
| 999 | export_include_dirs: ["my_include"], |
| 1000 | system_shared_libs: [], |
| 1001 | stl: "none", |
| 1002 | } |
| 1003 | |
| 1004 | cc_library { |
| 1005 | name: "mylib", |
| 1006 | srcs: ["mylib.cpp"], |
| 1007 | system_shared_libs: [], |
| 1008 | stl: "none", |
| 1009 | header_libs: ["mylib_headers"], |
| 1010 | export_header_lib_headers: ["mylib_headers"], |
| 1011 | stubs: { |
| 1012 | versions: ["1", "2", "3"], |
| 1013 | }, |
| 1014 | } |
| 1015 | |
| 1016 | cc_library { |
| 1017 | name: "otherlib", |
| 1018 | srcs: ["mylib.cpp"], |
| 1019 | system_shared_libs: [], |
| 1020 | stl: "none", |
| 1021 | shared_libs: ["mylib"], |
| 1022 | } |
| 1023 | `) |
| 1024 | |
| 1025 | cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"] |
| 1026 | |
| 1027 | // Ensure that the include path of the header lib is exported to 'otherlib' |
| 1028 | ensureContains(t, cFlags, "-Imy_include") |
| 1029 | } |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1030 | |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1031 | func TestNonTestApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1032 | ctx, _ := testApex(t, ` |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1033 | apex { |
| 1034 | name: "myapex", |
| 1035 | key: "myapex.key", |
| 1036 | native_shared_libs: ["mylib_common"], |
| 1037 | } |
| 1038 | |
| 1039 | apex_key { |
| 1040 | name: "myapex.key", |
| 1041 | public_key: "testkey.avbpubkey", |
| 1042 | private_key: "testkey.pem", |
| 1043 | } |
| 1044 | |
| 1045 | cc_library { |
| 1046 | name: "mylib_common", |
| 1047 | srcs: ["mylib.cpp"], |
| 1048 | system_shared_libs: [], |
| 1049 | stl: "none", |
| 1050 | } |
| 1051 | `) |
| 1052 | |
| 1053 | module := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1054 | apexRule := module.Rule("apexRule") |
| 1055 | copyCmds := apexRule.Args["copy_commands"] |
| 1056 | |
| 1057 | if apex, ok := module.Module().(*apexBundle); !ok || apex.testApex { |
| 1058 | t.Log("Apex was a test apex!") |
| 1059 | t.Fail() |
| 1060 | } |
| 1061 | // Ensure that main rule creates an output |
| 1062 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1063 | |
| 1064 | // Ensure that apex variant is created for the direct dep |
| 1065 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex") |
| 1066 | |
| 1067 | // Ensure that both direct and indirect deps are copied into apex |
| 1068 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so") |
| 1069 | |
| 1070 | // Ensure that the platform variant ends with _core_shared |
| 1071 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared") |
| 1072 | |
| 1073 | if !android.InAnyApex("mylib_common") { |
| 1074 | t.Log("Found mylib_common not in any apex!") |
| 1075 | t.Fail() |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | func TestTestApex(t *testing.T) { |
| 1080 | if android.InAnyApex("mylib_common_test") { |
| 1081 | 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!") |
| 1082 | } |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1083 | ctx, _ := testApex(t, ` |
Alex Light | 0851b88 | 2019-02-07 13:20:53 -0800 | [diff] [blame] | 1084 | apex_test { |
| 1085 | name: "myapex", |
| 1086 | key: "myapex.key", |
| 1087 | native_shared_libs: ["mylib_common_test"], |
| 1088 | } |
| 1089 | |
| 1090 | apex_key { |
| 1091 | name: "myapex.key", |
| 1092 | public_key: "testkey.avbpubkey", |
| 1093 | private_key: "testkey.pem", |
| 1094 | } |
| 1095 | |
| 1096 | cc_library { |
| 1097 | name: "mylib_common_test", |
| 1098 | srcs: ["mylib.cpp"], |
| 1099 | system_shared_libs: [], |
| 1100 | stl: "none", |
| 1101 | } |
| 1102 | `) |
| 1103 | |
| 1104 | module := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1105 | apexRule := module.Rule("apexRule") |
| 1106 | copyCmds := apexRule.Args["copy_commands"] |
| 1107 | |
| 1108 | if apex, ok := module.Module().(*apexBundle); !ok || !apex.testApex { |
| 1109 | t.Log("Apex was not a test apex!") |
| 1110 | t.Fail() |
| 1111 | } |
| 1112 | // Ensure that main rule creates an output |
| 1113 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1114 | |
| 1115 | // Ensure that apex variant is created for the direct dep |
| 1116 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared_myapex") |
| 1117 | |
| 1118 | // Ensure that both direct and indirect deps are copied into apex |
| 1119 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common_test.so") |
| 1120 | |
| 1121 | // Ensure that the platform variant ends with _core_shared |
| 1122 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_core_shared") |
| 1123 | |
| 1124 | if android.InAnyApex("mylib_common_test") { |
| 1125 | t.Log("Found mylib_common_test in some apex!") |
| 1126 | t.Fail() |
| 1127 | } |
| 1128 | } |
| 1129 | |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1130 | func TestApexWithTarget(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1131 | ctx, _ := testApex(t, ` |
Alex Light | 9670d33 | 2019-01-29 18:07:33 -0800 | [diff] [blame] | 1132 | apex { |
| 1133 | name: "myapex", |
| 1134 | key: "myapex.key", |
| 1135 | multilib: { |
| 1136 | first: { |
| 1137 | native_shared_libs: ["mylib_common"], |
| 1138 | } |
| 1139 | }, |
| 1140 | target: { |
| 1141 | android: { |
| 1142 | multilib: { |
| 1143 | first: { |
| 1144 | native_shared_libs: ["mylib"], |
| 1145 | } |
| 1146 | } |
| 1147 | }, |
| 1148 | host: { |
| 1149 | multilib: { |
| 1150 | first: { |
| 1151 | native_shared_libs: ["mylib2"], |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | |
| 1158 | apex_key { |
| 1159 | name: "myapex.key", |
| 1160 | public_key: "testkey.avbpubkey", |
| 1161 | private_key: "testkey.pem", |
| 1162 | } |
| 1163 | |
| 1164 | cc_library { |
| 1165 | name: "mylib", |
| 1166 | srcs: ["mylib.cpp"], |
| 1167 | system_shared_libs: [], |
| 1168 | stl: "none", |
| 1169 | } |
| 1170 | |
| 1171 | cc_library { |
| 1172 | name: "mylib_common", |
| 1173 | srcs: ["mylib.cpp"], |
| 1174 | system_shared_libs: [], |
| 1175 | stl: "none", |
| 1176 | compile_multilib: "first", |
| 1177 | } |
| 1178 | |
| 1179 | cc_library { |
| 1180 | name: "mylib2", |
| 1181 | srcs: ["mylib.cpp"], |
| 1182 | system_shared_libs: [], |
| 1183 | stl: "none", |
| 1184 | compile_multilib: "first", |
| 1185 | } |
| 1186 | `) |
| 1187 | |
| 1188 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1189 | copyCmds := apexRule.Args["copy_commands"] |
| 1190 | |
| 1191 | // Ensure that main rule creates an output |
| 1192 | ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned") |
| 1193 | |
| 1194 | // Ensure that apex variant is created for the direct dep |
| 1195 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
| 1196 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared_myapex") |
| 1197 | ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared_myapex") |
| 1198 | |
| 1199 | // Ensure that both direct and indirect deps are copied into apex |
| 1200 | ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") |
| 1201 | ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so") |
| 1202 | ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") |
| 1203 | |
| 1204 | // Ensure that the platform variant ends with _core_shared |
| 1205 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared") |
| 1206 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_core_shared") |
| 1207 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_core_shared") |
| 1208 | } |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1209 | |
| 1210 | func TestApexWithShBinary(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1211 | ctx, _ := testApex(t, ` |
Jiyong Park | 04480cf | 2019-02-06 00:16:29 +0900 | [diff] [blame] | 1212 | apex { |
| 1213 | name: "myapex", |
| 1214 | key: "myapex.key", |
| 1215 | binaries: ["myscript"], |
| 1216 | } |
| 1217 | |
| 1218 | apex_key { |
| 1219 | name: "myapex.key", |
| 1220 | public_key: "testkey.avbpubkey", |
| 1221 | private_key: "testkey.pem", |
| 1222 | } |
| 1223 | |
| 1224 | sh_binary { |
| 1225 | name: "myscript", |
| 1226 | src: "mylib.cpp", |
| 1227 | filename: "myscript.sh", |
| 1228 | sub_dir: "script", |
| 1229 | } |
| 1230 | `) |
| 1231 | |
| 1232 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1233 | copyCmds := apexRule.Args["copy_commands"] |
| 1234 | |
| 1235 | ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh") |
| 1236 | } |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1237 | |
| 1238 | func TestApexInProductPartition(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1239 | ctx, _ := testApex(t, ` |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1240 | apex { |
| 1241 | name: "myapex", |
| 1242 | key: "myapex.key", |
| 1243 | native_shared_libs: ["mylib"], |
| 1244 | product_specific: true, |
| 1245 | } |
| 1246 | |
| 1247 | apex_key { |
| 1248 | name: "myapex.key", |
| 1249 | public_key: "testkey.avbpubkey", |
| 1250 | private_key: "testkey.pem", |
| 1251 | product_specific: true, |
| 1252 | } |
| 1253 | |
| 1254 | cc_library { |
| 1255 | name: "mylib", |
| 1256 | srcs: ["mylib.cpp"], |
| 1257 | system_shared_libs: [], |
| 1258 | stl: "none", |
| 1259 | } |
| 1260 | `) |
| 1261 | |
| 1262 | apex := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) |
| 1263 | expected := "target/product/test_device/product/apex" |
| 1264 | actual := apex.installDir.RelPathString() |
| 1265 | if actual != expected { |
| 1266 | t.Errorf("wrong install path. expected %q. actual %q", expected, actual) |
| 1267 | } |
Jiyong Park | d1e293d | 2019-03-15 02:13:21 +0900 | [diff] [blame] | 1268 | } |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 1269 | |
| 1270 | func TestApexKeyFromOtherModule(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1271 | ctx, _ := testApex(t, ` |
Jiyong Park | 6788256 | 2019-03-21 01:11:21 +0900 | [diff] [blame] | 1272 | apex_key { |
| 1273 | name: "myapex.key", |
| 1274 | public_key: ":my.avbpubkey", |
| 1275 | private_key: ":my.pem", |
| 1276 | product_specific: true, |
| 1277 | } |
| 1278 | |
| 1279 | filegroup { |
| 1280 | name: "my.avbpubkey", |
| 1281 | srcs: ["testkey2.avbpubkey"], |
| 1282 | } |
| 1283 | |
| 1284 | filegroup { |
| 1285 | name: "my.pem", |
| 1286 | srcs: ["testkey2.pem"], |
| 1287 | } |
| 1288 | `) |
| 1289 | |
| 1290 | apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) |
| 1291 | expected_pubkey := "testkey2.avbpubkey" |
| 1292 | actual_pubkey := apex_key.public_key_file.String() |
| 1293 | if actual_pubkey != expected_pubkey { |
| 1294 | t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey) |
| 1295 | } |
| 1296 | expected_privkey := "testkey2.pem" |
| 1297 | actual_privkey := apex_key.private_key_file.String() |
| 1298 | if actual_privkey != expected_privkey { |
| 1299 | t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey) |
| 1300 | } |
| 1301 | } |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1302 | |
| 1303 | func TestPrebuilt(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1304 | ctx, _ := testApex(t, ` |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1305 | prebuilt_apex { |
| 1306 | name: "myapex", |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 1307 | arch: { |
| 1308 | arm64: { |
| 1309 | src: "myapex-arm64.apex", |
| 1310 | }, |
| 1311 | arm: { |
| 1312 | src: "myapex-arm.apex", |
| 1313 | }, |
| 1314 | }, |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1315 | } |
| 1316 | `) |
| 1317 | |
| 1318 | prebuilt := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) |
| 1319 | |
Jiyong Park | c95714e | 2019-03-29 14:23:10 +0900 | [diff] [blame] | 1320 | expectedInput := "myapex-arm64.apex" |
| 1321 | if prebuilt.inputApex.String() != expectedInput { |
| 1322 | t.Errorf("inputApex invalid. expected: %q, actual: %q", expectedInput, prebuilt.inputApex.String()) |
| 1323 | } |
Jaewoong Jung | 939ebd5 | 2019-03-26 15:07:36 -0700 | [diff] [blame] | 1324 | } |
Nikita Ioffe | 7a41ebd | 2019-04-04 18:09:48 +0100 | [diff] [blame] | 1325 | |
| 1326 | func TestPrebuiltFilenameOverride(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1327 | ctx, _ := testApex(t, ` |
Nikita Ioffe | 7a41ebd | 2019-04-04 18:09:48 +0100 | [diff] [blame] | 1328 | prebuilt_apex { |
| 1329 | name: "myapex", |
| 1330 | src: "myapex-arm.apex", |
| 1331 | filename: "notmyapex.apex", |
| 1332 | } |
| 1333 | `) |
| 1334 | |
| 1335 | p := ctx.ModuleForTests("myapex", "android_common").Module().(*Prebuilt) |
| 1336 | |
| 1337 | expected := "notmyapex.apex" |
| 1338 | if p.installFilename != expected { |
| 1339 | t.Errorf("installFilename invalid. expected: %q, actual: %q", expected, p.installFilename) |
| 1340 | } |
| 1341 | } |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 1342 | |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1343 | func TestPrebuiltOverrides(t *testing.T) { |
| 1344 | ctx, config := testApex(t, ` |
| 1345 | prebuilt_apex { |
| 1346 | name: "myapex.prebuilt", |
| 1347 | src: "myapex-arm.apex", |
| 1348 | overrides: [ |
| 1349 | "myapex", |
| 1350 | ], |
| 1351 | } |
| 1352 | `) |
| 1353 | |
| 1354 | p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt) |
| 1355 | |
| 1356 | expected := []string{"myapex"} |
| 1357 | actual := android.AndroidMkEntriesForTest(t, config, "", p).EntryMap["LOCAL_OVERRIDES_PACKAGES"] |
| 1358 | if !reflect.DeepEqual(actual, expected) { |
| 1359 | t.Errorf("Incorrect LOCAL_OVERRIDES_PACKAGES value '%s', expected '%s'", actual, expected) |
| 1360 | } |
| 1361 | } |
| 1362 | |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1363 | func TestApexWithTests(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1364 | ctx, _ := testApex(t, ` |
Roland Levillain | 630846d | 2019-06-26 12:48:34 +0100 | [diff] [blame] | 1365 | apex_test { |
| 1366 | name: "myapex", |
| 1367 | key: "myapex.key", |
| 1368 | tests: [ |
| 1369 | "mytest", |
| 1370 | ], |
| 1371 | } |
| 1372 | |
| 1373 | apex_key { |
| 1374 | name: "myapex.key", |
| 1375 | public_key: "testkey.avbpubkey", |
| 1376 | private_key: "testkey.pem", |
| 1377 | } |
| 1378 | |
| 1379 | cc_test { |
| 1380 | name: "mytest", |
| 1381 | gtest: false, |
| 1382 | srcs: ["mytest.cpp"], |
| 1383 | relative_install_path: "test", |
| 1384 | system_shared_libs: [], |
| 1385 | static_executable: true, |
| 1386 | stl: "none", |
| 1387 | } |
| 1388 | `) |
| 1389 | |
| 1390 | apexRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexRule") |
| 1391 | copyCmds := apexRule.Args["copy_commands"] |
| 1392 | |
| 1393 | // Ensure that test dep is copied into apex. |
| 1394 | ensureContains(t, copyCmds, "image.apex/bin/test/mytest") |
| 1395 | } |
| 1396 | |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1397 | func TestApexUsesOtherApex(t *testing.T) { |
Jaewoong Jung | 22f7d18 | 2019-07-16 18:25:41 -0700 | [diff] [blame^] | 1398 | ctx, _ := testApex(t, ` |
Jooyung Han | 5c998b9 | 2019-06-27 11:30:33 +0900 | [diff] [blame] | 1399 | apex { |
| 1400 | name: "myapex", |
| 1401 | key: "myapex.key", |
| 1402 | native_shared_libs: ["mylib"], |
| 1403 | uses: ["commonapex"], |
| 1404 | } |
| 1405 | |
| 1406 | apex { |
| 1407 | name: "commonapex", |
| 1408 | key: "myapex.key", |
| 1409 | native_shared_libs: ["libcommon"], |
| 1410 | provide_cpp_shared_libs: true, |
| 1411 | } |
| 1412 | |
| 1413 | apex_key { |
| 1414 | name: "myapex.key", |
| 1415 | public_key: "testkey.avbpubkey", |
| 1416 | private_key: "testkey.pem", |
| 1417 | } |
| 1418 | |
| 1419 | cc_library { |
| 1420 | name: "mylib", |
| 1421 | srcs: ["mylib.cpp"], |
| 1422 | shared_libs: ["libcommon"], |
| 1423 | system_shared_libs: [], |
| 1424 | stl: "none", |
| 1425 | } |
| 1426 | |
| 1427 | cc_library { |
| 1428 | name: "libcommon", |
| 1429 | srcs: ["mylib_common.cpp"], |
| 1430 | system_shared_libs: [], |
| 1431 | stl: "none", |
| 1432 | } |
| 1433 | `) |
| 1434 | |
| 1435 | module1 := ctx.ModuleForTests("myapex", "android_common_myapex") |
| 1436 | apexRule1 := module1.Rule("apexRule") |
| 1437 | copyCmds1 := apexRule1.Args["copy_commands"] |
| 1438 | |
| 1439 | module2 := ctx.ModuleForTests("commonapex", "android_common_commonapex") |
| 1440 | apexRule2 := module2.Rule("apexRule") |
| 1441 | copyCmds2 := apexRule2.Args["copy_commands"] |
| 1442 | |
| 1443 | ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_core_shared_myapex") |
| 1444 | ensureListContains(t, ctx.ModuleVariantsForTests("libcommon"), "android_arm64_armv8-a_core_shared_commonapex") |
| 1445 | ensureContains(t, copyCmds1, "image.apex/lib64/mylib.so") |
| 1446 | ensureContains(t, copyCmds2, "image.apex/lib64/libcommon.so") |
| 1447 | ensureNotContains(t, copyCmds1, "image.apex/lib64/libcommon.so") |
| 1448 | } |
| 1449 | |
| 1450 | func TestApexUsesFailsIfNotProvided(t *testing.T) { |
| 1451 | testApexError(t, `uses: "commonapex" does not provide native_shared_libs`, ` |
| 1452 | apex { |
| 1453 | name: "myapex", |
| 1454 | key: "myapex.key", |
| 1455 | uses: ["commonapex"], |
| 1456 | } |
| 1457 | |
| 1458 | apex { |
| 1459 | name: "commonapex", |
| 1460 | key: "myapex.key", |
| 1461 | } |
| 1462 | |
| 1463 | apex_key { |
| 1464 | name: "myapex.key", |
| 1465 | public_key: "testkey.avbpubkey", |
| 1466 | private_key: "testkey.pem", |
| 1467 | } |
| 1468 | `) |
| 1469 | testApexError(t, `uses: "commonapex" is not a provider`, ` |
| 1470 | apex { |
| 1471 | name: "myapex", |
| 1472 | key: "myapex.key", |
| 1473 | uses: ["commonapex"], |
| 1474 | } |
| 1475 | |
| 1476 | cc_library { |
| 1477 | name: "commonapex", |
| 1478 | system_shared_libs: [], |
| 1479 | stl: "none", |
| 1480 | } |
| 1481 | |
| 1482 | apex_key { |
| 1483 | name: "myapex.key", |
| 1484 | public_key: "testkey.avbpubkey", |
| 1485 | private_key: "testkey.pem", |
| 1486 | } |
| 1487 | `) |
| 1488 | } |
| 1489 | |
| 1490 | func TestApexUsesFailsIfUseVenderMismatch(t *testing.T) { |
| 1491 | testApexError(t, `use_vendor: "commonapex" has different value of use_vendor`, ` |
| 1492 | apex { |
| 1493 | name: "myapex", |
| 1494 | key: "myapex.key", |
| 1495 | use_vendor: true, |
| 1496 | uses: ["commonapex"], |
| 1497 | } |
| 1498 | |
| 1499 | apex { |
| 1500 | name: "commonapex", |
| 1501 | key: "myapex.key", |
| 1502 | provide_cpp_shared_libs: true, |
| 1503 | } |
| 1504 | |
| 1505 | apex_key { |
| 1506 | name: "myapex.key", |
| 1507 | public_key: "testkey.avbpubkey", |
| 1508 | private_key: "testkey.pem", |
| 1509 | } |
| 1510 | `) |
| 1511 | } |
| 1512 | |
Jaewoong Jung | c1001ec | 2019-06-25 11:20:53 -0700 | [diff] [blame] | 1513 | func TestMain(m *testing.M) { |
| 1514 | run := func() int { |
| 1515 | setUp() |
| 1516 | defer tearDown() |
| 1517 | |
| 1518 | return m.Run() |
| 1519 | } |
| 1520 | |
| 1521 | os.Exit(run()) |
| 1522 | } |