| Colin Cross | d00350c | 2017-11-17 10:55:38 -0800 | [diff] [blame] | 1 | // Copyright 2017 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 | |
| Colin Cross | 74d1ec0 | 2015-04-28 13:30:13 -0700 | [diff] [blame] | 15 | package cc |
| 16 | |
| 17 | import ( |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 18 | "fmt" |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 19 | "io/ioutil" |
| 20 | "os" |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 21 | "path/filepath" |
| Colin Cross | 74d1ec0 | 2015-04-28 13:30:13 -0700 | [diff] [blame] | 22 | "reflect" |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 23 | "strings" |
| Colin Cross | 74d1ec0 | 2015-04-28 13:30:13 -0700 | [diff] [blame] | 24 | "testing" |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 25 | |
| 26 | "android/soong/android" |
| Colin Cross | 74d1ec0 | 2015-04-28 13:30:13 -0700 | [diff] [blame] | 27 | ) |
| 28 | |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 29 | var buildDir string |
| 30 | |
| 31 | func setUp() { |
| 32 | var err error |
| 33 | buildDir, err = ioutil.TempDir("", "soong_cc_test") |
| 34 | if err != nil { |
| 35 | panic(err) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | func tearDown() { |
| 40 | os.RemoveAll(buildDir) |
| 41 | } |
| 42 | |
| 43 | func TestMain(m *testing.M) { |
| 44 | run := func() int { |
| 45 | setUp() |
| 46 | defer tearDown() |
| 47 | |
| 48 | return m.Run() |
| 49 | } |
| 50 | |
| 51 | os.Exit(run()) |
| 52 | } |
| 53 | |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 54 | func testCcWithConfig(t *testing.T, config android.Config) *android.TestContext { |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 55 | t.Helper() |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 56 | ctx := CreateTestContext(config) |
| 57 | ctx.Register() |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 58 | |
| Jeff Gaston | d3e141d | 2017-08-08 17:46:01 -0700 | [diff] [blame] | 59 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| Logan Chien | 4203971 | 2018-03-12 16:29:17 +0800 | [diff] [blame] | 60 | android.FailIfErrored(t, errs) |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 61 | _, errs = ctx.PrepareBuildActions(config) |
| Logan Chien | 4203971 | 2018-03-12 16:29:17 +0800 | [diff] [blame] | 62 | android.FailIfErrored(t, errs) |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 63 | |
| 64 | return ctx |
| 65 | } |
| 66 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 67 | func testCc(t *testing.T, bp string) *android.TestContext { |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 68 | t.Helper() |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 69 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 70 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 71 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 72 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 73 | |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 74 | return testCcWithConfig(t, config) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | func testCcNoVndk(t *testing.T, bp string) *android.TestContext { |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 78 | t.Helper() |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 79 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| Dan Willemsen | 674dc7f | 2018-03-12 18:06:05 -0700 | [diff] [blame] | 80 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 81 | |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 82 | return testCcWithConfig(t, config) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 83 | } |
| 84 | |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 85 | func testCcNoProductVndk(t *testing.T, bp string) *android.TestContext { |
| 86 | t.Helper() |
| 87 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 88 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 89 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 90 | |
| 91 | return testCcWithConfig(t, config) |
| 92 | } |
| 93 | |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 94 | func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) { |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 95 | t.Helper() |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 96 | |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 97 | ctx := CreateTestContext(config) |
| 98 | ctx.Register() |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 99 | |
| 100 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 101 | if len(errs) > 0 { |
| Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 102 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 103 | return |
| 104 | } |
| 105 | |
| 106 | _, errs = ctx.PrepareBuildActions(config) |
| 107 | if len(errs) > 0 { |
| Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 108 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 109 | return |
| 110 | } |
| 111 | |
| 112 | t.Fatalf("missing expected error %q (0 errors are returned)", pattern) |
| 113 | } |
| 114 | |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 115 | func testCcError(t *testing.T, pattern string, bp string) { |
| Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 116 | t.Helper() |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 117 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 118 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 119 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 120 | testCcErrorWithConfig(t, pattern, config) |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | func testCcErrorProductVndk(t *testing.T, pattern string, bp string) { |
| Jooyung Han | 261e158 | 2020-10-20 18:54:21 +0900 | [diff] [blame] | 125 | t.Helper() |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 126 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 127 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 128 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 129 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 130 | testCcErrorWithConfig(t, pattern, config) |
| 131 | return |
| 132 | } |
| 133 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 134 | const ( |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 135 | coreVariant = "android_arm64_armv8-a_shared" |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 136 | vendorVariant = "android_vendor.VER_arm64_armv8-a_shared" |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 137 | productVariant = "android_product.VER_arm64_armv8-a_shared" |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 138 | recoveryVariant = "android_recovery_arm64_armv8-a_shared" |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 139 | ) |
| 140 | |
| Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 141 | func TestFuchsiaDeps(t *testing.T) { |
| 142 | t.Helper() |
| 143 | |
| 144 | bp := ` |
| 145 | cc_library { |
| 146 | name: "libTest", |
| 147 | srcs: ["foo.c"], |
| 148 | target: { |
| 149 | fuchsia: { |
| 150 | srcs: ["bar.c"], |
| 151 | }, |
| 152 | }, |
| 153 | }` |
| 154 | |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 155 | config := TestConfig(buildDir, android.Fuchsia, nil, bp, nil) |
| 156 | ctx := testCcWithConfig(t, config) |
| Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 157 | |
| 158 | rt := false |
| 159 | fb := false |
| 160 | |
| 161 | ld := ctx.ModuleForTests("libTest", "fuchsia_arm64_shared").Rule("ld") |
| 162 | implicits := ld.Implicits |
| 163 | for _, lib := range implicits { |
| 164 | if strings.Contains(lib.Rel(), "libcompiler_rt") { |
| 165 | rt = true |
| 166 | } |
| 167 | |
| 168 | if strings.Contains(lib.Rel(), "libbioniccompat") { |
| 169 | fb = true |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | if !rt || !fb { |
| 174 | t.Errorf("fuchsia libs must link libcompiler_rt and libbioniccompat") |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | func TestFuchsiaTargetDecl(t *testing.T) { |
| 179 | t.Helper() |
| 180 | |
| 181 | bp := ` |
| 182 | cc_library { |
| 183 | name: "libTest", |
| 184 | srcs: ["foo.c"], |
| 185 | target: { |
| 186 | fuchsia: { |
| 187 | srcs: ["bar.c"], |
| 188 | }, |
| 189 | }, |
| 190 | }` |
| 191 | |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 192 | config := TestConfig(buildDir, android.Fuchsia, nil, bp, nil) |
| 193 | ctx := testCcWithConfig(t, config) |
| Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 194 | ld := ctx.ModuleForTests("libTest", "fuchsia_arm64_shared").Rule("ld") |
| 195 | var objs []string |
| 196 | for _, o := range ld.Inputs { |
| 197 | objs = append(objs, o.Base()) |
| 198 | } |
| 199 | if len(objs) != 2 || objs[0] != "foo.o" || objs[1] != "bar.o" { |
| 200 | t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs) |
| 201 | } |
| 202 | } |
| 203 | |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 204 | func TestVendorSrc(t *testing.T) { |
| 205 | ctx := testCc(t, ` |
| 206 | cc_library { |
| 207 | name: "libTest", |
| 208 | srcs: ["foo.c"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 209 | no_libcrt: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 210 | nocrt: true, |
| 211 | system_shared_libs: [], |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 212 | vendor_available: true, |
| 213 | target: { |
| 214 | vendor: { |
| 215 | srcs: ["bar.c"], |
| 216 | }, |
| 217 | }, |
| 218 | } |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 219 | `) |
| 220 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 221 | ld := ctx.ModuleForTests("libTest", vendorVariant).Rule("ld") |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 222 | var objs []string |
| 223 | for _, o := range ld.Inputs { |
| 224 | objs = append(objs, o.Base()) |
| 225 | } |
| Colin Cross | 95d33fe | 2018-01-03 13:40:46 -0800 | [diff] [blame] | 226 | if len(objs) != 2 || objs[0] != "foo.o" || objs[1] != "bar.o" { |
| Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 227 | t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs) |
| 228 | } |
| 229 | } |
| 230 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 231 | func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 232 | isVndkSp bool, extends string, variant string) { |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 233 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 234 | t.Helper() |
| 235 | |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 236 | mod := ctx.ModuleForTests(name, variant).Module().(*Module) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 237 | |
| 238 | // Check library properties. |
| 239 | lib, ok := mod.compiler.(*libraryDecorator) |
| 240 | if !ok { |
| 241 | t.Errorf("%q must have libraryDecorator", name) |
| 242 | } else if lib.baseInstaller.subDir != subDir { |
| 243 | t.Errorf("%q must use %q as subdir but it is using %q", name, subDir, |
| 244 | lib.baseInstaller.subDir) |
| 245 | } |
| 246 | |
| 247 | // Check VNDK properties. |
| 248 | if mod.vndkdep == nil { |
| 249 | t.Fatalf("%q must have `vndkdep`", name) |
| 250 | } |
| Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 251 | if !mod.IsVndk() { |
| 252 | t.Errorf("%q IsVndk() must equal to true", name) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 253 | } |
| 254 | if mod.isVndkSp() != isVndkSp { |
| 255 | t.Errorf("%q isVndkSp() must equal to %t", name, isVndkSp) |
| 256 | } |
| 257 | |
| 258 | // Check VNDK extension properties. |
| 259 | isVndkExt := extends != "" |
| Ivan Lozano | f9e2172 | 2020-12-02 09:00:51 -0500 | [diff] [blame] | 260 | if mod.IsVndkExt() != isVndkExt { |
| 261 | t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | if actualExtends := mod.getVndkExtendsModuleName(); actualExtends != extends { |
| 265 | t.Errorf("%q must extend from %q but get %q", name, extends, actualExtends) |
| 266 | } |
| 267 | } |
| 268 | |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 269 | func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool) { |
| 270 | t.Helper() |
| Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 271 | mod, ok := ctx.ModuleForTests(moduleName, variant).Module().(android.OutputFileProducer) |
| 272 | if !ok { |
| 273 | t.Errorf("%q must have output\n", moduleName) |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 274 | return |
| 275 | } |
| Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 276 | outputFiles, err := mod.OutputFiles("") |
| 277 | if err != nil || len(outputFiles) != 1 { |
| 278 | t.Errorf("%q must have single output\n", moduleName) |
| 279 | return |
| 280 | } |
| 281 | snapshotPath := filepath.Join(subDir, snapshotFilename) |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 282 | |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 283 | if include { |
| 284 | out := singleton.Output(snapshotPath) |
| 285 | if out.Input.String() != outputFiles[0].String() { |
| 286 | t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFiles[0]) |
| 287 | } |
| 288 | } else { |
| 289 | out := singleton.MaybeOutput(snapshotPath) |
| 290 | if out.Rule != nil { |
| 291 | t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0]) |
| 292 | } |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 296 | func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 297 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true) |
| 298 | } |
| 299 | |
| 300 | func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) { |
| 301 | checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false) |
| 302 | } |
| 303 | |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 304 | func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) { |
| 305 | t.Helper() |
| Colin Cross | cf371cc | 2020-11-13 11:48:42 -0800 | [diff] [blame] | 306 | content := android.ContentFromFileRuleForTests(t, params) |
| 307 | actual := strings.FieldsFunc(content, func(r rune) bool { return r == '\n' }) |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 308 | assertArrayString(t, actual, expected) |
| 309 | } |
| 310 | |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 311 | func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) { |
| 312 | t.Helper() |
| 313 | vndkSnapshot := ctx.SingletonForTests("vndk-snapshot") |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 314 | checkWriteFileOutput(t, vndkSnapshot.Output(output), expected) |
| 315 | } |
| 316 | |
| 317 | func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []string) { |
| 318 | t.Helper() |
| Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 319 | got := ctx.ModuleForTests(module, "").Module().(*vndkLibrariesTxt).fileNames |
| 320 | assertArrayString(t, got, expected) |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 321 | } |
| 322 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 323 | func TestVndk(t *testing.T) { |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 324 | bp := ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 325 | cc_library { |
| 326 | name: "libvndk", |
| 327 | vendor_available: true, |
| 328 | vndk: { |
| 329 | enabled: true, |
| 330 | }, |
| 331 | nocrt: true, |
| 332 | } |
| 333 | |
| 334 | cc_library { |
| 335 | name: "libvndk_private", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 336 | vendor_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 337 | vndk: { |
| 338 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 339 | private: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 340 | }, |
| 341 | nocrt: true, |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 342 | stem: "libvndk-private", |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | cc_library { |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 346 | name: "libvndk_product", |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 347 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 348 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 349 | vndk: { |
| 350 | enabled: true, |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 351 | }, |
| 352 | nocrt: true, |
| 353 | target: { |
| 354 | vendor: { |
| 355 | cflags: ["-DTEST"], |
| 356 | }, |
| 357 | product: { |
| 358 | cflags: ["-DTEST"], |
| 359 | }, |
| 360 | }, |
| 361 | } |
| 362 | |
| 363 | cc_library { |
| 364 | name: "libvndk_sp", |
| 365 | vendor_available: true, |
| 366 | vndk: { |
| 367 | enabled: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 368 | support_system_process: true, |
| 369 | }, |
| 370 | nocrt: true, |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 371 | suffix: "-x", |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | cc_library { |
| 375 | name: "libvndk_sp_private", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 376 | vendor_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 377 | vndk: { |
| 378 | enabled: true, |
| 379 | support_system_process: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 380 | private: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 381 | }, |
| 382 | nocrt: true, |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 383 | target: { |
| 384 | vendor: { |
| 385 | suffix: "-x", |
| 386 | }, |
| 387 | }, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 388 | } |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 389 | |
| 390 | cc_library { |
| 391 | name: "libvndk_sp_product_private", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 392 | vendor_available: true, |
| 393 | product_available: true, |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 394 | vndk: { |
| 395 | enabled: true, |
| 396 | support_system_process: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 397 | private: true, |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 398 | }, |
| 399 | nocrt: true, |
| 400 | target: { |
| 401 | vendor: { |
| 402 | suffix: "-x", |
| 403 | }, |
| 404 | product: { |
| 405 | suffix: "-x", |
| 406 | }, |
| 407 | }, |
| 408 | } |
| 409 | |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 410 | llndk_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 411 | name: "llndk.libraries.txt", |
| 412 | } |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 413 | vndkcore_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 414 | name: "vndkcore.libraries.txt", |
| 415 | } |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 416 | vndksp_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 417 | name: "vndksp.libraries.txt", |
| 418 | } |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 419 | vndkprivate_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 420 | name: "vndkprivate.libraries.txt", |
| 421 | } |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 422 | vndkproduct_libraries_txt { |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 423 | name: "vndkproduct.libraries.txt", |
| 424 | } |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 425 | vndkcorevariant_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 426 | name: "vndkcorevariant.libraries.txt", |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 427 | insert_vndk_version: false, |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 428 | } |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 429 | ` |
| 430 | |
| 431 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 432 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 433 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 434 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 435 | |
| 436 | ctx := testCcWithConfig(t, config) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 437 | |
| Jooyung Han | 261e158 | 2020-10-20 18:54:21 +0900 | [diff] [blame] | 438 | // subdir == "" because VNDK libs are not supposed to be installed separately. |
| 439 | // They are installed as part of VNDK APEX instead. |
| 440 | checkVndkModule(t, ctx, "libvndk", "", false, "", vendorVariant) |
| 441 | checkVndkModule(t, ctx, "libvndk_private", "", false, "", vendorVariant) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 442 | checkVndkModule(t, ctx, "libvndk_product", "", false, "", vendorVariant) |
| Jooyung Han | 261e158 | 2020-10-20 18:54:21 +0900 | [diff] [blame] | 443 | checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant) |
| 444 | checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 445 | checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", vendorVariant) |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 446 | |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 447 | checkVndkModule(t, ctx, "libvndk_product", "", false, "", productVariant) |
| 448 | checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", productVariant) |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 449 | |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 450 | // Check VNDK snapshot output. |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 451 | snapshotDir := "vndk-snapshot" |
| 452 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 453 | |
| 454 | vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", |
| 455 | "arm64", "armv8-a")) |
| 456 | vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s", |
| 457 | "arm", "armv7-a-neon")) |
| 458 | |
| 459 | vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core") |
| 460 | vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp") |
| 461 | vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core") |
| 462 | vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp") |
| 463 | |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 464 | variant := "android_vendor.VER_arm64_armv8-a_shared" |
| 465 | variant2nd := "android_vendor.VER_arm_armv7-a-neon_shared" |
| Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 466 | |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 467 | snapshotSingleton := ctx.SingletonForTests("vndk-snapshot") |
| 468 | |
| 469 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant) |
| 470 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 471 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLibPath, variant) |
| 472 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLib2ndPath, variant2nd) |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 473 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant) |
| 474 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, variant2nd) |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 475 | |
| Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 476 | snapshotConfigsPath := filepath.Join(snapshotVariantPath, "configs") |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 477 | checkSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotConfigsPath, "") |
| 478 | checkSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "") |
| 479 | checkSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "") |
| 480 | checkSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "") |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 481 | checkSnapshot(t, ctx, snapshotSingleton, "vndkproduct.libraries.txt", "vndkproduct.libraries.txt", snapshotConfigsPath, "") |
| Jooyung Han | 39edb6c | 2019-11-06 16:53:07 +0900 | [diff] [blame] | 482 | |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 483 | checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{ |
| 484 | "LLNDK: libc.so", |
| 485 | "LLNDK: libdl.so", |
| 486 | "LLNDK: libft2.so", |
| 487 | "LLNDK: libm.so", |
| 488 | "VNDK-SP: libc++.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 489 | "VNDK-SP: libvndk_sp-x.so", |
| 490 | "VNDK-SP: libvndk_sp_private-x.so", |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 491 | "VNDK-SP: libvndk_sp_product_private-x.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 492 | "VNDK-core: libvndk-private.so", |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 493 | "VNDK-core: libvndk.so", |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 494 | "VNDK-core: libvndk_product.so", |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 495 | "VNDK-private: libft2.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 496 | "VNDK-private: libvndk-private.so", |
| 497 | "VNDK-private: libvndk_sp_private-x.so", |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 498 | "VNDK-private: libvndk_sp_product_private-x.so", |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 499 | "VNDK-product: libc++.so", |
| 500 | "VNDK-product: libvndk_product.so", |
| 501 | "VNDK-product: libvndk_sp_product_private-x.so", |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 502 | }) |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 503 | checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libdl.so", "libft2.so", "libm.so"}) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 504 | checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so", "libvndk_product.so"}) |
| 505 | checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) |
| 506 | checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"}) |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 507 | checkVndkLibrariesOutput(t, ctx, "vndkproduct.libraries.txt", []string{"libc++.so", "libvndk_product.so", "libvndk_sp_product_private-x.so"}) |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 508 | checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil) |
| 509 | } |
| 510 | |
| Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 511 | func TestVndkWithHostSupported(t *testing.T) { |
| 512 | ctx := testCc(t, ` |
| 513 | cc_library { |
| 514 | name: "libvndk_host_supported", |
| 515 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 516 | product_available: true, |
| Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 517 | vndk: { |
| 518 | enabled: true, |
| 519 | }, |
| 520 | host_supported: true, |
| 521 | } |
| 522 | |
| 523 | cc_library { |
| 524 | name: "libvndk_host_supported_but_disabled_on_device", |
| 525 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 526 | product_available: true, |
| Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 527 | vndk: { |
| 528 | enabled: true, |
| 529 | }, |
| 530 | host_supported: true, |
| 531 | enabled: false, |
| 532 | target: { |
| 533 | host: { |
| 534 | enabled: true, |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 539 | vndkcore_libraries_txt { |
| Yo Chiang | bba545e | 2020-06-09 16:15:37 +0800 | [diff] [blame] | 540 | name: "vndkcore.libraries.txt", |
| 541 | } |
| 542 | `) |
| 543 | |
| 544 | checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"}) |
| 545 | } |
| 546 | |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 547 | func TestVndkLibrariesTxtAndroidMk(t *testing.T) { |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 548 | bp := ` |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 549 | llndk_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 550 | name: "llndk.libraries.txt", |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 551 | insert_vndk_version: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 552 | }` |
| 553 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 554 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 555 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 556 | ctx := testCcWithConfig(t, config) |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 557 | |
| 558 | module := ctx.ModuleForTests("llndk.libraries.txt", "") |
| Jiyong Park | 0b0e1b9 | 2019-12-03 13:24:29 +0900 | [diff] [blame] | 559 | entries := android.AndroidMkEntriesForTest(t, config, "", module.Module())[0] |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 560 | assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"}) |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | func TestVndkUsingCoreVariant(t *testing.T) { |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 564 | bp := ` |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 565 | cc_library { |
| 566 | name: "libvndk", |
| 567 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 568 | product_available: true, |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 569 | vndk: { |
| 570 | enabled: true, |
| 571 | }, |
| 572 | nocrt: true, |
| 573 | } |
| 574 | |
| 575 | cc_library { |
| 576 | name: "libvndk_sp", |
| 577 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 578 | product_available: true, |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 579 | vndk: { |
| 580 | enabled: true, |
| 581 | support_system_process: true, |
| 582 | }, |
| 583 | nocrt: true, |
| 584 | } |
| 585 | |
| 586 | cc_library { |
| 587 | name: "libvndk2", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 588 | vendor_available: true, |
| 589 | product_available: true, |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 590 | vndk: { |
| 591 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 592 | private: true, |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 593 | }, |
| 594 | nocrt: true, |
| 595 | } |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 596 | |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 597 | vndkcorevariant_libraries_txt { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 598 | name: "vndkcorevariant.libraries.txt", |
| Colin Cross | e4e44bc | 2020-12-28 13:50:21 -0800 | [diff] [blame] | 599 | insert_vndk_version: false, |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 600 | } |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 601 | ` |
| 602 | |
| 603 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 604 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 605 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 606 | config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) |
| 607 | |
| 608 | setVndkMustUseVendorVariantListForTest(config, []string{"libvndk"}) |
| 609 | |
| 610 | ctx := testCcWithConfig(t, config) |
| Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 611 | |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 612 | checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", []string{"libc++.so", "libvndk2.so", "libvndk_sp.so"}) |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 613 | } |
| 614 | |
| Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 615 | func TestDataLibs(t *testing.T) { |
| 616 | bp := ` |
| 617 | cc_test_library { |
| 618 | name: "test_lib", |
| 619 | srcs: ["test_lib.cpp"], |
| 620 | gtest: false, |
| 621 | } |
| 622 | |
| 623 | cc_test { |
| 624 | name: "main_test", |
| 625 | data_libs: ["test_lib"], |
| 626 | gtest: false, |
| 627 | } |
| Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 628 | ` |
| Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 629 | |
| 630 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 631 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 632 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 633 | config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) |
| 634 | |
| 635 | ctx := testCcWithConfig(t, config) |
| 636 | module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() |
| 637 | testBinary := module.(*Module).linker.(*testBinary) |
| 638 | outputFiles, err := module.(android.OutputFileProducer).OutputFiles("") |
| 639 | if err != nil { |
| 640 | t.Errorf("Expected cc_test to produce output files, error: %s", err) |
| 641 | return |
| 642 | } |
| 643 | if len(outputFiles) != 1 { |
| 644 | t.Errorf("expected exactly one output file. output files: [%s]", outputFiles) |
| 645 | return |
| 646 | } |
| 647 | if len(testBinary.dataPaths()) != 1 { |
| 648 | t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) |
| 649 | return |
| 650 | } |
| 651 | |
| 652 | outputPath := outputFiles[0].String() |
| Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 653 | testBinaryPath := testBinary.dataPaths()[0].SrcPath.String() |
| Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 654 | |
| 655 | if !strings.HasSuffix(outputPath, "/main_test") { |
| 656 | t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath) |
| 657 | return |
| 658 | } |
| 659 | if !strings.HasSuffix(testBinaryPath, "/test_lib.so") { |
| 660 | t.Errorf("expected test data file to be 'test_lib.so', but was '%s'", testBinaryPath) |
| 661 | return |
| 662 | } |
| 663 | } |
| 664 | |
| Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 665 | func TestDataLibsRelativeInstallPath(t *testing.T) { |
| 666 | bp := ` |
| 667 | cc_test_library { |
| 668 | name: "test_lib", |
| 669 | srcs: ["test_lib.cpp"], |
| 670 | relative_install_path: "foo/bar/baz", |
| 671 | gtest: false, |
| 672 | } |
| 673 | |
| 674 | cc_test { |
| 675 | name: "main_test", |
| 676 | data_libs: ["test_lib"], |
| 677 | gtest: false, |
| 678 | } |
| 679 | ` |
| 680 | |
| 681 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 682 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 683 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 684 | config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) |
| 685 | |
| 686 | ctx := testCcWithConfig(t, config) |
| 687 | module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() |
| 688 | testBinary := module.(*Module).linker.(*testBinary) |
| 689 | outputFiles, err := module.(android.OutputFileProducer).OutputFiles("") |
| 690 | if err != nil { |
| 691 | t.Fatalf("Expected cc_test to produce output files, error: %s", err) |
| 692 | } |
| 693 | if len(outputFiles) != 1 { |
| 694 | t.Errorf("expected exactly one output file. output files: [%s]", outputFiles) |
| 695 | } |
| 696 | if len(testBinary.dataPaths()) != 1 { |
| 697 | t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) |
| 698 | } |
| 699 | |
| 700 | outputPath := outputFiles[0].String() |
| Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 701 | |
| 702 | if !strings.HasSuffix(outputPath, "/main_test") { |
| 703 | t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath) |
| 704 | } |
| 705 | entries := android.AndroidMkEntriesForTest(t, config, "", module)[0] |
| 706 | if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") { |
| 707 | t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+ |
| Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 708 | " but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0]) |
| Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 709 | } |
| 710 | } |
| 711 | |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 712 | func TestVndkWhenVndkVersionIsNotSet(t *testing.T) { |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 713 | ctx := testCcNoVndk(t, ` |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 714 | cc_library { |
| 715 | name: "libvndk", |
| 716 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 717 | product_available: true, |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 718 | vndk: { |
| 719 | enabled: true, |
| 720 | }, |
| 721 | nocrt: true, |
| 722 | } |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 723 | cc_library { |
| 724 | name: "libvndk-private", |
| Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 725 | vendor_available: true, |
| 726 | product_available: true, |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 727 | vndk: { |
| 728 | enabled: true, |
| Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 729 | private: true, |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 730 | }, |
| 731 | nocrt: true, |
| 732 | } |
| Colin Cross | b5f6fa6 | 2021-01-06 17:05:04 -0800 | [diff] [blame] | 733 | |
| 734 | cc_library { |
| 735 | name: "libllndk", |
| 736 | llndk_stubs: "libllndk.llndk", |
| 737 | } |
| 738 | |
| 739 | llndk_library { |
| 740 | name: "libllndk.llndk", |
| 741 | symbol_file: "", |
| 742 | export_llndk_headers: ["libllndk_headers"], |
| 743 | } |
| 744 | |
| 745 | llndk_headers { |
| 746 | name: "libllndk_headers", |
| 747 | export_include_dirs: ["include"], |
| 748 | } |
| Jooyung Han | 2216fb1 | 2019-11-06 16:46:15 +0900 | [diff] [blame] | 749 | `) |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 750 | |
| 751 | checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{ |
| 752 | "LLNDK: libc.so", |
| 753 | "LLNDK: libdl.so", |
| 754 | "LLNDK: libft2.so", |
| Colin Cross | b5f6fa6 | 2021-01-06 17:05:04 -0800 | [diff] [blame] | 755 | "LLNDK: libllndk.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 756 | "LLNDK: libm.so", |
| 757 | "VNDK-SP: libc++.so", |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 758 | "VNDK-core: libvndk-private.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 759 | "VNDK-core: libvndk.so", |
| 760 | "VNDK-private: libft2.so", |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 761 | "VNDK-private: libvndk-private.so", |
| 762 | "VNDK-product: libc++.so", |
| 763 | "VNDK-product: libvndk-private.so", |
| 764 | "VNDK-product: libvndk.so", |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 765 | }) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 766 | } |
| 767 | |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 768 | func TestVndkModuleError(t *testing.T) { |
| 769 | // Check the error message for vendor_available and product_available properties. |
| Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 770 | testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", ` |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 771 | cc_library { |
| 772 | name: "libvndk", |
| 773 | vndk: { |
| 774 | enabled: true, |
| 775 | }, |
| 776 | nocrt: true, |
| 777 | } |
| 778 | `) |
| 779 | |
| Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 780 | testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", ` |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 781 | cc_library { |
| 782 | name: "libvndk", |
| 783 | product_available: true, |
| 784 | vndk: { |
| 785 | enabled: true, |
| 786 | }, |
| 787 | nocrt: true, |
| 788 | } |
| 789 | `) |
| 790 | |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 791 | testCcErrorProductVndk(t, "product properties must have the same values with the vendor properties for VNDK modules", ` |
| 792 | cc_library { |
| 793 | name: "libvndkprop", |
| 794 | vendor_available: true, |
| 795 | product_available: true, |
| 796 | vndk: { |
| 797 | enabled: true, |
| 798 | }, |
| 799 | nocrt: true, |
| 800 | target: { |
| 801 | vendor: { |
| 802 | cflags: ["-DTEST",], |
| 803 | }, |
| 804 | }, |
| 805 | } |
| 806 | `) |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 807 | } |
| 808 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 809 | func TestVndkDepError(t *testing.T) { |
| 810 | // Check whether an error is emitted when a VNDK lib depends on a system lib. |
| 811 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 812 | cc_library { |
| 813 | name: "libvndk", |
| 814 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 815 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 816 | vndk: { |
| 817 | enabled: true, |
| 818 | }, |
| 819 | shared_libs: ["libfwk"], // Cause error |
| 820 | nocrt: true, |
| 821 | } |
| 822 | |
| 823 | cc_library { |
| 824 | name: "libfwk", |
| 825 | nocrt: true, |
| 826 | } |
| 827 | `) |
| 828 | |
| 829 | // Check whether an error is emitted when a VNDK lib depends on a vendor lib. |
| 830 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 831 | cc_library { |
| 832 | name: "libvndk", |
| 833 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 834 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 835 | vndk: { |
| 836 | enabled: true, |
| 837 | }, |
| 838 | shared_libs: ["libvendor"], // Cause error |
| 839 | nocrt: true, |
| 840 | } |
| 841 | |
| 842 | cc_library { |
| 843 | name: "libvendor", |
| 844 | vendor: true, |
| 845 | nocrt: true, |
| 846 | } |
| 847 | `) |
| 848 | |
| 849 | // Check whether an error is emitted when a VNDK-SP lib depends on a system lib. |
| 850 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 851 | cc_library { |
| 852 | name: "libvndk_sp", |
| 853 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 854 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 855 | vndk: { |
| 856 | enabled: true, |
| 857 | support_system_process: true, |
| 858 | }, |
| 859 | shared_libs: ["libfwk"], // Cause error |
| 860 | nocrt: true, |
| 861 | } |
| 862 | |
| 863 | cc_library { |
| 864 | name: "libfwk", |
| 865 | nocrt: true, |
| 866 | } |
| 867 | `) |
| 868 | |
| 869 | // Check whether an error is emitted when a VNDK-SP lib depends on a vendor lib. |
| 870 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 871 | cc_library { |
| 872 | name: "libvndk_sp", |
| 873 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 874 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 875 | vndk: { |
| 876 | enabled: true, |
| 877 | support_system_process: true, |
| 878 | }, |
| 879 | shared_libs: ["libvendor"], // Cause error |
| 880 | nocrt: true, |
| 881 | } |
| 882 | |
| 883 | cc_library { |
| 884 | name: "libvendor", |
| 885 | vendor: true, |
| 886 | nocrt: true, |
| 887 | } |
| 888 | `) |
| 889 | |
| 890 | // Check whether an error is emitted when a VNDK-SP lib depends on a VNDK lib. |
| 891 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 892 | cc_library { |
| 893 | name: "libvndk_sp", |
| 894 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 895 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 896 | vndk: { |
| 897 | enabled: true, |
| 898 | support_system_process: true, |
| 899 | }, |
| 900 | shared_libs: ["libvndk"], // Cause error |
| 901 | nocrt: true, |
| 902 | } |
| 903 | |
| 904 | cc_library { |
| 905 | name: "libvndk", |
| 906 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 907 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 908 | vndk: { |
| 909 | enabled: true, |
| 910 | }, |
| 911 | nocrt: true, |
| 912 | } |
| 913 | `) |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 914 | |
| 915 | // Check whether an error is emitted when a VNDK lib depends on a non-VNDK lib. |
| 916 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 917 | cc_library { |
| 918 | name: "libvndk", |
| 919 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 920 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 921 | vndk: { |
| 922 | enabled: true, |
| 923 | }, |
| 924 | shared_libs: ["libnonvndk"], |
| 925 | nocrt: true, |
| 926 | } |
| 927 | |
| 928 | cc_library { |
| 929 | name: "libnonvndk", |
| 930 | vendor_available: true, |
| 931 | nocrt: true, |
| 932 | } |
| 933 | `) |
| 934 | |
| 935 | // Check whether an error is emitted when a VNDK-private lib depends on a non-VNDK lib. |
| 936 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 937 | cc_library { |
| 938 | name: "libvndkprivate", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 939 | vendor_available: true, |
| 940 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 941 | vndk: { |
| 942 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 943 | private: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 944 | }, |
| 945 | shared_libs: ["libnonvndk"], |
| 946 | nocrt: true, |
| 947 | } |
| 948 | |
| 949 | cc_library { |
| 950 | name: "libnonvndk", |
| 951 | vendor_available: true, |
| 952 | nocrt: true, |
| 953 | } |
| 954 | `) |
| 955 | |
| 956 | // Check whether an error is emitted when a VNDK-sp lib depends on a non-VNDK lib. |
| 957 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 958 | cc_library { |
| 959 | name: "libvndksp", |
| 960 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 961 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 962 | vndk: { |
| 963 | enabled: true, |
| 964 | support_system_process: true, |
| 965 | }, |
| 966 | shared_libs: ["libnonvndk"], |
| 967 | nocrt: true, |
| 968 | } |
| 969 | |
| 970 | cc_library { |
| 971 | name: "libnonvndk", |
| 972 | vendor_available: true, |
| 973 | nocrt: true, |
| 974 | } |
| 975 | `) |
| 976 | |
| 977 | // Check whether an error is emitted when a VNDK-sp-private lib depends on a non-VNDK lib. |
| 978 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 979 | cc_library { |
| 980 | name: "libvndkspprivate", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 981 | vendor_available: true, |
| 982 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 983 | vndk: { |
| 984 | enabled: true, |
| 985 | support_system_process: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 986 | private: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 987 | }, |
| 988 | shared_libs: ["libnonvndk"], |
| 989 | nocrt: true, |
| 990 | } |
| 991 | |
| 992 | cc_library { |
| 993 | name: "libnonvndk", |
| 994 | vendor_available: true, |
| 995 | nocrt: true, |
| 996 | } |
| 997 | `) |
| 998 | } |
| 999 | |
| 1000 | func TestDoubleLoadbleDep(t *testing.T) { |
| 1001 | // okay to link : LLNDK -> double_loadable VNDK |
| 1002 | testCc(t, ` |
| 1003 | cc_library { |
| 1004 | name: "libllndk", |
| 1005 | shared_libs: ["libdoubleloadable"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1006 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1010 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1011 | symbol_file: "", |
| 1012 | } |
| 1013 | |
| 1014 | cc_library { |
| 1015 | name: "libdoubleloadable", |
| 1016 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1017 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1018 | vndk: { |
| 1019 | enabled: true, |
| 1020 | }, |
| 1021 | double_loadable: true, |
| 1022 | } |
| 1023 | `) |
| 1024 | // okay to link : LLNDK -> VNDK-SP |
| 1025 | testCc(t, ` |
| 1026 | cc_library { |
| 1027 | name: "libllndk", |
| 1028 | shared_libs: ["libvndksp"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1029 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1033 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1034 | symbol_file: "", |
| 1035 | } |
| 1036 | |
| 1037 | cc_library { |
| 1038 | name: "libvndksp", |
| 1039 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1040 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1041 | vndk: { |
| 1042 | enabled: true, |
| 1043 | support_system_process: true, |
| 1044 | }, |
| 1045 | } |
| 1046 | `) |
| 1047 | // okay to link : double_loadable -> double_loadable |
| 1048 | testCc(t, ` |
| 1049 | cc_library { |
| 1050 | name: "libdoubleloadable1", |
| 1051 | shared_libs: ["libdoubleloadable2"], |
| 1052 | vendor_available: true, |
| 1053 | double_loadable: true, |
| 1054 | } |
| 1055 | |
| 1056 | cc_library { |
| 1057 | name: "libdoubleloadable2", |
| 1058 | vendor_available: true, |
| 1059 | double_loadable: true, |
| 1060 | } |
| 1061 | `) |
| 1062 | // okay to link : double_loadable VNDK -> double_loadable VNDK private |
| 1063 | testCc(t, ` |
| 1064 | cc_library { |
| 1065 | name: "libdoubleloadable", |
| 1066 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1067 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1068 | vndk: { |
| 1069 | enabled: true, |
| 1070 | }, |
| 1071 | double_loadable: true, |
| 1072 | shared_libs: ["libnondoubleloadable"], |
| 1073 | } |
| 1074 | |
| 1075 | cc_library { |
| 1076 | name: "libnondoubleloadable", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 1077 | vendor_available: true, |
| 1078 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1079 | vndk: { |
| 1080 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 1081 | private: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1082 | }, |
| 1083 | double_loadable: true, |
| 1084 | } |
| 1085 | `) |
| 1086 | // okay to link : LLNDK -> core-only -> vendor_available & double_loadable |
| 1087 | testCc(t, ` |
| 1088 | cc_library { |
| 1089 | name: "libllndk", |
| 1090 | shared_libs: ["libcoreonly"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1091 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 1095 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1096 | symbol_file: "", |
| 1097 | } |
| 1098 | |
| 1099 | cc_library { |
| 1100 | name: "libcoreonly", |
| 1101 | shared_libs: ["libvendoravailable"], |
| 1102 | } |
| 1103 | |
| 1104 | // indirect dependency of LLNDK |
| 1105 | cc_library { |
| 1106 | name: "libvendoravailable", |
| 1107 | vendor_available: true, |
| 1108 | double_loadable: true, |
| 1109 | } |
| 1110 | `) |
| 1111 | } |
| 1112 | |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1113 | func TestVendorSnapshotCapture(t *testing.T) { |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1114 | bp := ` |
| 1115 | cc_library { |
| 1116 | name: "libvndk", |
| 1117 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1118 | product_available: true, |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1119 | vndk: { |
| 1120 | enabled: true, |
| 1121 | }, |
| 1122 | nocrt: true, |
| 1123 | } |
| 1124 | |
| 1125 | cc_library { |
| 1126 | name: "libvendor", |
| 1127 | vendor: true, |
| 1128 | nocrt: true, |
| 1129 | } |
| 1130 | |
| 1131 | cc_library { |
| 1132 | name: "libvendor_available", |
| 1133 | vendor_available: true, |
| 1134 | nocrt: true, |
| 1135 | } |
| 1136 | |
| 1137 | cc_library_headers { |
| 1138 | name: "libvendor_headers", |
| 1139 | vendor_available: true, |
| 1140 | nocrt: true, |
| 1141 | } |
| 1142 | |
| 1143 | cc_binary { |
| 1144 | name: "vendor_bin", |
| 1145 | vendor: true, |
| 1146 | nocrt: true, |
| 1147 | } |
| 1148 | |
| 1149 | cc_binary { |
| 1150 | name: "vendor_available_bin", |
| 1151 | vendor_available: true, |
| 1152 | nocrt: true, |
| 1153 | } |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1154 | |
| 1155 | toolchain_library { |
| 1156 | name: "libb", |
| 1157 | vendor_available: true, |
| 1158 | src: "libb.a", |
| 1159 | } |
| Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 1160 | |
| 1161 | cc_object { |
| 1162 | name: "obj", |
| 1163 | vendor_available: true, |
| 1164 | } |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 1165 | |
| 1166 | cc_library { |
| 1167 | name: "libllndk", |
| 1168 | llndk_stubs: "libllndk.llndk", |
| 1169 | } |
| 1170 | |
| 1171 | llndk_library { |
| 1172 | name: "libllndk.llndk", |
| 1173 | symbol_file: "", |
| 1174 | } |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1175 | ` |
| 1176 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 1177 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1178 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1179 | ctx := testCcWithConfig(t, config) |
| 1180 | |
| 1181 | // Check Vendor snapshot output. |
| 1182 | |
| 1183 | snapshotDir := "vendor-snapshot" |
| 1184 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1185 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1186 | |
| 1187 | var jsonFiles []string |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1188 | |
| 1189 | for _, arch := range [][]string{ |
| 1190 | []string{"arm64", "armv8-a"}, |
| 1191 | []string{"arm", "armv7-a-neon"}, |
| 1192 | } { |
| 1193 | archType := arch[0] |
| 1194 | archVariant := arch[1] |
| 1195 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1196 | |
| 1197 | // For shared libraries, only non-VNDK vendor_available modules are captured |
| 1198 | sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant) |
| 1199 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1200 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 1201 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant) |
| 1202 | jsonFiles = append(jsonFiles, |
| 1203 | filepath.Join(sharedDir, "libvendor.so.json"), |
| 1204 | filepath.Join(sharedDir, "libvendor_available.so.json")) |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1205 | |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 1206 | // LLNDK modules are not captured |
| 1207 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", sharedDir, sharedVariant) |
| 1208 | |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1209 | // For static libraries, all vendor:true and vendor_available modules (including VNDK) are captured. |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1210 | // Also cfi variants are captured, except for prebuilts like toolchain_library |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1211 | staticVariant := fmt.Sprintf("android_vendor.VER_%s_%s_static", archType, archVariant) |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1212 | staticCfiVariant := fmt.Sprintf("android_vendor.VER_%s_%s_static_cfi", archType, archVariant) |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1213 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1214 | checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1215 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.a", staticDir, staticVariant) |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1216 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.cfi.a", staticDir, staticCfiVariant) |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1217 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.a", staticDir, staticVariant) |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1218 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.cfi.a", staticDir, staticCfiVariant) |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1219 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.a", staticDir, staticVariant) |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1220 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.cfi.a", staticDir, staticCfiVariant) |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1221 | jsonFiles = append(jsonFiles, |
| 1222 | filepath.Join(staticDir, "libb.a.json"), |
| 1223 | filepath.Join(staticDir, "libvndk.a.json"), |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1224 | filepath.Join(staticDir, "libvndk.cfi.a.json"), |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1225 | filepath.Join(staticDir, "libvendor.a.json"), |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1226 | filepath.Join(staticDir, "libvendor.cfi.a.json"), |
| 1227 | filepath.Join(staticDir, "libvendor_available.a.json"), |
| 1228 | filepath.Join(staticDir, "libvendor_available.cfi.a.json")) |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1229 | |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1230 | // For binary executables, all vendor:true and vendor_available modules are captured. |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1231 | if archType == "arm64" { |
| 1232 | binaryVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant) |
| 1233 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1234 | checkSnapshot(t, ctx, snapshotSingleton, "vendor_bin", "vendor_bin", binaryDir, binaryVariant) |
| 1235 | checkSnapshot(t, ctx, snapshotSingleton, "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant) |
| 1236 | jsonFiles = append(jsonFiles, |
| 1237 | filepath.Join(binaryDir, "vendor_bin.json"), |
| 1238 | filepath.Join(binaryDir, "vendor_available_bin.json")) |
| 1239 | } |
| 1240 | |
| 1241 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1242 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1243 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "libvendor_headers.json")) |
| Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 1244 | |
| 1245 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1246 | objectVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant) |
| 1247 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
| 1248 | checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
| 1249 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1250 | } |
| 1251 | |
| 1252 | for _, jsonFile := range jsonFiles { |
| 1253 | // verify all json files exist |
| 1254 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1255 | t.Errorf("%q expected but not found", jsonFile) |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1256 | } |
| 1257 | } |
| Inseob Kim | e9aec6a | 2021-01-05 20:03:22 +0900 | [diff] [blame] | 1258 | |
| 1259 | // fake snapshot should have all outputs in the normal snapshot. |
| 1260 | fakeSnapshotSingleton := ctx.SingletonForTests("vendor-fake-snapshot") |
| 1261 | for _, output := range snapshotSingleton.AllOutputs() { |
| 1262 | fakeOutput := strings.Replace(output, "/vendor-snapshot/", "/fake/vendor-snapshot/", 1) |
| 1263 | if fakeSnapshotSingleton.MaybeOutput(fakeOutput).Rule == nil { |
| 1264 | t.Errorf("%q expected but not found", fakeOutput) |
| 1265 | } |
| 1266 | } |
| Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1267 | } |
| 1268 | |
| Inseob Kim | 7cf1465 | 2021-01-06 23:06:52 +0900 | [diff] [blame] | 1269 | func TestVendorSnapshotDirected(t *testing.T) { |
| 1270 | bp := ` |
| 1271 | cc_library_shared { |
| 1272 | name: "libvendor", |
| 1273 | vendor: true, |
| 1274 | nocrt: true, |
| 1275 | } |
| 1276 | |
| 1277 | cc_library_shared { |
| 1278 | name: "libvendor_available", |
| 1279 | vendor_available: true, |
| 1280 | nocrt: true, |
| 1281 | } |
| 1282 | |
| 1283 | genrule { |
| 1284 | name: "libfoo_gen", |
| 1285 | cmd: "", |
| 1286 | out: ["libfoo.so"], |
| 1287 | } |
| 1288 | |
| 1289 | cc_prebuilt_library_shared { |
| 1290 | name: "libfoo", |
| 1291 | vendor: true, |
| 1292 | prefer: true, |
| 1293 | srcs: [":libfoo_gen"], |
| 1294 | } |
| 1295 | |
| 1296 | cc_library_shared { |
| 1297 | name: "libfoo", |
| 1298 | vendor: true, |
| 1299 | nocrt: true, |
| 1300 | } |
| 1301 | ` |
| 1302 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 1303 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1304 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1305 | config.TestProductVariables.DirectedVendorSnapshot = true |
| 1306 | config.TestProductVariables.VendorSnapshotModules = make(map[string]bool) |
| 1307 | config.TestProductVariables.VendorSnapshotModules["libvendor"] = true |
| 1308 | config.TestProductVariables.VendorSnapshotModules["libfoo"] = true |
| 1309 | ctx := testCcWithConfig(t, config) |
| 1310 | |
| 1311 | // Check Vendor snapshot output. |
| 1312 | |
| 1313 | snapshotDir := "vendor-snapshot" |
| 1314 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1315 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1316 | |
| 1317 | var includeJsonFiles []string |
| 1318 | var excludeJsonFiles []string |
| 1319 | |
| 1320 | for _, arch := range [][]string{ |
| 1321 | []string{"arm64", "armv8-a"}, |
| 1322 | []string{"arm", "armv7-a-neon"}, |
| 1323 | } { |
| 1324 | archType := arch[0] |
| 1325 | archVariant := arch[1] |
| 1326 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1327 | |
| 1328 | sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant) |
| 1329 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1330 | |
| 1331 | // Included modules |
| 1332 | checkSnapshot(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 1333 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
| 1334 | // Check that snapshot captures "prefer: true" prebuilt |
| 1335 | checkSnapshot(t, ctx, snapshotSingleton, "prebuilt_libfoo", "libfoo.so", sharedDir, sharedVariant) |
| 1336 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libfoo.so.json")) |
| 1337 | |
| 1338 | // Excluded modules |
| 1339 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant) |
| 1340 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor_available.so.json")) |
| 1341 | } |
| 1342 | |
| 1343 | // Verify that each json file for an included module has a rule. |
| 1344 | for _, jsonFile := range includeJsonFiles { |
| 1345 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1346 | t.Errorf("include json file %q not found", jsonFile) |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | // Verify that each json file for an excluded module has no rule. |
| 1351 | for _, jsonFile := range excludeJsonFiles { |
| 1352 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1353 | t.Errorf("exclude json file %q found", jsonFile) |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1358 | func TestVendorSnapshotUse(t *testing.T) { |
| 1359 | frameworkBp := ` |
| 1360 | cc_library { |
| 1361 | name: "libvndk", |
| 1362 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1363 | product_available: true, |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1364 | vndk: { |
| 1365 | enabled: true, |
| 1366 | }, |
| 1367 | nocrt: true, |
| 1368 | compile_multilib: "64", |
| 1369 | } |
| 1370 | |
| 1371 | cc_library { |
| 1372 | name: "libvendor", |
| 1373 | vendor: true, |
| 1374 | nocrt: true, |
| 1375 | no_libcrt: true, |
| 1376 | stl: "none", |
| 1377 | system_shared_libs: [], |
| 1378 | compile_multilib: "64", |
| 1379 | } |
| 1380 | |
| 1381 | cc_binary { |
| 1382 | name: "bin", |
| 1383 | vendor: true, |
| 1384 | nocrt: true, |
| 1385 | no_libcrt: true, |
| 1386 | stl: "none", |
| 1387 | system_shared_libs: [], |
| 1388 | compile_multilib: "64", |
| 1389 | } |
| 1390 | ` |
| 1391 | |
| 1392 | vndkBp := ` |
| 1393 | vndk_prebuilt_shared { |
| 1394 | name: "libvndk", |
| 1395 | version: "BOARD", |
| 1396 | target_arch: "arm64", |
| 1397 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 1398 | product_available: true, |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1399 | vndk: { |
| 1400 | enabled: true, |
| 1401 | }, |
| 1402 | arch: { |
| 1403 | arm64: { |
| 1404 | srcs: ["libvndk.so"], |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1405 | export_include_dirs: ["include/libvndk"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1406 | }, |
| 1407 | }, |
| 1408 | } |
| 1409 | ` |
| 1410 | |
| 1411 | vendorProprietaryBp := ` |
| 1412 | cc_library { |
| 1413 | name: "libvendor_without_snapshot", |
| 1414 | vendor: true, |
| 1415 | nocrt: true, |
| 1416 | no_libcrt: true, |
| 1417 | stl: "none", |
| 1418 | system_shared_libs: [], |
| 1419 | compile_multilib: "64", |
| 1420 | } |
| 1421 | |
| 1422 | cc_library_shared { |
| 1423 | name: "libclient", |
| 1424 | vendor: true, |
| 1425 | nocrt: true, |
| 1426 | no_libcrt: true, |
| 1427 | stl: "none", |
| 1428 | system_shared_libs: [], |
| 1429 | shared_libs: ["libvndk"], |
| 1430 | static_libs: ["libvendor", "libvendor_without_snapshot"], |
| 1431 | compile_multilib: "64", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1432 | srcs: ["client.cpp"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | cc_binary { |
| 1436 | name: "bin_without_snapshot", |
| 1437 | vendor: true, |
| 1438 | nocrt: true, |
| 1439 | no_libcrt: true, |
| 1440 | stl: "none", |
| 1441 | system_shared_libs: [], |
| 1442 | static_libs: ["libvndk"], |
| 1443 | compile_multilib: "64", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1444 | srcs: ["bin.cpp"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | vendor_snapshot_static { |
| 1448 | name: "libvndk", |
| 1449 | version: "BOARD", |
| 1450 | target_arch: "arm64", |
| 1451 | vendor: true, |
| 1452 | arch: { |
| 1453 | arm64: { |
| 1454 | src: "libvndk.a", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1455 | export_include_dirs: ["include/libvndk"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1456 | }, |
| 1457 | }, |
| 1458 | } |
| 1459 | |
| 1460 | vendor_snapshot_shared { |
| 1461 | name: "libvendor", |
| 1462 | version: "BOARD", |
| 1463 | target_arch: "arm64", |
| 1464 | vendor: true, |
| 1465 | arch: { |
| 1466 | arm64: { |
| 1467 | src: "libvendor.so", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1468 | export_include_dirs: ["include/libvendor"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1469 | }, |
| 1470 | }, |
| 1471 | } |
| 1472 | |
| 1473 | vendor_snapshot_static { |
| 1474 | name: "libvendor", |
| 1475 | version: "BOARD", |
| 1476 | target_arch: "arm64", |
| 1477 | vendor: true, |
| 1478 | arch: { |
| 1479 | arm64: { |
| 1480 | src: "libvendor.a", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1481 | export_include_dirs: ["include/libvendor"], |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1482 | }, |
| 1483 | }, |
| 1484 | } |
| 1485 | |
| 1486 | vendor_snapshot_binary { |
| 1487 | name: "bin", |
| 1488 | version: "BOARD", |
| 1489 | target_arch: "arm64", |
| 1490 | vendor: true, |
| 1491 | arch: { |
| 1492 | arm64: { |
| 1493 | src: "bin", |
| 1494 | }, |
| 1495 | }, |
| 1496 | } |
| 1497 | ` |
| 1498 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1499 | |
| 1500 | mockFS := map[string][]byte{ |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1501 | "deps/Android.bp": []byte(depsBp), |
| 1502 | "framework/Android.bp": []byte(frameworkBp), |
| 1503 | "vendor/Android.bp": []byte(vendorProprietaryBp), |
| 1504 | "vendor/bin": nil, |
| 1505 | "vendor/bin.cpp": nil, |
| 1506 | "vendor/client.cpp": nil, |
| 1507 | "vendor/include/libvndk/a.h": nil, |
| 1508 | "vendor/include/libvendor/b.h": nil, |
| 1509 | "vendor/libvndk.a": nil, |
| 1510 | "vendor/libvendor.a": nil, |
| 1511 | "vendor/libvendor.so": nil, |
| 1512 | "vndk/Android.bp": []byte(vndkBp), |
| 1513 | "vndk/include/libvndk/a.h": nil, |
| 1514 | "vndk/libvndk.so": nil, |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1518 | config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD") |
| 1519 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1520 | ctx := CreateTestContext(config) |
| 1521 | ctx.Register() |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1522 | |
| 1523 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "vendor/Android.bp", "vndk/Android.bp"}) |
| 1524 | android.FailIfErrored(t, errs) |
| 1525 | _, errs = ctx.PrepareBuildActions(config) |
| 1526 | android.FailIfErrored(t, errs) |
| 1527 | |
| 1528 | sharedVariant := "android_vendor.BOARD_arm64_armv8-a_shared" |
| 1529 | staticVariant := "android_vendor.BOARD_arm64_armv8-a_static" |
| 1530 | binaryVariant := "android_vendor.BOARD_arm64_armv8-a" |
| 1531 | |
| 1532 | // libclient uses libvndk.vndk.BOARD.arm64, libvendor.vendor_static.BOARD.arm64, libvendor_without_snapshot |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1533 | libclientCcFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("cc").Args["cFlags"] |
| 1534 | for _, includeFlags := range []string{ |
| 1535 | "-Ivndk/include/libvndk", // libvndk |
| 1536 | "-Ivendor/include/libvendor", // libvendor |
| 1537 | } { |
| 1538 | if !strings.Contains(libclientCcFlags, includeFlags) { |
| 1539 | t.Errorf("flags for libclient must contain %#v, but was %#v.", |
| 1540 | includeFlags, libclientCcFlags) |
| 1541 | } |
| 1542 | } |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1543 | |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1544 | libclientLdFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("ld").Args["libFlags"] |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1545 | for _, input := range [][]string{ |
| 1546 | []string{sharedVariant, "libvndk.vndk.BOARD.arm64"}, |
| 1547 | []string{staticVariant, "libvendor.vendor_static.BOARD.arm64"}, |
| 1548 | []string{staticVariant, "libvendor_without_snapshot"}, |
| 1549 | } { |
| 1550 | outputPaths := getOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */) |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1551 | if !strings.Contains(libclientLdFlags, outputPaths[0].String()) { |
| 1552 | t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientLdFlags) |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | // bin_without_snapshot uses libvndk.vendor_static.BOARD.arm64 |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1557 | binWithoutSnapshotCcFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("cc").Args["cFlags"] |
| 1558 | if !strings.Contains(binWithoutSnapshotCcFlags, "-Ivendor/include/libvndk") { |
| 1559 | t.Errorf("flags for bin_without_snapshot must contain %#v, but was %#v.", |
| 1560 | "-Ivendor/include/libvndk", binWithoutSnapshotCcFlags) |
| 1561 | } |
| 1562 | |
| 1563 | binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("ld").Args["libFlags"] |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1564 | libVndkStaticOutputPaths := getOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.BOARD.arm64"}) |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1565 | if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) { |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1566 | t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v", |
| Inseob Kim | 67be732 | 2020-10-19 10:15:28 +0900 | [diff] [blame] | 1567 | libVndkStaticOutputPaths[0], binWithoutSnapshotLdFlags) |
| Inseob Kim | 5f58ff7 | 2020-09-07 19:53:31 +0900 | [diff] [blame] | 1568 | } |
| 1569 | |
| 1570 | // libvendor.so is installed by libvendor.vendor_shared.BOARD.arm64 |
| 1571 | ctx.ModuleForTests("libvendor.vendor_shared.BOARD.arm64", sharedVariant).Output("libvendor.so") |
| 1572 | |
| 1573 | // libvendor_without_snapshot.so is installed by libvendor_without_snapshot |
| 1574 | ctx.ModuleForTests("libvendor_without_snapshot", sharedVariant).Output("libvendor_without_snapshot.so") |
| 1575 | |
| 1576 | // bin is installed by bin.vendor_binary.BOARD.arm64 |
| 1577 | ctx.ModuleForTests("bin.vendor_binary.BOARD.arm64", binaryVariant).Output("bin") |
| 1578 | |
| 1579 | // bin_without_snapshot is installed by bin_without_snapshot |
| 1580 | ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot") |
| 1581 | |
| 1582 | // libvendor and bin don't have vendor.BOARD variant |
| 1583 | libvendorVariants := ctx.ModuleVariantsForTests("libvendor") |
| 1584 | if inList(sharedVariant, libvendorVariants) { |
| 1585 | t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant) |
| 1586 | } |
| 1587 | |
| 1588 | binVariants := ctx.ModuleVariantsForTests("bin") |
| 1589 | if inList(binaryVariant, binVariants) { |
| 1590 | t.Errorf("bin must not have variant %#v, but it does", sharedVariant) |
| 1591 | } |
| 1592 | } |
| 1593 | |
| Inseob Kim | c42f2f2 | 2020-07-29 20:32:10 +0900 | [diff] [blame] | 1594 | func TestVendorSnapshotSanitizer(t *testing.T) { |
| 1595 | bp := ` |
| 1596 | vendor_snapshot_static { |
| 1597 | name: "libsnapshot", |
| 1598 | vendor: true, |
| 1599 | target_arch: "arm64", |
| 1600 | version: "BOARD", |
| 1601 | arch: { |
| 1602 | arm64: { |
| 1603 | src: "libsnapshot.a", |
| 1604 | cfi: { |
| 1605 | src: "libsnapshot.cfi.a", |
| 1606 | } |
| 1607 | }, |
| 1608 | }, |
| 1609 | } |
| 1610 | ` |
| 1611 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 1612 | config.TestProductVariables.DeviceVndkVersion = StringPtr("BOARD") |
| 1613 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1614 | ctx := testCcWithConfig(t, config) |
| 1615 | |
| 1616 | // Check non-cfi and cfi variant. |
| 1617 | staticVariant := "android_vendor.BOARD_arm64_armv8-a_static" |
| 1618 | staticCfiVariant := "android_vendor.BOARD_arm64_armv8-a_static_cfi" |
| 1619 | |
| 1620 | staticModule := ctx.ModuleForTests("libsnapshot.vendor_static.BOARD.arm64", staticVariant).Module().(*Module) |
| 1621 | assertString(t, staticModule.outputFile.Path().Base(), "libsnapshot.a") |
| 1622 | |
| 1623 | staticCfiModule := ctx.ModuleForTests("libsnapshot.vendor_static.BOARD.arm64", staticCfiVariant).Module().(*Module) |
| 1624 | assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a") |
| 1625 | } |
| 1626 | |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1627 | func assertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) { |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1628 | t.Helper() |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1629 | m := ctx.ModuleForTests(name, vendorVariant).Module().(*Module) |
| 1630 | if m.ExcludeFromVendorSnapshot() != expected { |
| 1631 | t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected) |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1632 | } |
| 1633 | } |
| 1634 | |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1635 | func assertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) { |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1636 | t.Helper() |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1637 | m := ctx.ModuleForTests(name, recoveryVariant).Module().(*Module) |
| 1638 | if m.ExcludeFromRecoverySnapshot() != expected { |
| 1639 | t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected) |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1640 | } |
| 1641 | } |
| 1642 | |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1643 | func TestVendorSnapshotExclude(t *testing.T) { |
| 1644 | |
| 1645 | // This test verifies that the exclude_from_vendor_snapshot property |
| 1646 | // makes its way from the Android.bp source file into the module data |
| 1647 | // structure. It also verifies that modules are correctly included or |
| 1648 | // excluded in the vendor snapshot based on their path (framework or |
| 1649 | // vendor) and the exclude_from_vendor_snapshot property. |
| 1650 | |
| 1651 | frameworkBp := ` |
| 1652 | cc_library_shared { |
| 1653 | name: "libinclude", |
| 1654 | srcs: ["src/include.cpp"], |
| 1655 | vendor_available: true, |
| 1656 | } |
| 1657 | cc_library_shared { |
| 1658 | name: "libexclude", |
| 1659 | srcs: ["src/exclude.cpp"], |
| 1660 | vendor: true, |
| 1661 | exclude_from_vendor_snapshot: true, |
| 1662 | } |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1663 | cc_library_shared { |
| 1664 | name: "libavailable_exclude", |
| 1665 | srcs: ["src/exclude.cpp"], |
| 1666 | vendor_available: true, |
| 1667 | exclude_from_vendor_snapshot: true, |
| 1668 | } |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1669 | ` |
| 1670 | |
| 1671 | vendorProprietaryBp := ` |
| 1672 | cc_library_shared { |
| 1673 | name: "libvendor", |
| 1674 | srcs: ["vendor.cpp"], |
| 1675 | vendor: true, |
| 1676 | } |
| 1677 | ` |
| 1678 | |
| 1679 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1680 | |
| 1681 | mockFS := map[string][]byte{ |
| 1682 | "deps/Android.bp": []byte(depsBp), |
| 1683 | "framework/Android.bp": []byte(frameworkBp), |
| 1684 | "framework/include.cpp": nil, |
| 1685 | "framework/exclude.cpp": nil, |
| 1686 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1687 | "device/vendor.cpp": nil, |
| 1688 | } |
| 1689 | |
| 1690 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1691 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1692 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1693 | ctx := CreateTestContext(config) |
| 1694 | ctx.Register() |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1695 | |
| 1696 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1697 | android.FailIfErrored(t, errs) |
| 1698 | _, errs = ctx.PrepareBuildActions(config) |
| 1699 | android.FailIfErrored(t, errs) |
| 1700 | |
| 1701 | // Test an include and exclude framework module. |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1702 | assertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false) |
| 1703 | assertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true) |
| 1704 | assertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true) |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1705 | |
| 1706 | // A vendor module is excluded, but by its path, not the |
| 1707 | // exclude_from_vendor_snapshot property. |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1708 | assertExcludeFromVendorSnapshotIs(t, ctx, "libvendor", false) |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1709 | |
| 1710 | // Verify the content of the vendor snapshot. |
| 1711 | |
| 1712 | snapshotDir := "vendor-snapshot" |
| 1713 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1714 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1715 | |
| 1716 | var includeJsonFiles []string |
| 1717 | var excludeJsonFiles []string |
| 1718 | |
| 1719 | for _, arch := range [][]string{ |
| 1720 | []string{"arm64", "armv8-a"}, |
| 1721 | []string{"arm", "armv7-a-neon"}, |
| 1722 | } { |
| 1723 | archType := arch[0] |
| 1724 | archVariant := arch[1] |
| 1725 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1726 | |
| 1727 | sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant) |
| 1728 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1729 | |
| 1730 | // Included modules |
| 1731 | checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
| 1732 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1733 | |
| 1734 | // Excluded modules |
| 1735 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
| 1736 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
| 1737 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 1738 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1739 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
| 1740 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
| 1743 | // Verify that each json file for an included module has a rule. |
| 1744 | for _, jsonFile := range includeJsonFiles { |
| 1745 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1746 | t.Errorf("include json file %q not found", jsonFile) |
| 1747 | } |
| 1748 | } |
| 1749 | |
| 1750 | // Verify that each json file for an excluded module has no rule. |
| 1751 | for _, jsonFile := range excludeJsonFiles { |
| 1752 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1753 | t.Errorf("exclude json file %q found", jsonFile) |
| 1754 | } |
| 1755 | } |
| 1756 | } |
| 1757 | |
| 1758 | func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) { |
| 1759 | |
| 1760 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1761 | // property on a module in a vendor proprietary path generates an |
| 1762 | // error. These modules are already excluded, so we prohibit using the |
| 1763 | // property in this way, which could add to confusion. |
| 1764 | |
| 1765 | vendorProprietaryBp := ` |
| 1766 | cc_library_shared { |
| 1767 | name: "libvendor", |
| 1768 | srcs: ["vendor.cpp"], |
| 1769 | vendor: true, |
| 1770 | exclude_from_vendor_snapshot: true, |
| 1771 | } |
| 1772 | ` |
| 1773 | |
| 1774 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1775 | |
| 1776 | mockFS := map[string][]byte{ |
| 1777 | "deps/Android.bp": []byte(depsBp), |
| 1778 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1779 | "device/vendor.cpp": nil, |
| 1780 | } |
| 1781 | |
| 1782 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1783 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1784 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1785 | ctx := CreateTestContext(config) |
| 1786 | ctx.Register() |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1787 | |
| 1788 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"}) |
| 1789 | android.FailIfErrored(t, errs) |
| 1790 | |
| 1791 | _, errs = ctx.PrepareBuildActions(config) |
| 1792 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1793 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1794 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 1795 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1796 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| Inseob Kim | e9aec6a | 2021-01-05 20:03:22 +0900 | [diff] [blame] | 1797 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1798 | `module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1799 | }) |
| 1800 | } |
| 1801 | |
| Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 1802 | func TestRecoverySnapshotCapture(t *testing.T) { |
| 1803 | bp := ` |
| 1804 | cc_library { |
| 1805 | name: "libvndk", |
| 1806 | vendor_available: true, |
| 1807 | recovery_available: true, |
| 1808 | product_available: true, |
| 1809 | vndk: { |
| 1810 | enabled: true, |
| 1811 | }, |
| 1812 | nocrt: true, |
| 1813 | } |
| 1814 | |
| 1815 | cc_library { |
| 1816 | name: "librecovery", |
| 1817 | recovery: true, |
| 1818 | nocrt: true, |
| 1819 | } |
| 1820 | |
| 1821 | cc_library { |
| 1822 | name: "librecovery_available", |
| 1823 | recovery_available: true, |
| 1824 | nocrt: true, |
| 1825 | } |
| 1826 | |
| 1827 | cc_library_headers { |
| 1828 | name: "librecovery_headers", |
| 1829 | recovery_available: true, |
| 1830 | nocrt: true, |
| 1831 | } |
| 1832 | |
| 1833 | cc_binary { |
| 1834 | name: "recovery_bin", |
| 1835 | recovery: true, |
| 1836 | nocrt: true, |
| 1837 | } |
| 1838 | |
| 1839 | cc_binary { |
| 1840 | name: "recovery_available_bin", |
| 1841 | recovery_available: true, |
| 1842 | nocrt: true, |
| 1843 | } |
| 1844 | |
| 1845 | toolchain_library { |
| 1846 | name: "libb", |
| 1847 | recovery_available: true, |
| 1848 | src: "libb.a", |
| 1849 | } |
| 1850 | |
| 1851 | cc_object { |
| 1852 | name: "obj", |
| 1853 | recovery_available: true, |
| 1854 | } |
| 1855 | ` |
| 1856 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1857 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
| Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 1858 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1859 | ctx := testCcWithConfig(t, config) |
| 1860 | |
| 1861 | // Check Recovery snapshot output. |
| 1862 | |
| 1863 | snapshotDir := "recovery-snapshot" |
| 1864 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1865 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1866 | |
| 1867 | var jsonFiles []string |
| 1868 | |
| 1869 | for _, arch := range [][]string{ |
| 1870 | []string{"arm64", "armv8-a"}, |
| 1871 | } { |
| 1872 | archType := arch[0] |
| 1873 | archVariant := arch[1] |
| 1874 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1875 | |
| 1876 | // For shared libraries, only recovery_available modules are captured. |
| 1877 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1878 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1879 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant) |
| 1880 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 1881 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
| 1882 | jsonFiles = append(jsonFiles, |
| 1883 | filepath.Join(sharedDir, "libvndk.so.json"), |
| 1884 | filepath.Join(sharedDir, "librecovery.so.json"), |
| 1885 | filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1886 | |
| 1887 | // For static libraries, all recovery:true and recovery_available modules are captured. |
| 1888 | staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant) |
| 1889 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
| 1890 | checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1891 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant) |
| 1892 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant) |
| 1893 | jsonFiles = append(jsonFiles, |
| 1894 | filepath.Join(staticDir, "libb.a.json"), |
| 1895 | filepath.Join(staticDir, "librecovery.a.json"), |
| 1896 | filepath.Join(staticDir, "librecovery_available.a.json")) |
| 1897 | |
| 1898 | // For binary executables, all recovery:true and recovery_available modules are captured. |
| 1899 | if archType == "arm64" { |
| 1900 | binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1901 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
| 1902 | checkSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant) |
| 1903 | checkSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant) |
| 1904 | jsonFiles = append(jsonFiles, |
| 1905 | filepath.Join(binaryDir, "recovery_bin.json"), |
| 1906 | filepath.Join(binaryDir, "recovery_available_bin.json")) |
| 1907 | } |
| 1908 | |
| 1909 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1910 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1911 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json")) |
| 1912 | |
| 1913 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1914 | objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1915 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
| 1916 | checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
| 1917 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 1918 | } |
| 1919 | |
| 1920 | for _, jsonFile := range jsonFiles { |
| 1921 | // verify all json files exist |
| 1922 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1923 | t.Errorf("%q expected but not found", jsonFile) |
| 1924 | } |
| 1925 | } |
| 1926 | } |
| 1927 | |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1928 | func TestRecoverySnapshotExclude(t *testing.T) { |
| 1929 | // This test verifies that the exclude_from_recovery_snapshot property |
| 1930 | // makes its way from the Android.bp source file into the module data |
| 1931 | // structure. It also verifies that modules are correctly included or |
| 1932 | // excluded in the recovery snapshot based on their path (framework or |
| 1933 | // vendor) and the exclude_from_recovery_snapshot property. |
| 1934 | |
| 1935 | frameworkBp := ` |
| 1936 | cc_library_shared { |
| 1937 | name: "libinclude", |
| 1938 | srcs: ["src/include.cpp"], |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1939 | recovery_available: true, |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1940 | } |
| 1941 | cc_library_shared { |
| 1942 | name: "libexclude", |
| 1943 | srcs: ["src/exclude.cpp"], |
| 1944 | recovery: true, |
| 1945 | exclude_from_recovery_snapshot: true, |
| 1946 | } |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1947 | cc_library_shared { |
| 1948 | name: "libavailable_exclude", |
| 1949 | srcs: ["src/exclude.cpp"], |
| 1950 | recovery_available: true, |
| 1951 | exclude_from_recovery_snapshot: true, |
| 1952 | } |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1953 | ` |
| 1954 | |
| 1955 | vendorProprietaryBp := ` |
| 1956 | cc_library_shared { |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1957 | name: "librecovery", |
| 1958 | srcs: ["recovery.cpp"], |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1959 | recovery: true, |
| 1960 | } |
| 1961 | ` |
| 1962 | |
| 1963 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1964 | |
| 1965 | mockFS := map[string][]byte{ |
| 1966 | "deps/Android.bp": []byte(depsBp), |
| 1967 | "framework/Android.bp": []byte(frameworkBp), |
| 1968 | "framework/include.cpp": nil, |
| 1969 | "framework/exclude.cpp": nil, |
| 1970 | "device/Android.bp": []byte(vendorProprietaryBp), |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1971 | "device/recovery.cpp": nil, |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1975 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
| 1976 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1977 | ctx := CreateTestContext(config) |
| 1978 | ctx.Register() |
| 1979 | |
| 1980 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1981 | android.FailIfErrored(t, errs) |
| 1982 | _, errs = ctx.PrepareBuildActions(config) |
| 1983 | android.FailIfErrored(t, errs) |
| 1984 | |
| 1985 | // Test an include and exclude framework module. |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1986 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false) |
| 1987 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true) |
| 1988 | assertExcludeFromRecoverySnapshotIs(t, ctx, "libavailable_exclude", true) |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1989 | |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1990 | // A recovery module is excluded, but by its path, not the |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1991 | // exclude_from_recovery_snapshot property. |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 1992 | assertExcludeFromRecoverySnapshotIs(t, ctx, "librecovery", false) |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1993 | |
| 1994 | // Verify the content of the recovery snapshot. |
| 1995 | |
| 1996 | snapshotDir := "recovery-snapshot" |
| 1997 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1998 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1999 | |
| 2000 | var includeJsonFiles []string |
| 2001 | var excludeJsonFiles []string |
| 2002 | |
| 2003 | for _, arch := range [][]string{ |
| 2004 | []string{"arm64", "armv8-a"}, |
| 2005 | } { |
| 2006 | archType := arch[0] |
| 2007 | archVariant := arch[1] |
| 2008 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 2009 | |
| 2010 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 2011 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 2012 | |
| 2013 | // Included modules |
| 2014 | checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
| 2015 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 2016 | |
| 2017 | // Excluded modules |
| 2018 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
| 2019 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
| Justin Yun | e09ac17 | 2021-01-20 19:49:01 +0900 | [diff] [blame] | 2020 | checkSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 2021 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json")) |
| 2022 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
| 2023 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
| Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 2024 | } |
| 2025 | |
| 2026 | // Verify that each json file for an included module has a rule. |
| 2027 | for _, jsonFile := range includeJsonFiles { |
| 2028 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 2029 | t.Errorf("include json file %q not found", jsonFile) |
| 2030 | } |
| 2031 | } |
| 2032 | |
| 2033 | // Verify that each json file for an excluded module has no rule. |
| 2034 | for _, jsonFile := range excludeJsonFiles { |
| 2035 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 2036 | t.Errorf("exclude json file %q found", jsonFile) |
| 2037 | } |
| 2038 | } |
| 2039 | } |
| 2040 | |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2041 | func TestDoubleLoadableDepError(t *testing.T) { |
| 2042 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib. |
| 2043 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2044 | cc_library { |
| 2045 | name: "libllndk", |
| 2046 | shared_libs: ["libnondoubleloadable"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2047 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2048 | } |
| 2049 | |
| 2050 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2051 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2052 | symbol_file: "", |
| 2053 | } |
| 2054 | |
| 2055 | cc_library { |
| 2056 | name: "libnondoubleloadable", |
| 2057 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2058 | product_available: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2059 | vndk: { |
| 2060 | enabled: true, |
| 2061 | }, |
| 2062 | } |
| 2063 | `) |
| 2064 | |
| 2065 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable vendor_available lib. |
| 2066 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2067 | cc_library { |
| 2068 | name: "libllndk", |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 2069 | no_libcrt: true, |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2070 | shared_libs: ["libnondoubleloadable"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2071 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2072 | } |
| 2073 | |
| 2074 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2075 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2076 | symbol_file: "", |
| 2077 | } |
| 2078 | |
| 2079 | cc_library { |
| 2080 | name: "libnondoubleloadable", |
| 2081 | vendor_available: true, |
| 2082 | } |
| 2083 | `) |
| 2084 | |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2085 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable indirectly. |
| 2086 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2087 | cc_library { |
| 2088 | name: "libllndk", |
| 2089 | shared_libs: ["libcoreonly"], |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2090 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2091 | } |
| 2092 | |
| 2093 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2094 | name: "libllndk.llndk", |
| Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2095 | symbol_file: "", |
| 2096 | } |
| 2097 | |
| 2098 | cc_library { |
| 2099 | name: "libcoreonly", |
| 2100 | shared_libs: ["libvendoravailable"], |
| 2101 | } |
| 2102 | |
| 2103 | // indirect dependency of LLNDK |
| 2104 | cc_library { |
| 2105 | name: "libvendoravailable", |
| 2106 | vendor_available: true, |
| 2107 | } |
| 2108 | `) |
| Jiyong Park | 0474e1f | 2021-01-14 14:26:06 +0900 | [diff] [blame] | 2109 | |
| 2110 | // The error is not from 'client' but from 'libllndk' |
| 2111 | testCcError(t, "module \"libllndk\".* links a library \"libnondoubleloadable\".*double_loadable", ` |
| 2112 | cc_library { |
| 2113 | name: "client", |
| 2114 | vendor_available: true, |
| 2115 | double_loadable: true, |
| 2116 | shared_libs: ["libllndk"], |
| 2117 | } |
| 2118 | cc_library { |
| 2119 | name: "libllndk", |
| 2120 | shared_libs: ["libnondoubleloadable"], |
| 2121 | llndk_stubs: "libllndk.llndk", |
| 2122 | } |
| 2123 | llndk_library { |
| 2124 | name: "libllndk.llndk", |
| 2125 | symbol_file: "", |
| 2126 | } |
| 2127 | cc_library { |
| 2128 | name: "libnondoubleloadable", |
| 2129 | vendor_available: true, |
| 2130 | } |
| 2131 | `) |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2132 | } |
| 2133 | |
| Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 2134 | func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) { |
| 2135 | testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", ` |
| 2136 | cc_library { |
| 2137 | name: "libvndksp", |
| 2138 | shared_libs: ["libanothervndksp"], |
| 2139 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2140 | product_available: true, |
| Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 2141 | vndk: { |
| 2142 | enabled: true, |
| 2143 | support_system_process: true, |
| 2144 | } |
| 2145 | } |
| 2146 | |
| 2147 | cc_library { |
| 2148 | name: "libllndk", |
| 2149 | shared_libs: ["libanothervndksp"], |
| 2150 | } |
| 2151 | |
| 2152 | llndk_library { |
| 2153 | name: "libllndk", |
| 2154 | symbol_file: "", |
| 2155 | } |
| 2156 | |
| 2157 | cc_library { |
| 2158 | name: "libanothervndksp", |
| 2159 | vendor_available: true, |
| 2160 | } |
| 2161 | `) |
| 2162 | } |
| 2163 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2164 | func TestVndkExt(t *testing.T) { |
| 2165 | // This test checks the VNDK-Ext properties. |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2166 | bp := ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2167 | cc_library { |
| 2168 | name: "libvndk", |
| 2169 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2170 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2171 | vndk: { |
| 2172 | enabled: true, |
| 2173 | }, |
| 2174 | nocrt: true, |
| 2175 | } |
| Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2176 | cc_library { |
| 2177 | name: "libvndk2", |
| 2178 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2179 | product_available: true, |
| Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2180 | vndk: { |
| 2181 | enabled: true, |
| 2182 | }, |
| 2183 | target: { |
| 2184 | vendor: { |
| 2185 | suffix: "-suffix", |
| 2186 | }, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2187 | product: { |
| 2188 | suffix: "-suffix", |
| 2189 | }, |
| Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2190 | }, |
| 2191 | nocrt: true, |
| 2192 | } |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2193 | |
| 2194 | cc_library { |
| 2195 | name: "libvndk_ext", |
| 2196 | vendor: true, |
| 2197 | vndk: { |
| 2198 | enabled: true, |
| 2199 | extends: "libvndk", |
| 2200 | }, |
| 2201 | nocrt: true, |
| 2202 | } |
| Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2203 | |
| 2204 | cc_library { |
| 2205 | name: "libvndk2_ext", |
| 2206 | vendor: true, |
| 2207 | vndk: { |
| 2208 | enabled: true, |
| 2209 | extends: "libvndk2", |
| 2210 | }, |
| 2211 | nocrt: true, |
| 2212 | } |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2213 | |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2214 | cc_library { |
| 2215 | name: "libvndk_ext_product", |
| 2216 | product_specific: true, |
| 2217 | vndk: { |
| 2218 | enabled: true, |
| 2219 | extends: "libvndk", |
| 2220 | }, |
| 2221 | nocrt: true, |
| 2222 | } |
| Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2223 | |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2224 | cc_library { |
| 2225 | name: "libvndk2_ext_product", |
| 2226 | product_specific: true, |
| 2227 | vndk: { |
| 2228 | enabled: true, |
| 2229 | extends: "libvndk2", |
| 2230 | }, |
| 2231 | nocrt: true, |
| 2232 | } |
| 2233 | ` |
| 2234 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 2235 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 2236 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 2237 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 2238 | |
| 2239 | ctx := testCcWithConfig(t, config) |
| 2240 | |
| 2241 | checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk", vendorVariant) |
| 2242 | checkVndkModule(t, ctx, "libvndk_ext_product", "vndk", false, "libvndk", productVariant) |
| 2243 | |
| 2244 | mod_vendor := ctx.ModuleForTests("libvndk2_ext", vendorVariant).Module().(*Module) |
| 2245 | assertString(t, mod_vendor.outputFile.Path().Base(), "libvndk2-suffix.so") |
| 2246 | |
| 2247 | mod_product := ctx.ModuleForTests("libvndk2_ext_product", productVariant).Module().(*Module) |
| 2248 | assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so") |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2249 | } |
| 2250 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2251 | func TestVndkExtWithoutBoardVndkVersion(t *testing.T) { |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2252 | // This test checks the VNDK-Ext properties when BOARD_VNDK_VERSION is not set. |
| 2253 | ctx := testCcNoVndk(t, ` |
| 2254 | cc_library { |
| 2255 | name: "libvndk", |
| 2256 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2257 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2258 | vndk: { |
| 2259 | enabled: true, |
| 2260 | }, |
| 2261 | nocrt: true, |
| 2262 | } |
| 2263 | |
| 2264 | cc_library { |
| 2265 | name: "libvndk_ext", |
| 2266 | vendor: true, |
| 2267 | vndk: { |
| 2268 | enabled: true, |
| 2269 | extends: "libvndk", |
| 2270 | }, |
| 2271 | nocrt: true, |
| 2272 | } |
| 2273 | `) |
| 2274 | |
| 2275 | // Ensures that the core variant of "libvndk_ext" can be found. |
| 2276 | mod := ctx.ModuleForTests("libvndk_ext", coreVariant).Module().(*Module) |
| 2277 | if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" { |
| 2278 | t.Errorf("\"libvndk_ext\" must extend from \"libvndk\" but get %q", extends) |
| 2279 | } |
| 2280 | } |
| 2281 | |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2282 | func TestVndkExtWithoutProductVndkVersion(t *testing.T) { |
| 2283 | // This test checks the VNDK-Ext properties when PRODUCT_PRODUCT_VNDK_VERSION is not set. |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 2284 | ctx := testCcNoProductVndk(t, ` |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2285 | cc_library { |
| 2286 | name: "libvndk", |
| 2287 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2288 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2289 | vndk: { |
| 2290 | enabled: true, |
| 2291 | }, |
| 2292 | nocrt: true, |
| 2293 | } |
| 2294 | |
| 2295 | cc_library { |
| 2296 | name: "libvndk_ext_product", |
| 2297 | product_specific: true, |
| 2298 | vndk: { |
| 2299 | enabled: true, |
| 2300 | extends: "libvndk", |
| 2301 | }, |
| 2302 | nocrt: true, |
| 2303 | } |
| 2304 | `) |
| 2305 | |
| 2306 | // Ensures that the core variant of "libvndk_ext_product" can be found. |
| 2307 | mod := ctx.ModuleForTests("libvndk_ext_product", coreVariant).Module().(*Module) |
| 2308 | if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" { |
| 2309 | t.Errorf("\"libvndk_ext_product\" must extend from \"libvndk\" but get %q", extends) |
| 2310 | } |
| 2311 | } |
| 2312 | |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2313 | func TestVndkExtError(t *testing.T) { |
| 2314 | // This test ensures an error is emitted in ill-formed vndk-ext definition. |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2315 | testCcError(t, "must set `vendor: true` or `product_specific: true` to set `extends: \".*\"`", ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2316 | cc_library { |
| 2317 | name: "libvndk", |
| 2318 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2319 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2320 | vndk: { |
| 2321 | enabled: true, |
| 2322 | }, |
| 2323 | nocrt: true, |
| 2324 | } |
| 2325 | |
| 2326 | cc_library { |
| 2327 | name: "libvndk_ext", |
| 2328 | vndk: { |
| 2329 | enabled: true, |
| 2330 | extends: "libvndk", |
| 2331 | }, |
| 2332 | nocrt: true, |
| 2333 | } |
| 2334 | `) |
| 2335 | |
| 2336 | testCcError(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` |
| 2337 | cc_library { |
| 2338 | name: "libvndk", |
| 2339 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2340 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2341 | vndk: { |
| 2342 | enabled: true, |
| 2343 | }, |
| 2344 | nocrt: true, |
| 2345 | } |
| 2346 | |
| 2347 | cc_library { |
| 2348 | name: "libvndk_ext", |
| 2349 | vendor: true, |
| 2350 | vndk: { |
| 2351 | enabled: true, |
| 2352 | }, |
| 2353 | nocrt: true, |
| 2354 | } |
| 2355 | `) |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2356 | |
| 2357 | testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` |
| 2358 | cc_library { |
| 2359 | name: "libvndk", |
| 2360 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2361 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2362 | vndk: { |
| 2363 | enabled: true, |
| 2364 | }, |
| 2365 | nocrt: true, |
| 2366 | } |
| 2367 | |
| 2368 | cc_library { |
| 2369 | name: "libvndk_ext_product", |
| 2370 | product_specific: true, |
| 2371 | vndk: { |
| 2372 | enabled: true, |
| 2373 | }, |
| 2374 | nocrt: true, |
| 2375 | } |
| 2376 | `) |
| 2377 | |
| 2378 | testCcErrorProductVndk(t, "must not set at the same time as `vndk: {extends: \"\\.\\.\\.\"}`", ` |
| 2379 | cc_library { |
| 2380 | name: "libvndk", |
| 2381 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2382 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2383 | vndk: { |
| 2384 | enabled: true, |
| 2385 | }, |
| 2386 | nocrt: true, |
| 2387 | } |
| 2388 | |
| 2389 | cc_library { |
| 2390 | name: "libvndk_ext_product", |
| 2391 | product_specific: true, |
| 2392 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2393 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2394 | vndk: { |
| 2395 | enabled: true, |
| 2396 | extends: "libvndk", |
| 2397 | }, |
| 2398 | nocrt: true, |
| 2399 | } |
| 2400 | `) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2401 | } |
| 2402 | |
| 2403 | func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) { |
| 2404 | // This test ensures an error is emitted for inconsistent support_system_process. |
| 2405 | testCcError(t, "module \".*\" with mismatched support_system_process", ` |
| 2406 | cc_library { |
| 2407 | name: "libvndk", |
| 2408 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2409 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2410 | vndk: { |
| 2411 | enabled: true, |
| 2412 | }, |
| 2413 | nocrt: true, |
| 2414 | } |
| 2415 | |
| 2416 | cc_library { |
| 2417 | name: "libvndk_sp_ext", |
| 2418 | vendor: true, |
| 2419 | vndk: { |
| 2420 | enabled: true, |
| 2421 | extends: "libvndk", |
| 2422 | support_system_process: true, |
| 2423 | }, |
| 2424 | nocrt: true, |
| 2425 | } |
| 2426 | `) |
| 2427 | |
| 2428 | testCcError(t, "module \".*\" with mismatched support_system_process", ` |
| 2429 | cc_library { |
| 2430 | name: "libvndk_sp", |
| 2431 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2432 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2433 | vndk: { |
| 2434 | enabled: true, |
| 2435 | support_system_process: true, |
| 2436 | }, |
| 2437 | nocrt: true, |
| 2438 | } |
| 2439 | |
| 2440 | cc_library { |
| 2441 | name: "libvndk_ext", |
| 2442 | vendor: true, |
| 2443 | vndk: { |
| 2444 | enabled: true, |
| 2445 | extends: "libvndk_sp", |
| 2446 | }, |
| 2447 | nocrt: true, |
| 2448 | } |
| 2449 | `) |
| 2450 | } |
| 2451 | |
| 2452 | func TestVndkExtVendorAvailableFalseError(t *testing.T) { |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2453 | // This test ensures an error is emitted when a VNDK-Ext library extends a VNDK library |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2454 | // with `private: true`. |
| 2455 | testCcError(t, "`extends` refers module \".*\" which has `private: true`", ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2456 | cc_library { |
| 2457 | name: "libvndk", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2458 | vendor_available: true, |
| 2459 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2460 | vndk: { |
| 2461 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2462 | private: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2463 | }, |
| 2464 | nocrt: true, |
| 2465 | } |
| 2466 | |
| 2467 | cc_library { |
| 2468 | name: "libvndk_ext", |
| 2469 | vendor: true, |
| 2470 | vndk: { |
| 2471 | enabled: true, |
| 2472 | extends: "libvndk", |
| 2473 | }, |
| 2474 | nocrt: true, |
| 2475 | } |
| 2476 | `) |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2477 | |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2478 | testCcErrorProductVndk(t, "`extends` refers module \".*\" which has `private: true`", ` |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2479 | cc_library { |
| 2480 | name: "libvndk", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2481 | vendor_available: true, |
| 2482 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2483 | vndk: { |
| 2484 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2485 | private: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2486 | }, |
| 2487 | nocrt: true, |
| 2488 | } |
| 2489 | |
| 2490 | cc_library { |
| 2491 | name: "libvndk_ext_product", |
| 2492 | product_specific: true, |
| 2493 | vndk: { |
| 2494 | enabled: true, |
| 2495 | extends: "libvndk", |
| 2496 | }, |
| 2497 | nocrt: true, |
| 2498 | } |
| 2499 | `) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2500 | } |
| 2501 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2502 | func TestVendorModuleUseVndkExt(t *testing.T) { |
| 2503 | // This test ensures a vendor module can depend on a VNDK-Ext library. |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2504 | testCc(t, ` |
| 2505 | cc_library { |
| 2506 | name: "libvndk", |
| 2507 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2508 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2509 | vndk: { |
| 2510 | enabled: true, |
| 2511 | }, |
| 2512 | nocrt: true, |
| 2513 | } |
| 2514 | |
| 2515 | cc_library { |
| 2516 | name: "libvndk_ext", |
| 2517 | vendor: true, |
| 2518 | vndk: { |
| 2519 | enabled: true, |
| 2520 | extends: "libvndk", |
| 2521 | }, |
| 2522 | nocrt: true, |
| 2523 | } |
| 2524 | |
| 2525 | cc_library { |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2526 | name: "libvndk_sp", |
| 2527 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2528 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2529 | vndk: { |
| 2530 | enabled: true, |
| 2531 | support_system_process: true, |
| 2532 | }, |
| 2533 | nocrt: true, |
| 2534 | } |
| 2535 | |
| 2536 | cc_library { |
| 2537 | name: "libvndk_sp_ext", |
| 2538 | vendor: true, |
| 2539 | vndk: { |
| 2540 | enabled: true, |
| 2541 | extends: "libvndk_sp", |
| 2542 | support_system_process: true, |
| 2543 | }, |
| 2544 | nocrt: true, |
| 2545 | } |
| 2546 | |
| 2547 | cc_library { |
| 2548 | name: "libvendor", |
| 2549 | vendor: true, |
| 2550 | shared_libs: ["libvndk_ext", "libvndk_sp_ext"], |
| 2551 | nocrt: true, |
| 2552 | } |
| 2553 | `) |
| 2554 | } |
| 2555 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2556 | func TestVndkExtUseVendorLib(t *testing.T) { |
| 2557 | // This test ensures a VNDK-Ext library can depend on a vendor library. |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2558 | testCc(t, ` |
| 2559 | cc_library { |
| 2560 | name: "libvndk", |
| 2561 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2562 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2563 | vndk: { |
| 2564 | enabled: true, |
| 2565 | }, |
| 2566 | nocrt: true, |
| 2567 | } |
| 2568 | |
| 2569 | cc_library { |
| 2570 | name: "libvndk_ext", |
| 2571 | vendor: true, |
| 2572 | vndk: { |
| 2573 | enabled: true, |
| 2574 | extends: "libvndk", |
| 2575 | }, |
| 2576 | shared_libs: ["libvendor"], |
| 2577 | nocrt: true, |
| 2578 | } |
| 2579 | |
| 2580 | cc_library { |
| 2581 | name: "libvendor", |
| 2582 | vendor: true, |
| 2583 | nocrt: true, |
| 2584 | } |
| 2585 | `) |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2586 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2587 | // This test ensures a VNDK-SP-Ext library can depend on a vendor library. |
| 2588 | testCc(t, ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2589 | cc_library { |
| 2590 | name: "libvndk_sp", |
| 2591 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2592 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2593 | vndk: { |
| 2594 | enabled: true, |
| 2595 | support_system_process: true, |
| 2596 | }, |
| 2597 | nocrt: true, |
| 2598 | } |
| 2599 | |
| 2600 | cc_library { |
| 2601 | name: "libvndk_sp_ext", |
| 2602 | vendor: true, |
| 2603 | vndk: { |
| 2604 | enabled: true, |
| 2605 | extends: "libvndk_sp", |
| 2606 | support_system_process: true, |
| 2607 | }, |
| 2608 | shared_libs: ["libvendor"], // Cause an error |
| 2609 | nocrt: true, |
| 2610 | } |
| 2611 | |
| 2612 | cc_library { |
| 2613 | name: "libvendor", |
| 2614 | vendor: true, |
| 2615 | nocrt: true, |
| 2616 | } |
| 2617 | `) |
| 2618 | } |
| 2619 | |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2620 | func TestProductVndkExtDependency(t *testing.T) { |
| 2621 | bp := ` |
| 2622 | cc_library { |
| 2623 | name: "libvndk", |
| 2624 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2625 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2626 | vndk: { |
| 2627 | enabled: true, |
| 2628 | }, |
| 2629 | nocrt: true, |
| 2630 | } |
| 2631 | |
| 2632 | cc_library { |
| 2633 | name: "libvndk_ext_product", |
| 2634 | product_specific: true, |
| 2635 | vndk: { |
| 2636 | enabled: true, |
| 2637 | extends: "libvndk", |
| 2638 | }, |
| 2639 | shared_libs: ["libproduct_for_vndklibs"], |
| 2640 | nocrt: true, |
| 2641 | } |
| 2642 | |
| 2643 | cc_library { |
| 2644 | name: "libvndk_sp", |
| 2645 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2646 | product_available: true, |
| Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2647 | vndk: { |
| 2648 | enabled: true, |
| 2649 | support_system_process: true, |
| 2650 | }, |
| 2651 | nocrt: true, |
| 2652 | } |
| 2653 | |
| 2654 | cc_library { |
| 2655 | name: "libvndk_sp_ext_product", |
| 2656 | product_specific: true, |
| 2657 | vndk: { |
| 2658 | enabled: true, |
| 2659 | extends: "libvndk_sp", |
| 2660 | support_system_process: true, |
| 2661 | }, |
| 2662 | shared_libs: ["libproduct_for_vndklibs"], |
| 2663 | nocrt: true, |
| 2664 | } |
| 2665 | |
| 2666 | cc_library { |
| 2667 | name: "libproduct", |
| 2668 | product_specific: true, |
| 2669 | shared_libs: ["libvndk_ext_product", "libvndk_sp_ext_product"], |
| 2670 | nocrt: true, |
| 2671 | } |
| 2672 | |
| 2673 | cc_library { |
| 2674 | name: "libproduct_for_vndklibs", |
| 2675 | product_specific: true, |
| 2676 | nocrt: true, |
| 2677 | } |
| 2678 | ` |
| 2679 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 2680 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 2681 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 2682 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 2683 | |
| 2684 | testCcWithConfig(t, config) |
| 2685 | } |
| 2686 | |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2687 | func TestVndkSpExtUseVndkError(t *testing.T) { |
| 2688 | // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK |
| 2689 | // library. |
| 2690 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 2691 | cc_library { |
| 2692 | name: "libvndk", |
| 2693 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2694 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2695 | vndk: { |
| 2696 | enabled: true, |
| 2697 | }, |
| 2698 | nocrt: true, |
| 2699 | } |
| 2700 | |
| 2701 | cc_library { |
| 2702 | name: "libvndk_sp", |
| 2703 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2704 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2705 | vndk: { |
| 2706 | enabled: true, |
| 2707 | support_system_process: true, |
| 2708 | }, |
| 2709 | nocrt: true, |
| 2710 | } |
| 2711 | |
| 2712 | cc_library { |
| 2713 | name: "libvndk_sp_ext", |
| 2714 | vendor: true, |
| 2715 | vndk: { |
| 2716 | enabled: true, |
| 2717 | extends: "libvndk_sp", |
| 2718 | support_system_process: true, |
| 2719 | }, |
| 2720 | shared_libs: ["libvndk"], // Cause an error |
| 2721 | nocrt: true, |
| 2722 | } |
| 2723 | `) |
| 2724 | |
| 2725 | // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK-Ext |
| 2726 | // library. |
| 2727 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 2728 | cc_library { |
| 2729 | name: "libvndk", |
| 2730 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2731 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2732 | vndk: { |
| 2733 | enabled: true, |
| 2734 | }, |
| 2735 | nocrt: true, |
| 2736 | } |
| 2737 | |
| 2738 | cc_library { |
| 2739 | name: "libvndk_ext", |
| 2740 | vendor: true, |
| 2741 | vndk: { |
| 2742 | enabled: true, |
| 2743 | extends: "libvndk", |
| 2744 | }, |
| 2745 | nocrt: true, |
| 2746 | } |
| 2747 | |
| 2748 | cc_library { |
| 2749 | name: "libvndk_sp", |
| 2750 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2751 | product_available: true, |
| Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2752 | vndk: { |
| 2753 | enabled: true, |
| 2754 | support_system_process: true, |
| 2755 | }, |
| 2756 | nocrt: true, |
| 2757 | } |
| 2758 | |
| 2759 | cc_library { |
| 2760 | name: "libvndk_sp_ext", |
| 2761 | vendor: true, |
| 2762 | vndk: { |
| 2763 | enabled: true, |
| 2764 | extends: "libvndk_sp", |
| 2765 | support_system_process: true, |
| 2766 | }, |
| 2767 | shared_libs: ["libvndk_ext"], // Cause an error |
| 2768 | nocrt: true, |
| 2769 | } |
| 2770 | `) |
| 2771 | } |
| 2772 | |
| 2773 | func TestVndkUseVndkExtError(t *testing.T) { |
| 2774 | // This test ensures an error is emitted if a VNDK/VNDK-SP library depends on a |
| 2775 | // VNDK-Ext/VNDK-SP-Ext library. |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2776 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 2777 | cc_library { |
| 2778 | name: "libvndk", |
| 2779 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2780 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2781 | vndk: { |
| 2782 | enabled: true, |
| 2783 | }, |
| 2784 | nocrt: true, |
| 2785 | } |
| 2786 | |
| 2787 | cc_library { |
| 2788 | name: "libvndk_ext", |
| 2789 | vendor: true, |
| 2790 | vndk: { |
| 2791 | enabled: true, |
| 2792 | extends: "libvndk", |
| 2793 | }, |
| 2794 | nocrt: true, |
| 2795 | } |
| 2796 | |
| 2797 | cc_library { |
| 2798 | name: "libvndk2", |
| 2799 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2800 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2801 | vndk: { |
| 2802 | enabled: true, |
| 2803 | }, |
| 2804 | shared_libs: ["libvndk_ext"], |
| 2805 | nocrt: true, |
| 2806 | } |
| 2807 | `) |
| 2808 | |
| Martin Stjernholm | ef449fe | 2018-11-06 16:12:13 +0000 | [diff] [blame] | 2809 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2810 | cc_library { |
| 2811 | name: "libvndk", |
| 2812 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2813 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2814 | vndk: { |
| 2815 | enabled: true, |
| 2816 | }, |
| 2817 | nocrt: true, |
| 2818 | } |
| 2819 | |
| 2820 | cc_library { |
| 2821 | name: "libvndk_ext", |
| 2822 | vendor: true, |
| 2823 | vndk: { |
| 2824 | enabled: true, |
| 2825 | extends: "libvndk", |
| 2826 | }, |
| 2827 | nocrt: true, |
| 2828 | } |
| 2829 | |
| 2830 | cc_library { |
| 2831 | name: "libvndk2", |
| 2832 | vendor_available: true, |
| 2833 | vndk: { |
| 2834 | enabled: true, |
| 2835 | }, |
| 2836 | target: { |
| 2837 | vendor: { |
| 2838 | shared_libs: ["libvndk_ext"], |
| 2839 | }, |
| 2840 | }, |
| 2841 | nocrt: true, |
| 2842 | } |
| 2843 | `) |
| 2844 | |
| 2845 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 2846 | cc_library { |
| 2847 | name: "libvndk_sp", |
| 2848 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2849 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2850 | vndk: { |
| 2851 | enabled: true, |
| 2852 | support_system_process: true, |
| 2853 | }, |
| 2854 | nocrt: true, |
| 2855 | } |
| 2856 | |
| 2857 | cc_library { |
| 2858 | name: "libvndk_sp_ext", |
| 2859 | vendor: true, |
| 2860 | vndk: { |
| 2861 | enabled: true, |
| 2862 | extends: "libvndk_sp", |
| 2863 | support_system_process: true, |
| 2864 | }, |
| 2865 | nocrt: true, |
| 2866 | } |
| 2867 | |
| 2868 | cc_library { |
| 2869 | name: "libvndk_sp_2", |
| 2870 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2871 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2872 | vndk: { |
| 2873 | enabled: true, |
| 2874 | support_system_process: true, |
| 2875 | }, |
| 2876 | shared_libs: ["libvndk_sp_ext"], |
| 2877 | nocrt: true, |
| 2878 | } |
| 2879 | `) |
| 2880 | |
| Martin Stjernholm | ef449fe | 2018-11-06 16:12:13 +0000 | [diff] [blame] | 2881 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2882 | cc_library { |
| 2883 | name: "libvndk_sp", |
| 2884 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2885 | product_available: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2886 | vndk: { |
| 2887 | enabled: true, |
| 2888 | }, |
| 2889 | nocrt: true, |
| 2890 | } |
| 2891 | |
| 2892 | cc_library { |
| 2893 | name: "libvndk_sp_ext", |
| 2894 | vendor: true, |
| 2895 | vndk: { |
| 2896 | enabled: true, |
| 2897 | extends: "libvndk_sp", |
| 2898 | }, |
| 2899 | nocrt: true, |
| 2900 | } |
| 2901 | |
| 2902 | cc_library { |
| 2903 | name: "libvndk_sp2", |
| 2904 | vendor_available: true, |
| 2905 | vndk: { |
| 2906 | enabled: true, |
| 2907 | }, |
| 2908 | target: { |
| 2909 | vendor: { |
| 2910 | shared_libs: ["libvndk_sp_ext"], |
| 2911 | }, |
| 2912 | }, |
| 2913 | nocrt: true, |
| 2914 | } |
| 2915 | `) |
| 2916 | } |
| 2917 | |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2918 | func TestEnforceProductVndkVersion(t *testing.T) { |
| 2919 | bp := ` |
| 2920 | cc_library { |
| 2921 | name: "libllndk", |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2922 | llndk_stubs: "libllndk.llndk", |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2923 | } |
| 2924 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2925 | name: "libllndk.llndk", |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2926 | symbol_file: "", |
| 2927 | } |
| 2928 | cc_library { |
| 2929 | name: "libvndk", |
| 2930 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2931 | product_available: true, |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2932 | vndk: { |
| 2933 | enabled: true, |
| 2934 | }, |
| 2935 | nocrt: true, |
| 2936 | } |
| 2937 | cc_library { |
| 2938 | name: "libvndk_sp", |
| 2939 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2940 | product_available: true, |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2941 | vndk: { |
| 2942 | enabled: true, |
| 2943 | support_system_process: true, |
| 2944 | }, |
| 2945 | nocrt: true, |
| 2946 | } |
| 2947 | cc_library { |
| 2948 | name: "libva", |
| 2949 | vendor_available: true, |
| 2950 | nocrt: true, |
| 2951 | } |
| 2952 | cc_library { |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2953 | name: "libpa", |
| 2954 | product_available: true, |
| 2955 | nocrt: true, |
| 2956 | } |
| 2957 | cc_library { |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 2958 | name: "libboth_available", |
| 2959 | vendor_available: true, |
| 2960 | product_available: true, |
| 2961 | nocrt: true, |
| 2962 | target: { |
| 2963 | vendor: { |
| 2964 | suffix: "-vendor", |
| 2965 | }, |
| 2966 | product: { |
| 2967 | suffix: "-product", |
| 2968 | }, |
| 2969 | } |
| 2970 | } |
| 2971 | cc_library { |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2972 | name: "libproduct_va", |
| 2973 | product_specific: true, |
| 2974 | vendor_available: true, |
| 2975 | nocrt: true, |
| 2976 | } |
| 2977 | cc_library { |
| 2978 | name: "libprod", |
| 2979 | product_specific: true, |
| 2980 | shared_libs: [ |
| 2981 | "libllndk", |
| 2982 | "libvndk", |
| 2983 | "libvndk_sp", |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2984 | "libpa", |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 2985 | "libboth_available", |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2986 | "libproduct_va", |
| 2987 | ], |
| 2988 | nocrt: true, |
| 2989 | } |
| 2990 | cc_library { |
| 2991 | name: "libvendor", |
| 2992 | vendor: true, |
| 2993 | shared_libs: [ |
| 2994 | "libllndk", |
| 2995 | "libvndk", |
| 2996 | "libvndk_sp", |
| 2997 | "libva", |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 2998 | "libboth_available", |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2999 | "libproduct_va", |
| 3000 | ], |
| 3001 | nocrt: true, |
| 3002 | } |
| 3003 | ` |
| 3004 | |
| 3005 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 3006 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 3007 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 3008 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 3009 | |
| 3010 | ctx := testCcWithConfig(t, config) |
| 3011 | |
| Jooyung Han | 261e158 | 2020-10-20 18:54:21 +0900 | [diff] [blame] | 3012 | checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant) |
| 3013 | checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3014 | |
| 3015 | mod_vendor := ctx.ModuleForTests("libboth_available", vendorVariant).Module().(*Module) |
| 3016 | assertString(t, mod_vendor.outputFile.Path().Base(), "libboth_available-vendor.so") |
| 3017 | |
| 3018 | mod_product := ctx.ModuleForTests("libboth_available", productVariant).Module().(*Module) |
| 3019 | assertString(t, mod_product.outputFile.Path().Base(), "libboth_available-product.so") |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3020 | } |
| 3021 | |
| 3022 | func TestEnforceProductVndkVersionErrors(t *testing.T) { |
| 3023 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3024 | cc_library { |
| 3025 | name: "libprod", |
| 3026 | product_specific: true, |
| 3027 | shared_libs: [ |
| 3028 | "libvendor", |
| 3029 | ], |
| 3030 | nocrt: true, |
| 3031 | } |
| 3032 | cc_library { |
| 3033 | name: "libvendor", |
| 3034 | vendor: true, |
| 3035 | nocrt: true, |
| 3036 | } |
| 3037 | `) |
| 3038 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3039 | cc_library { |
| 3040 | name: "libprod", |
| 3041 | product_specific: true, |
| 3042 | shared_libs: [ |
| 3043 | "libsystem", |
| 3044 | ], |
| 3045 | nocrt: true, |
| 3046 | } |
| 3047 | cc_library { |
| 3048 | name: "libsystem", |
| 3049 | nocrt: true, |
| 3050 | } |
| 3051 | `) |
| Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3052 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3053 | cc_library { |
| 3054 | name: "libprod", |
| 3055 | product_specific: true, |
| 3056 | shared_libs: [ |
| 3057 | "libva", |
| 3058 | ], |
| 3059 | nocrt: true, |
| 3060 | } |
| 3061 | cc_library { |
| 3062 | name: "libva", |
| 3063 | vendor_available: true, |
| 3064 | nocrt: true, |
| 3065 | } |
| 3066 | `) |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3067 | testCcErrorProductVndk(t, "non-VNDK module should not link to \".*\" which has `private: true`", ` |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3068 | cc_library { |
| 3069 | name: "libprod", |
| 3070 | product_specific: true, |
| 3071 | shared_libs: [ |
| 3072 | "libvndk_private", |
| 3073 | ], |
| 3074 | nocrt: true, |
| 3075 | } |
| 3076 | cc_library { |
| 3077 | name: "libvndk_private", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3078 | vendor_available: true, |
| 3079 | product_available: true, |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3080 | vndk: { |
| 3081 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3082 | private: true, |
| Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3083 | }, |
| 3084 | nocrt: true, |
| 3085 | } |
| 3086 | `) |
| 3087 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3088 | cc_library { |
| 3089 | name: "libprod", |
| 3090 | product_specific: true, |
| 3091 | shared_libs: [ |
| 3092 | "libsystem_ext", |
| 3093 | ], |
| 3094 | nocrt: true, |
| 3095 | } |
| 3096 | cc_library { |
| 3097 | name: "libsystem_ext", |
| 3098 | system_ext_specific: true, |
| 3099 | nocrt: true, |
| 3100 | } |
| 3101 | `) |
| 3102 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:", ` |
| 3103 | cc_library { |
| 3104 | name: "libsystem", |
| 3105 | shared_libs: [ |
| 3106 | "libproduct_va", |
| 3107 | ], |
| 3108 | nocrt: true, |
| 3109 | } |
| 3110 | cc_library { |
| 3111 | name: "libproduct_va", |
| 3112 | product_specific: true, |
| 3113 | vendor_available: true, |
| 3114 | nocrt: true, |
| 3115 | } |
| 3116 | `) |
| 3117 | } |
| 3118 | |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3119 | func TestMakeLinkType(t *testing.T) { |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3120 | bp := ` |
| 3121 | cc_library { |
| 3122 | name: "libvndk", |
| 3123 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3124 | product_available: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3125 | vndk: { |
| 3126 | enabled: true, |
| 3127 | }, |
| 3128 | } |
| 3129 | cc_library { |
| 3130 | name: "libvndksp", |
| 3131 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3132 | product_available: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3133 | vndk: { |
| 3134 | enabled: true, |
| 3135 | support_system_process: true, |
| 3136 | }, |
| 3137 | } |
| 3138 | cc_library { |
| 3139 | name: "libvndkprivate", |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3140 | vendor_available: true, |
| 3141 | product_available: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3142 | vndk: { |
| 3143 | enabled: true, |
| Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3144 | private: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3145 | }, |
| 3146 | } |
| 3147 | cc_library { |
| 3148 | name: "libvendor", |
| 3149 | vendor: true, |
| 3150 | } |
| 3151 | cc_library { |
| 3152 | name: "libvndkext", |
| 3153 | vendor: true, |
| 3154 | vndk: { |
| 3155 | enabled: true, |
| 3156 | extends: "libvndk", |
| 3157 | }, |
| 3158 | } |
| 3159 | vndk_prebuilt_shared { |
| 3160 | name: "prevndk", |
| 3161 | version: "27", |
| 3162 | target_arch: "arm", |
| 3163 | binder32bit: true, |
| 3164 | vendor_available: true, |
| Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3165 | product_available: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3166 | vndk: { |
| 3167 | enabled: true, |
| 3168 | }, |
| 3169 | arch: { |
| 3170 | arm: { |
| 3171 | srcs: ["liba.so"], |
| 3172 | }, |
| 3173 | }, |
| 3174 | } |
| 3175 | cc_library { |
| 3176 | name: "libllndk", |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3177 | llndk_stubs: "libllndk.llndk", |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3178 | } |
| 3179 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3180 | name: "libllndk.llndk", |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3181 | symbol_file: "", |
| 3182 | } |
| 3183 | cc_library { |
| 3184 | name: "libllndkprivate", |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3185 | llndk_stubs: "libllndkprivate.llndk", |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3186 | } |
| 3187 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3188 | name: "libllndkprivate.llndk", |
| Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 3189 | private: true, |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3190 | symbol_file: "", |
| Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 3191 | } |
| 3192 | |
| 3193 | llndk_libraries_txt { |
| 3194 | name: "llndk.libraries.txt", |
| 3195 | } |
| 3196 | vndkcore_libraries_txt { |
| 3197 | name: "vndkcore.libraries.txt", |
| 3198 | } |
| 3199 | vndksp_libraries_txt { |
| 3200 | name: "vndksp.libraries.txt", |
| 3201 | } |
| 3202 | vndkprivate_libraries_txt { |
| 3203 | name: "vndkprivate.libraries.txt", |
| 3204 | } |
| 3205 | vndkcorevariant_libraries_txt { |
| 3206 | name: "vndkcorevariant.libraries.txt", |
| 3207 | insert_vndk_version: false, |
| 3208 | } |
| 3209 | ` |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3210 | |
| 3211 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3212 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 3213 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 3214 | // native:vndk |
| Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3215 | ctx := testCcWithConfig(t, config) |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3216 | |
| Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 3217 | checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", |
| 3218 | []string{"libvndk.so", "libvndkprivate.so"}) |
| 3219 | checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", |
| 3220 | []string{"libc++.so", "libvndksp.so"}) |
| 3221 | checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", |
| 3222 | []string{"libc.so", "libdl.so", "libft2.so", "libllndk.so", "libllndkprivate.so", "libm.so"}) |
| 3223 | checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", |
| 3224 | []string{"libft2.so", "libllndkprivate.so", "libvndkprivate.so"}) |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3225 | |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3226 | vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared" |
| Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 3227 | |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3228 | tests := []struct { |
| 3229 | variant string |
| 3230 | name string |
| 3231 | expected string |
| 3232 | }{ |
| 3233 | {vendorVariant, "libvndk", "native:vndk"}, |
| 3234 | {vendorVariant, "libvndksp", "native:vndk"}, |
| 3235 | {vendorVariant, "libvndkprivate", "native:vndk_private"}, |
| 3236 | {vendorVariant, "libvendor", "native:vendor"}, |
| 3237 | {vendorVariant, "libvndkext", "native:vendor"}, |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3238 | {vendorVariant, "libllndk", "native:vndk"}, |
| Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 3239 | {vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"}, |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3240 | {coreVariant, "libvndk", "native:platform"}, |
| 3241 | {coreVariant, "libvndkprivate", "native:platform"}, |
| 3242 | {coreVariant, "libllndk", "native:platform"}, |
| 3243 | } |
| 3244 | for _, test := range tests { |
| 3245 | t.Run(test.name, func(t *testing.T) { |
| 3246 | module := ctx.ModuleForTests(test.name, test.variant).Module().(*Module) |
| 3247 | assertString(t, module.makeLinkType, test.expected) |
| 3248 | }) |
| 3249 | } |
| 3250 | } |
| 3251 | |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3252 | var staticLinkDepOrderTestCases = []struct { |
| 3253 | // This is a string representation of a map[moduleName][]moduleDependency . |
| 3254 | // It models the dependencies declared in an Android.bp file. |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3255 | inStatic string |
| 3256 | |
| 3257 | // This is a string representation of a map[moduleName][]moduleDependency . |
| 3258 | // It models the dependencies declared in an Android.bp file. |
| 3259 | inShared string |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3260 | |
| 3261 | // allOrdered is a string representation of a map[moduleName][]moduleDependency . |
| 3262 | // The keys of allOrdered specify which modules we would like to check. |
| 3263 | // The values of allOrdered specify the expected result (of the transitive closure of all |
| 3264 | // dependencies) for each module to test |
| 3265 | allOrdered string |
| 3266 | |
| 3267 | // outOrdered is a string representation of a map[moduleName][]moduleDependency . |
| 3268 | // The keys of outOrdered specify which modules we would like to check. |
| 3269 | // The values of outOrdered specify the expected result (of the ordered linker command line) |
| 3270 | // for each module to test. |
| 3271 | outOrdered string |
| 3272 | }{ |
| 3273 | // Simple tests |
| 3274 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3275 | inStatic: "", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3276 | outOrdered: "", |
| 3277 | }, |
| 3278 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3279 | inStatic: "a:", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3280 | outOrdered: "a:", |
| 3281 | }, |
| 3282 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3283 | inStatic: "a:b; b:", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3284 | outOrdered: "a:b; b:", |
| 3285 | }, |
| 3286 | // Tests of reordering |
| 3287 | { |
| 3288 | // diamond example |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3289 | inStatic: "a:d,b,c; b:d; c:d; d:", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3290 | outOrdered: "a:b,c,d; b:d; c:d; d:", |
| 3291 | }, |
| 3292 | { |
| 3293 | // somewhat real example |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3294 | inStatic: "bsdiff_unittest:b,c,d,e,f,g,h,i; e:b", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3295 | outOrdered: "bsdiff_unittest:c,d,e,b,f,g,h,i; e:b", |
| 3296 | }, |
| 3297 | { |
| 3298 | // multiple reorderings |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3299 | inStatic: "a:b,c,d,e; d:b; e:c", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3300 | outOrdered: "a:d,b,e,c; d:b; e:c", |
| 3301 | }, |
| 3302 | { |
| 3303 | // should reorder without adding new transitive dependencies |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3304 | inStatic: "bin:lib2,lib1; lib1:lib2,liboptional", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3305 | allOrdered: "bin:lib1,lib2,liboptional; lib1:lib2,liboptional", |
| 3306 | outOrdered: "bin:lib1,lib2; lib1:lib2,liboptional", |
| 3307 | }, |
| 3308 | { |
| 3309 | // multiple levels of dependencies |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3310 | inStatic: "a:b,c,d,e,f,g,h; f:b,c,d; b:c,d; c:d", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3311 | allOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d", |
| 3312 | outOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d", |
| 3313 | }, |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3314 | // shared dependencies |
| 3315 | { |
| 3316 | // Note that this test doesn't recurse, to minimize the amount of logic it tests. |
| 3317 | // So, we don't actually have to check that a shared dependency of c will change the order |
| 3318 | // of a library that depends statically on b and on c. We only need to check that if c has |
| 3319 | // a shared dependency on b, that that shows up in allOrdered. |
| 3320 | inShared: "c:b", |
| 3321 | allOrdered: "c:b", |
| 3322 | outOrdered: "c:", |
| 3323 | }, |
| 3324 | { |
| 3325 | // This test doesn't actually include any shared dependencies but it's a reminder of what |
| 3326 | // the second phase of the above test would look like |
| 3327 | inStatic: "a:b,c; c:b", |
| 3328 | allOrdered: "a:c,b; c:b", |
| 3329 | outOrdered: "a:c,b; c:b", |
| 3330 | }, |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3331 | // tiebreakers for when two modules specifying different orderings and there is no dependency |
| 3332 | // to dictate an order |
| 3333 | { |
| 3334 | // if the tie is between two modules at the end of a's deps, then a's order wins |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3335 | inStatic: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3336 | outOrdered: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d", |
| 3337 | }, |
| 3338 | { |
| 3339 | // if the tie is between two modules at the start of a's deps, then c's order is used |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3340 | inStatic: "a1:d,e,b1,c1; b1:d,e; c1:e,d; a2:d,e,b2,c2; b2:d,e; c2:d,e", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3341 | outOrdered: "a1:b1,c1,e,d; b1:d,e; c1:e,d; a2:b2,c2,d,e; b2:d,e; c2:d,e", |
| 3342 | }, |
| 3343 | // Tests involving duplicate dependencies |
| 3344 | { |
| 3345 | // simple duplicate |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3346 | inStatic: "a:b,c,c,b", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3347 | outOrdered: "a:c,b", |
| 3348 | }, |
| 3349 | { |
| 3350 | // duplicates with reordering |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3351 | inStatic: "a:b,c,d,c; c:b", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3352 | outOrdered: "a:d,c,b", |
| 3353 | }, |
| 3354 | // Tests to confirm the nonexistence of infinite loops. |
| 3355 | // These cases should never happen, so as long as the test terminates and the |
| 3356 | // result is deterministic then that should be fine. |
| 3357 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3358 | inStatic: "a:a", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3359 | outOrdered: "a:a", |
| 3360 | }, |
| 3361 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3362 | inStatic: "a:b; b:c; c:a", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3363 | allOrdered: "a:b,c; b:c,a; c:a,b", |
| 3364 | outOrdered: "a:b; b:c; c:a", |
| 3365 | }, |
| 3366 | { |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3367 | inStatic: "a:b,c; b:c,a; c:a,b", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3368 | allOrdered: "a:c,a,b; b:a,b,c; c:b,c,a", |
| 3369 | outOrdered: "a:c,b; b:a,c; c:b,a", |
| 3370 | }, |
| 3371 | } |
| 3372 | |
| 3373 | // converts from a string like "a:b,c; d:e" to (["a","b"], {"a":["b","c"], "d":["e"]}, [{"a", "a.o"}, {"b", "b.o"}]) |
| 3374 | func parseModuleDeps(text string) (modulesInOrder []android.Path, allDeps map[android.Path][]android.Path) { |
| 3375 | // convert from "a:b,c; d:e" to "a:b,c;d:e" |
| 3376 | strippedText := strings.Replace(text, " ", "", -1) |
| 3377 | if len(strippedText) < 1 { |
| 3378 | return []android.Path{}, make(map[android.Path][]android.Path, 0) |
| 3379 | } |
| 3380 | allDeps = make(map[android.Path][]android.Path, 0) |
| 3381 | |
| 3382 | // convert from "a:b,c;d:e" to ["a:b,c", "d:e"] |
| 3383 | moduleTexts := strings.Split(strippedText, ";") |
| 3384 | |
| 3385 | outputForModuleName := func(moduleName string) android.Path { |
| 3386 | return android.PathForTesting(moduleName) |
| 3387 | } |
| 3388 | |
| 3389 | for _, moduleText := range moduleTexts { |
| 3390 | // convert from "a:b,c" to ["a", "b,c"] |
| 3391 | components := strings.Split(moduleText, ":") |
| 3392 | if len(components) != 2 { |
| 3393 | panic(fmt.Sprintf("illegal module dep string %q from larger string %q; must contain one ':', not %v", moduleText, text, len(components)-1)) |
| 3394 | } |
| 3395 | moduleName := components[0] |
| 3396 | moduleOutput := outputForModuleName(moduleName) |
| 3397 | modulesInOrder = append(modulesInOrder, moduleOutput) |
| 3398 | |
| 3399 | depString := components[1] |
| 3400 | // convert from "b,c" to ["b", "c"] |
| 3401 | depNames := strings.Split(depString, ",") |
| 3402 | if len(depString) < 1 { |
| 3403 | depNames = []string{} |
| 3404 | } |
| 3405 | var deps []android.Path |
| 3406 | for _, depName := range depNames { |
| 3407 | deps = append(deps, outputForModuleName(depName)) |
| 3408 | } |
| 3409 | allDeps[moduleOutput] = deps |
| 3410 | } |
| 3411 | return modulesInOrder, allDeps |
| 3412 | } |
| 3413 | |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3414 | func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) { |
| 3415 | for _, moduleName := range moduleNames { |
| 3416 | module := ctx.ModuleForTests(moduleName, variant).Module().(*Module) |
| 3417 | output := module.outputFile.Path() |
| 3418 | paths = append(paths, output) |
| 3419 | } |
| 3420 | return paths |
| 3421 | } |
| 3422 | |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3423 | func TestStaticLibDepReordering(t *testing.T) { |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3424 | ctx := testCc(t, ` |
| 3425 | cc_library { |
| 3426 | name: "a", |
| 3427 | static_libs: ["b", "c", "d"], |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3428 | stl: "none", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3429 | } |
| 3430 | cc_library { |
| 3431 | name: "b", |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3432 | stl: "none", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3433 | } |
| 3434 | cc_library { |
| 3435 | name: "c", |
| 3436 | static_libs: ["b"], |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3437 | stl: "none", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3438 | } |
| 3439 | cc_library { |
| 3440 | name: "d", |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3441 | stl: "none", |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3442 | } |
| 3443 | |
| 3444 | `) |
| 3445 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3446 | variant := "android_arm64_armv8-a_static" |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3447 | moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3448 | actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList() |
| 3449 | expected := getOutputPaths(ctx, variant, []string{"a", "c", "b", "d"}) |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3450 | |
| 3451 | if !reflect.DeepEqual(actual, expected) { |
| 3452 | t.Errorf("staticDeps orderings were not propagated correctly"+ |
| 3453 | "\nactual: %v"+ |
| 3454 | "\nexpected: %v", |
| 3455 | actual, |
| 3456 | expected, |
| 3457 | ) |
| 3458 | } |
| Jiyong Park | d08b697 | 2017-09-26 10:50:54 +0900 | [diff] [blame] | 3459 | } |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3460 | |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3461 | func TestStaticLibDepReorderingWithShared(t *testing.T) { |
| 3462 | ctx := testCc(t, ` |
| 3463 | cc_library { |
| 3464 | name: "a", |
| 3465 | static_libs: ["b", "c"], |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3466 | stl: "none", |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3467 | } |
| 3468 | cc_library { |
| 3469 | name: "b", |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3470 | stl: "none", |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3471 | } |
| 3472 | cc_library { |
| 3473 | name: "c", |
| 3474 | shared_libs: ["b"], |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3475 | stl: "none", |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3476 | } |
| 3477 | |
| 3478 | `) |
| 3479 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3480 | variant := "android_arm64_armv8-a_static" |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3481 | moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3482 | actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList() |
| 3483 | expected := getOutputPaths(ctx, variant, []string{"a", "c", "b"}) |
| Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3484 | |
| 3485 | if !reflect.DeepEqual(actual, expected) { |
| 3486 | t.Errorf("staticDeps orderings did not account for shared libs"+ |
| 3487 | "\nactual: %v"+ |
| 3488 | "\nexpected: %v", |
| 3489 | actual, |
| 3490 | expected, |
| 3491 | ) |
| 3492 | } |
| 3493 | } |
| 3494 | |
| Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 3495 | func checkEquals(t *testing.T, message string, expected, actual interface{}) { |
| Colin Cross | d1f898e | 2020-08-18 18:35:15 -0700 | [diff] [blame] | 3496 | t.Helper() |
| Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 3497 | if !reflect.DeepEqual(actual, expected) { |
| 3498 | t.Errorf(message+ |
| 3499 | "\nactual: %v"+ |
| 3500 | "\nexpected: %v", |
| 3501 | actual, |
| 3502 | expected, |
| 3503 | ) |
| 3504 | } |
| 3505 | } |
| 3506 | |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3507 | func TestLlndkLibrary(t *testing.T) { |
| 3508 | ctx := testCc(t, ` |
| 3509 | cc_library { |
| 3510 | name: "libllndk", |
| 3511 | stubs: { versions: ["1", "2"] }, |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3512 | llndk_stubs: "libllndk.llndk", |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3513 | } |
| 3514 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3515 | name: "libllndk.llndk", |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3516 | } |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3517 | |
| 3518 | cc_prebuilt_library_shared { |
| 3519 | name: "libllndkprebuilt", |
| 3520 | stubs: { versions: ["1", "2"] }, |
| 3521 | llndk_stubs: "libllndkprebuilt.llndk", |
| 3522 | } |
| 3523 | llndk_library { |
| 3524 | name: "libllndkprebuilt.llndk", |
| 3525 | } |
| 3526 | |
| 3527 | cc_library { |
| 3528 | name: "libllndk_with_external_headers", |
| 3529 | stubs: { versions: ["1", "2"] }, |
| 3530 | llndk_stubs: "libllndk_with_external_headers.llndk", |
| 3531 | header_libs: ["libexternal_headers"], |
| 3532 | export_header_lib_headers: ["libexternal_headers"], |
| 3533 | } |
| 3534 | llndk_library { |
| 3535 | name: "libllndk_with_external_headers.llndk", |
| 3536 | } |
| 3537 | cc_library_headers { |
| 3538 | name: "libexternal_headers", |
| 3539 | export_include_dirs: ["include"], |
| 3540 | vendor_available: true, |
| 3541 | } |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3542 | `) |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3543 | actual := ctx.ModuleVariantsForTests("libllndk") |
| 3544 | for i := 0; i < len(actual); i++ { |
| 3545 | if !strings.HasPrefix(actual[i], "android_vendor.VER_") { |
| 3546 | actual = append(actual[:i], actual[i+1:]...) |
| 3547 | i-- |
| 3548 | } |
| 3549 | } |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3550 | expected := []string{ |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3551 | "android_vendor.VER_arm64_armv8-a_shared_1", |
| 3552 | "android_vendor.VER_arm64_armv8-a_shared_2", |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3553 | "android_vendor.VER_arm64_armv8-a_shared", |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3554 | "android_vendor.VER_arm_armv7-a-neon_shared_1", |
| 3555 | "android_vendor.VER_arm_armv7-a-neon_shared_2", |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3556 | "android_vendor.VER_arm_armv7-a-neon_shared", |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3557 | } |
| 3558 | checkEquals(t, "variants for llndk stubs", expected, actual) |
| 3559 | |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3560 | params := ctx.ModuleForTests("libllndk", "android_vendor.VER_arm_armv7-a-neon_shared").Description("generate stub") |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3561 | checkEquals(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"]) |
| 3562 | |
| Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3563 | params = ctx.ModuleForTests("libllndk", "android_vendor.VER_arm_armv7-a-neon_shared_1").Description("generate stub") |
| Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3564 | checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"]) |
| 3565 | } |
| 3566 | |
| Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3567 | func TestLlndkHeaders(t *testing.T) { |
| 3568 | ctx := testCc(t, ` |
| 3569 | llndk_headers { |
| 3570 | name: "libllndk_headers", |
| 3571 | export_include_dirs: ["my_include"], |
| 3572 | } |
| 3573 | llndk_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3574 | name: "libllndk.llndk", |
| Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3575 | export_llndk_headers: ["libllndk_headers"], |
| 3576 | } |
| 3577 | cc_library { |
| Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3578 | name: "libllndk", |
| 3579 | llndk_stubs: "libllndk.llndk", |
| 3580 | } |
| 3581 | |
| 3582 | cc_library { |
| Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3583 | name: "libvendor", |
| 3584 | shared_libs: ["libllndk"], |
| 3585 | vendor: true, |
| 3586 | srcs: ["foo.c"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3587 | no_libcrt: true, |
| Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 3588 | nocrt: true, |
| Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3589 | } |
| 3590 | `) |
| 3591 | |
| 3592 | // _static variant is used since _shared reuses *.o from the static variant |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3593 | cc := ctx.ModuleForTests("libvendor", "android_vendor.VER_arm_armv7-a-neon_static").Rule("cc") |
| Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3594 | cflags := cc.Args["cFlags"] |
| 3595 | if !strings.Contains(cflags, "-Imy_include") { |
| 3596 | t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags) |
| 3597 | } |
| 3598 | } |
| 3599 | |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3600 | func checkRuntimeLibs(t *testing.T, expected []string, module *Module) { |
| 3601 | actual := module.Properties.AndroidMkRuntimeLibs |
| 3602 | if !reflect.DeepEqual(actual, expected) { |
| 3603 | t.Errorf("incorrect runtime_libs for shared libs"+ |
| 3604 | "\nactual: %v"+ |
| 3605 | "\nexpected: %v", |
| 3606 | actual, |
| 3607 | expected, |
| 3608 | ) |
| 3609 | } |
| 3610 | } |
| 3611 | |
| 3612 | const runtimeLibAndroidBp = ` |
| 3613 | cc_library { |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3614 | name: "liball_available", |
| 3615 | vendor_available: true, |
| 3616 | product_available: true, |
| 3617 | no_libcrt : true, |
| 3618 | nocrt : true, |
| 3619 | system_shared_libs : [], |
| 3620 | } |
| 3621 | cc_library { |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3622 | name: "libvendor_available1", |
| 3623 | vendor_available: true, |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3624 | runtime_libs: ["liball_available"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3625 | no_libcrt : true, |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3626 | nocrt : true, |
| 3627 | system_shared_libs : [], |
| 3628 | } |
| 3629 | cc_library { |
| 3630 | name: "libvendor_available2", |
| 3631 | vendor_available: true, |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3632 | runtime_libs: ["liball_available"], |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3633 | target: { |
| 3634 | vendor: { |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3635 | exclude_runtime_libs: ["liball_available"], |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3636 | } |
| 3637 | }, |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3638 | no_libcrt : true, |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3639 | nocrt : true, |
| 3640 | system_shared_libs : [], |
| 3641 | } |
| 3642 | cc_library { |
| 3643 | name: "libcore", |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3644 | runtime_libs: ["liball_available"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3645 | no_libcrt : true, |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3646 | nocrt : true, |
| 3647 | system_shared_libs : [], |
| 3648 | } |
| 3649 | cc_library { |
| 3650 | name: "libvendor1", |
| 3651 | vendor: true, |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3652 | no_libcrt : true, |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3653 | nocrt : true, |
| 3654 | system_shared_libs : [], |
| 3655 | } |
| 3656 | cc_library { |
| 3657 | name: "libvendor2", |
| 3658 | vendor: true, |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3659 | runtime_libs: ["liball_available", "libvendor1"], |
| 3660 | no_libcrt : true, |
| 3661 | nocrt : true, |
| 3662 | system_shared_libs : [], |
| 3663 | } |
| 3664 | cc_library { |
| 3665 | name: "libproduct_available1", |
| 3666 | product_available: true, |
| 3667 | runtime_libs: ["liball_available"], |
| 3668 | no_libcrt : true, |
| 3669 | nocrt : true, |
| 3670 | system_shared_libs : [], |
| 3671 | } |
| 3672 | cc_library { |
| 3673 | name: "libproduct1", |
| 3674 | product_specific: true, |
| 3675 | no_libcrt : true, |
| 3676 | nocrt : true, |
| 3677 | system_shared_libs : [], |
| 3678 | } |
| 3679 | cc_library { |
| 3680 | name: "libproduct2", |
| 3681 | product_specific: true, |
| 3682 | runtime_libs: ["liball_available", "libproduct1"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3683 | no_libcrt : true, |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3684 | nocrt : true, |
| 3685 | system_shared_libs : [], |
| 3686 | } |
| 3687 | ` |
| 3688 | |
| 3689 | func TestRuntimeLibs(t *testing.T) { |
| 3690 | ctx := testCc(t, runtimeLibAndroidBp) |
| 3691 | |
| 3692 | // runtime_libs for core variants use the module names without suffixes. |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3693 | variant := "android_arm64_armv8-a_shared" |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3694 | |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3695 | module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3696 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| 3697 | |
| 3698 | module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module) |
| 3699 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3700 | |
| 3701 | module = ctx.ModuleForTests("libcore", variant).Module().(*Module) |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3702 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3703 | |
| 3704 | // runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core |
| 3705 | // and vendor variants. |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3706 | variant = "android_vendor.VER_arm64_armv8-a_shared" |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3707 | |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3708 | module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3709 | checkRuntimeLibs(t, []string{"liball_available.vendor"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3710 | |
| 3711 | module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module) |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3712 | checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1"}, module) |
| 3713 | |
| 3714 | // runtime_libs for product variants have '.product' suffixes if the modules have both core |
| 3715 | // and product variants. |
| 3716 | variant = "android_product.VER_arm64_armv8-a_shared" |
| 3717 | |
| 3718 | module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module) |
| 3719 | checkRuntimeLibs(t, []string{"liball_available.product"}, module) |
| 3720 | |
| 3721 | module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module) |
| 3722 | checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3723 | } |
| 3724 | |
| 3725 | func TestExcludeRuntimeLibs(t *testing.T) { |
| 3726 | ctx := testCc(t, runtimeLibAndroidBp) |
| 3727 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3728 | variant := "android_arm64_armv8-a_shared" |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3729 | module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) |
| 3730 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3731 | |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3732 | variant = "android_vendor.VER_arm64_armv8-a_shared" |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3733 | module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3734 | checkRuntimeLibs(t, nil, module) |
| 3735 | } |
| 3736 | |
| 3737 | func TestRuntimeLibsNoVndk(t *testing.T) { |
| 3738 | ctx := testCcNoVndk(t, runtimeLibAndroidBp) |
| 3739 | |
| 3740 | // If DeviceVndkVersion is not defined, then runtime_libs are copied as-is. |
| 3741 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3742 | variant := "android_arm64_armv8-a_shared" |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3743 | |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3744 | module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3745 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3746 | |
| 3747 | module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module) |
| Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3748 | checkRuntimeLibs(t, []string{"liball_available", "libvendor1"}, module) |
| 3749 | |
| 3750 | module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module) |
| 3751 | checkRuntimeLibs(t, []string{"liball_available", "libproduct1"}, module) |
| Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3752 | } |
| 3753 | |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3754 | func checkStaticLibs(t *testing.T, expected []string, module *Module) { |
| Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 3755 | t.Helper() |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3756 | actual := module.Properties.AndroidMkStaticLibs |
| 3757 | if !reflect.DeepEqual(actual, expected) { |
| 3758 | t.Errorf("incorrect static_libs"+ |
| 3759 | "\nactual: %v"+ |
| 3760 | "\nexpected: %v", |
| 3761 | actual, |
| 3762 | expected, |
| 3763 | ) |
| 3764 | } |
| 3765 | } |
| 3766 | |
| 3767 | const staticLibAndroidBp = ` |
| 3768 | cc_library { |
| 3769 | name: "lib1", |
| 3770 | } |
| 3771 | cc_library { |
| 3772 | name: "lib2", |
| 3773 | static_libs: ["lib1"], |
| 3774 | } |
| 3775 | ` |
| 3776 | |
| 3777 | func TestStaticLibDepExport(t *testing.T) { |
| 3778 | ctx := testCc(t, staticLibAndroidBp) |
| 3779 | |
| 3780 | // Check the shared version of lib2. |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3781 | variant := "android_arm64_armv8-a_shared" |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3782 | module := ctx.ModuleForTests("lib2", variant).Module().(*Module) |
| Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 3783 | checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic"}, module) |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3784 | |
| 3785 | // Check the static version of lib2. |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3786 | variant = "android_arm64_armv8-a_static" |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3787 | module = ctx.ModuleForTests("lib2", variant).Module().(*Module) |
| 3788 | // libc++_static is linked additionally. |
| Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 3789 | checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins-aarch64-android", "libatomic"}, module) |
| Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3790 | } |
| 3791 | |
| Jiyong Park | d08b697 | 2017-09-26 10:50:54 +0900 | [diff] [blame] | 3792 | var compilerFlagsTestCases = []struct { |
| 3793 | in string |
| 3794 | out bool |
| 3795 | }{ |
| 3796 | { |
| 3797 | in: "a", |
| 3798 | out: false, |
| 3799 | }, |
| 3800 | { |
| 3801 | in: "-a", |
| 3802 | out: true, |
| 3803 | }, |
| 3804 | { |
| 3805 | in: "-Ipath/to/something", |
| 3806 | out: false, |
| 3807 | }, |
| 3808 | { |
| 3809 | in: "-isystempath/to/something", |
| 3810 | out: false, |
| 3811 | }, |
| 3812 | { |
| 3813 | in: "--coverage", |
| 3814 | out: false, |
| 3815 | }, |
| 3816 | { |
| 3817 | in: "-include a/b", |
| 3818 | out: true, |
| 3819 | }, |
| 3820 | { |
| 3821 | in: "-include a/b c/d", |
| 3822 | out: false, |
| 3823 | }, |
| 3824 | { |
| 3825 | in: "-DMACRO", |
| 3826 | out: true, |
| 3827 | }, |
| 3828 | { |
| 3829 | in: "-DMAC RO", |
| 3830 | out: false, |
| 3831 | }, |
| 3832 | { |
| 3833 | in: "-a -b", |
| 3834 | out: false, |
| 3835 | }, |
| 3836 | { |
| 3837 | in: "-DMACRO=definition", |
| 3838 | out: true, |
| 3839 | }, |
| 3840 | { |
| 3841 | in: "-DMACRO=defi nition", |
| 3842 | out: true, // TODO(jiyong): this should be false |
| 3843 | }, |
| 3844 | { |
| 3845 | in: "-DMACRO(x)=x + 1", |
| 3846 | out: true, |
| 3847 | }, |
| 3848 | { |
| 3849 | in: "-DMACRO=\"defi nition\"", |
| 3850 | out: true, |
| 3851 | }, |
| 3852 | } |
| 3853 | |
| 3854 | type mockContext struct { |
| 3855 | BaseModuleContext |
| 3856 | result bool |
| 3857 | } |
| 3858 | |
| 3859 | func (ctx *mockContext) PropertyErrorf(property, format string, args ...interface{}) { |
| 3860 | // CheckBadCompilerFlags calls this function when the flag should be rejected |
| 3861 | ctx.result = false |
| 3862 | } |
| 3863 | |
| 3864 | func TestCompilerFlags(t *testing.T) { |
| 3865 | for _, testCase := range compilerFlagsTestCases { |
| 3866 | ctx := &mockContext{result: true} |
| 3867 | CheckBadCompilerFlags(ctx, "", []string{testCase.in}) |
| 3868 | if ctx.result != testCase.out { |
| 3869 | t.Errorf("incorrect output:") |
| 3870 | t.Errorf(" input: %#v", testCase.in) |
| 3871 | t.Errorf(" expected: %#v", testCase.out) |
| 3872 | t.Errorf(" got: %#v", ctx.result) |
| 3873 | } |
| 3874 | } |
| Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3875 | } |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3876 | |
| 3877 | func TestVendorPublicLibraries(t *testing.T) { |
| 3878 | ctx := testCc(t, ` |
| 3879 | cc_library_headers { |
| 3880 | name: "libvendorpublic_headers", |
| 3881 | export_include_dirs: ["my_include"], |
| 3882 | } |
| 3883 | vendor_public_library { |
| 3884 | name: "libvendorpublic", |
| 3885 | symbol_file: "", |
| 3886 | export_public_headers: ["libvendorpublic_headers"], |
| 3887 | } |
| 3888 | cc_library { |
| 3889 | name: "libvendorpublic", |
| 3890 | srcs: ["foo.c"], |
| 3891 | vendor: true, |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3892 | no_libcrt: true, |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3893 | nocrt: true, |
| 3894 | } |
| 3895 | |
| 3896 | cc_library { |
| 3897 | name: "libsystem", |
| 3898 | shared_libs: ["libvendorpublic"], |
| 3899 | vendor: false, |
| 3900 | srcs: ["foo.c"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3901 | no_libcrt: true, |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3902 | nocrt: true, |
| 3903 | } |
| 3904 | cc_library { |
| 3905 | name: "libvendor", |
| 3906 | shared_libs: ["libvendorpublic"], |
| 3907 | vendor: true, |
| 3908 | srcs: ["foo.c"], |
| Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3909 | no_libcrt: true, |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3910 | nocrt: true, |
| 3911 | } |
| 3912 | `) |
| 3913 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3914 | coreVariant := "android_arm64_armv8-a_shared" |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3915 | vendorVariant := "android_vendor.VER_arm64_armv8-a_shared" |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3916 | |
| 3917 | // test if header search paths are correctly added |
| 3918 | // _static variant is used since _shared reuses *.o from the static variant |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3919 | cc := ctx.ModuleForTests("libsystem", strings.Replace(coreVariant, "_shared", "_static", 1)).Rule("cc") |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3920 | cflags := cc.Args["cFlags"] |
| 3921 | if !strings.Contains(cflags, "-Imy_include") { |
| 3922 | t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags) |
| 3923 | } |
| 3924 | |
| 3925 | // test if libsystem is linked to the stub |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3926 | ld := ctx.ModuleForTests("libsystem", coreVariant).Rule("ld") |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3927 | libflags := ld.Args["libFlags"] |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3928 | stubPaths := getOutputPaths(ctx, coreVariant, []string{"libvendorpublic" + vendorPublicLibrarySuffix}) |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3929 | if !strings.Contains(libflags, stubPaths[0].String()) { |
| 3930 | t.Errorf("libflags for libsystem must contain %#v, but was %#v", stubPaths[0], libflags) |
| 3931 | } |
| 3932 | |
| 3933 | // test if libvendor is linked to the real shared lib |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3934 | ld = ctx.ModuleForTests("libvendor", vendorVariant).Rule("ld") |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3935 | libflags = ld.Args["libFlags"] |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3936 | stubPaths = getOutputPaths(ctx, vendorVariant, []string{"libvendorpublic"}) |
| Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3937 | if !strings.Contains(libflags, stubPaths[0].String()) { |
| 3938 | t.Errorf("libflags for libvendor must contain %#v, but was %#v", stubPaths[0], libflags) |
| 3939 | } |
| 3940 | |
| 3941 | } |
| Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3942 | |
| 3943 | func TestRecovery(t *testing.T) { |
| 3944 | ctx := testCc(t, ` |
| 3945 | cc_library_shared { |
| 3946 | name: "librecovery", |
| 3947 | recovery: true, |
| 3948 | } |
| 3949 | cc_library_shared { |
| 3950 | name: "librecovery32", |
| 3951 | recovery: true, |
| 3952 | compile_multilib:"32", |
| 3953 | } |
| Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 3954 | cc_library_shared { |
| 3955 | name: "libHalInRecovery", |
| 3956 | recovery_available: true, |
| 3957 | vendor: true, |
| 3958 | } |
| Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3959 | `) |
| 3960 | |
| 3961 | variants := ctx.ModuleVariantsForTests("librecovery") |
| Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3962 | const arm64 = "android_recovery_arm64_armv8-a_shared" |
| Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3963 | if len(variants) != 1 || !android.InList(arm64, variants) { |
| 3964 | t.Errorf("variants of librecovery must be \"%s\" only, but was %#v", arm64, variants) |
| 3965 | } |
| 3966 | |
| 3967 | variants = ctx.ModuleVariantsForTests("librecovery32") |
| 3968 | if android.InList(arm64, variants) { |
| 3969 | t.Errorf("multilib was set to 32 for librecovery32, but its variants has %s.", arm64) |
| 3970 | } |
| Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 3971 | |
| 3972 | recoveryModule := ctx.ModuleForTests("libHalInRecovery", recoveryVariant).Module().(*Module) |
| 3973 | if !recoveryModule.Platform() { |
| 3974 | t.Errorf("recovery variant of libHalInRecovery must not specific to device, soc, or product") |
| 3975 | } |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 3976 | } |
| Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 3977 | |
| Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 3978 | func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) { |
| 3979 | bp := ` |
| 3980 | cc_prebuilt_test_library_shared { |
| 3981 | name: "test_lib", |
| 3982 | relative_install_path: "foo/bar/baz", |
| 3983 | srcs: ["srcpath/dontusethispath/baz.so"], |
| 3984 | } |
| 3985 | |
| 3986 | cc_test { |
| 3987 | name: "main_test", |
| 3988 | data_libs: ["test_lib"], |
| 3989 | gtest: false, |
| 3990 | } |
| 3991 | ` |
| 3992 | |
| 3993 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 3994 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 3995 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 3996 | config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) |
| 3997 | |
| 3998 | ctx := testCcWithConfig(t, config) |
| 3999 | module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() |
| 4000 | testBinary := module.(*Module).linker.(*testBinary) |
| 4001 | outputFiles, err := module.(android.OutputFileProducer).OutputFiles("") |
| 4002 | if err != nil { |
| 4003 | t.Fatalf("Expected cc_test to produce output files, error: %s", err) |
| 4004 | } |
| 4005 | if len(outputFiles) != 1 { |
| 4006 | t.Errorf("expected exactly one output file. output files: [%s]", outputFiles) |
| 4007 | } |
| 4008 | if len(testBinary.dataPaths()) != 1 { |
| 4009 | t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) |
| 4010 | } |
| 4011 | |
| 4012 | outputPath := outputFiles[0].String() |
| 4013 | |
| 4014 | if !strings.HasSuffix(outputPath, "/main_test") { |
| 4015 | t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath) |
| 4016 | } |
| 4017 | entries := android.AndroidMkEntriesForTest(t, config, "", module)[0] |
| 4018 | if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") { |
| 4019 | t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+ |
| 4020 | " but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0]) |
| 4021 | } |
| 4022 | } |
| 4023 | |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4024 | func TestVersionedStubs(t *testing.T) { |
| 4025 | ctx := testCc(t, ` |
| 4026 | cc_library_shared { |
| 4027 | name: "libFoo", |
| Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4028 | srcs: ["foo.c"], |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4029 | stubs: { |
| 4030 | symbol_file: "foo.map.txt", |
| 4031 | versions: ["1", "2", "3"], |
| 4032 | }, |
| 4033 | } |
| Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4034 | |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4035 | cc_library_shared { |
| 4036 | name: "libBar", |
| Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4037 | srcs: ["bar.c"], |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4038 | shared_libs: ["libFoo#1"], |
| 4039 | }`) |
| 4040 | |
| 4041 | variants := ctx.ModuleVariantsForTests("libFoo") |
| 4042 | expectedVariants := []string{ |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4043 | "android_arm64_armv8-a_shared", |
| 4044 | "android_arm64_armv8-a_shared_1", |
| 4045 | "android_arm64_armv8-a_shared_2", |
| 4046 | "android_arm64_armv8-a_shared_3", |
| 4047 | "android_arm_armv7-a-neon_shared", |
| 4048 | "android_arm_armv7-a-neon_shared_1", |
| 4049 | "android_arm_armv7-a-neon_shared_2", |
| 4050 | "android_arm_armv7-a-neon_shared_3", |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4051 | } |
| 4052 | variantsMismatch := false |
| 4053 | if len(variants) != len(expectedVariants) { |
| 4054 | variantsMismatch = true |
| 4055 | } else { |
| 4056 | for _, v := range expectedVariants { |
| 4057 | if !inList(v, variants) { |
| 4058 | variantsMismatch = false |
| 4059 | } |
| 4060 | } |
| 4061 | } |
| 4062 | if variantsMismatch { |
| 4063 | t.Errorf("variants of libFoo expected:\n") |
| 4064 | for _, v := range expectedVariants { |
| 4065 | t.Errorf("%q\n", v) |
| 4066 | } |
| 4067 | t.Errorf(", but got:\n") |
| 4068 | for _, v := range variants { |
| 4069 | t.Errorf("%q\n", v) |
| 4070 | } |
| 4071 | } |
| 4072 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4073 | libBarLinkRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("ld") |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4074 | libFlags := libBarLinkRule.Args["libFlags"] |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4075 | libFoo1StubPath := "libFoo/android_arm64_armv8-a_shared_1/libFoo.so" |
| Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4076 | if !strings.Contains(libFlags, libFoo1StubPath) { |
| 4077 | t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags) |
| 4078 | } |
| Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4079 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4080 | libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("cc") |
| Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4081 | cFlags := libBarCompileRule.Args["cFlags"] |
| 4082 | libFoo1VersioningMacro := "-D__LIBFOO_API__=1" |
| 4083 | if !strings.Contains(cFlags, libFoo1VersioningMacro) { |
| 4084 | t.Errorf("%q is not found in %q", libFoo1VersioningMacro, cFlags) |
| 4085 | } |
| Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 4086 | } |
| Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4087 | |
| Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 4088 | func TestVersioningMacro(t *testing.T) { |
| 4089 | for _, tc := range []struct{ moduleName, expected string }{ |
| 4090 | {"libc", "__LIBC_API__"}, |
| 4091 | {"libfoo", "__LIBFOO_API__"}, |
| 4092 | {"libfoo@1", "__LIBFOO_1_API__"}, |
| 4093 | {"libfoo-v1", "__LIBFOO_V1_API__"}, |
| 4094 | {"libfoo.v1", "__LIBFOO_V1_API__"}, |
| 4095 | } { |
| 4096 | checkEquals(t, tc.moduleName, tc.expected, versioningMacroName(tc.moduleName)) |
| 4097 | } |
| 4098 | } |
| 4099 | |
| Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4100 | func TestStaticExecutable(t *testing.T) { |
| 4101 | ctx := testCc(t, ` |
| 4102 | cc_binary { |
| 4103 | name: "static_test", |
| Pete Bentley | fcf55bf | 2019-08-16 20:14:32 +0100 | [diff] [blame] | 4104 | srcs: ["foo.c", "baz.o"], |
| Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4105 | static_executable: true, |
| 4106 | }`) |
| 4107 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4108 | variant := "android_arm64_armv8-a" |
| Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4109 | binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld") |
| 4110 | libFlags := binModuleRule.Args["libFlags"] |
| Ryan Prichard | b49fe1b | 2019-10-11 15:03:34 -0700 | [diff] [blame] | 4111 | systemStaticLibs := []string{"libc.a", "libm.a"} |
| Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4112 | for _, lib := range systemStaticLibs { |
| 4113 | if !strings.Contains(libFlags, lib) { |
| 4114 | t.Errorf("Static lib %q was not found in %q", lib, libFlags) |
| 4115 | } |
| 4116 | } |
| 4117 | systemSharedLibs := []string{"libc.so", "libm.so", "libdl.so"} |
| 4118 | for _, lib := range systemSharedLibs { |
| 4119 | if strings.Contains(libFlags, lib) { |
| 4120 | t.Errorf("Shared lib %q was found in %q", lib, libFlags) |
| 4121 | } |
| 4122 | } |
| 4123 | } |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4124 | |
| 4125 | func TestStaticDepsOrderWithStubs(t *testing.T) { |
| 4126 | ctx := testCc(t, ` |
| 4127 | cc_binary { |
| 4128 | name: "mybin", |
| 4129 | srcs: ["foo.c"], |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 4130 | static_libs: ["libfooC", "libfooB"], |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4131 | static_executable: true, |
| 4132 | stl: "none", |
| 4133 | } |
| 4134 | |
| 4135 | cc_library { |
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4136 | name: "libfooB", |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4137 | srcs: ["foo.c"], |
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4138 | shared_libs: ["libfooC"], |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4139 | stl: "none", |
| 4140 | } |
| 4141 | |
| 4142 | cc_library { |
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4143 | name: "libfooC", |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4144 | srcs: ["foo.c"], |
| 4145 | stl: "none", |
| 4146 | stubs: { |
| 4147 | versions: ["1"], |
| 4148 | }, |
| 4149 | }`) |
| 4150 | |
| Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 4151 | mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Rule("ld") |
| 4152 | actual := mybin.Implicits[:2] |
| Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4153 | expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"}) |
| Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4154 | |
| 4155 | if !reflect.DeepEqual(actual, expected) { |
| 4156 | t.Errorf("staticDeps orderings were not propagated correctly"+ |
| 4157 | "\nactual: %v"+ |
| 4158 | "\nexpected: %v", |
| 4159 | actual, |
| 4160 | expected, |
| 4161 | ) |
| 4162 | } |
| 4163 | } |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 4164 | |
| Jooyung Han | d48f3c3 | 2019-08-23 11:18:57 +0900 | [diff] [blame] | 4165 | func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) { |
| 4166 | testCcError(t, `module "libA" .* depends on disabled module "libB"`, ` |
| 4167 | cc_library { |
| 4168 | name: "libA", |
| 4169 | srcs: ["foo.c"], |
| 4170 | shared_libs: ["libB"], |
| 4171 | stl: "none", |
| 4172 | } |
| 4173 | |
| 4174 | cc_library { |
| 4175 | name: "libB", |
| 4176 | srcs: ["foo.c"], |
| 4177 | enabled: false, |
| 4178 | stl: "none", |
| 4179 | } |
| 4180 | `) |
| 4181 | } |
| 4182 | |
| Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 4183 | // Simple smoke test for the cc_fuzz target that ensures the rule compiles |
| 4184 | // correctly. |
| 4185 | func TestFuzzTarget(t *testing.T) { |
| 4186 | ctx := testCc(t, ` |
| 4187 | cc_fuzz { |
| 4188 | name: "fuzz_smoke_test", |
| 4189 | srcs: ["foo.c"], |
| 4190 | }`) |
| 4191 | |
| Paul Duffin | 075c417 | 2019-12-19 19:06:13 +0000 | [diff] [blame] | 4192 | variant := "android_arm64_armv8-a_fuzzer" |
| Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 4193 | ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc") |
| 4194 | } |
| 4195 | |
| Jiyong Park | 2907459 | 2019-07-07 16:27:47 +0900 | [diff] [blame] | 4196 | func TestAidl(t *testing.T) { |
| 4197 | } |
| 4198 | |
| Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 4199 | func assertString(t *testing.T, got, expected string) { |
| 4200 | t.Helper() |
| 4201 | if got != expected { |
| 4202 | t.Errorf("expected %q got %q", expected, got) |
| 4203 | } |
| 4204 | } |
| 4205 | |
| 4206 | func assertArrayString(t *testing.T, got, expected []string) { |
| 4207 | t.Helper() |
| 4208 | if len(got) != len(expected) { |
| 4209 | t.Errorf("expected %d (%q) got (%d) %q", len(expected), expected, len(got), got) |
| 4210 | return |
| 4211 | } |
| 4212 | for i := range got { |
| 4213 | if got[i] != expected[i] { |
| 4214 | t.Errorf("expected %d-th %q (%q) got %q (%q)", |
| 4215 | i, expected[i], expected, got[i], got) |
| 4216 | return |
| 4217 | } |
| 4218 | } |
| 4219 | } |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4220 | |
| Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 4221 | func assertMapKeys(t *testing.T, m map[string]string, expected []string) { |
| 4222 | t.Helper() |
| 4223 | assertArrayString(t, android.SortedStringKeys(m), expected) |
| 4224 | } |
| 4225 | |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4226 | func TestDefaults(t *testing.T) { |
| 4227 | ctx := testCc(t, ` |
| 4228 | cc_defaults { |
| 4229 | name: "defaults", |
| 4230 | srcs: ["foo.c"], |
| 4231 | static: { |
| 4232 | srcs: ["bar.c"], |
| 4233 | }, |
| 4234 | shared: { |
| 4235 | srcs: ["baz.c"], |
| 4236 | }, |
| 4237 | } |
| 4238 | |
| 4239 | cc_library_static { |
| 4240 | name: "libstatic", |
| 4241 | defaults: ["defaults"], |
| 4242 | } |
| 4243 | |
| 4244 | cc_library_shared { |
| 4245 | name: "libshared", |
| 4246 | defaults: ["defaults"], |
| 4247 | } |
| 4248 | |
| 4249 | cc_library { |
| 4250 | name: "libboth", |
| 4251 | defaults: ["defaults"], |
| 4252 | } |
| 4253 | |
| 4254 | cc_binary { |
| 4255 | name: "binary", |
| 4256 | defaults: ["defaults"], |
| 4257 | }`) |
| 4258 | |
| 4259 | pathsToBase := func(paths android.Paths) []string { |
| 4260 | var ret []string |
| 4261 | for _, p := range paths { |
| 4262 | ret = append(ret, p.Base()) |
| 4263 | } |
| 4264 | return ret |
| 4265 | } |
| 4266 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4267 | shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Rule("ld") |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4268 | if g, w := pathsToBase(shared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) { |
| 4269 | t.Errorf("libshared ld rule wanted %q, got %q", w, g) |
| 4270 | } |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4271 | bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_shared").Rule("ld") |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4272 | if g, w := pathsToBase(bothShared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) { |
| 4273 | t.Errorf("libboth ld rule wanted %q, got %q", w, g) |
| 4274 | } |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4275 | binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a").Rule("ld") |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4276 | if g, w := pathsToBase(binary.Inputs), []string{"foo.o"}; !reflect.DeepEqual(w, g) { |
| 4277 | t.Errorf("binary ld rule wanted %q, got %q", w, g) |
| 4278 | } |
| 4279 | |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4280 | static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_static").Rule("ar") |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4281 | if g, w := pathsToBase(static.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) { |
| 4282 | t.Errorf("libstatic ar rule wanted %q, got %q", w, g) |
| 4283 | } |
| Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4284 | bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_static").Rule("ar") |
| Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4285 | if g, w := pathsToBase(bothStatic.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) { |
| 4286 | t.Errorf("libboth ar rule wanted %q, got %q", w, g) |
| 4287 | } |
| 4288 | } |
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4289 | |
| 4290 | func TestProductVariableDefaults(t *testing.T) { |
| 4291 | bp := ` |
| 4292 | cc_defaults { |
| 4293 | name: "libfoo_defaults", |
| 4294 | srcs: ["foo.c"], |
| 4295 | cppflags: ["-DFOO"], |
| 4296 | product_variables: { |
| 4297 | debuggable: { |
| 4298 | cppflags: ["-DBAR"], |
| 4299 | }, |
| 4300 | }, |
| 4301 | } |
| 4302 | |
| 4303 | cc_library { |
| 4304 | name: "libfoo", |
| 4305 | defaults: ["libfoo_defaults"], |
| 4306 | } |
| 4307 | ` |
| 4308 | |
| 4309 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4310 | config.TestProductVariables.Debuggable = BoolPtr(true) |
| 4311 | |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4312 | ctx := CreateTestContext(config) |
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4313 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 4314 | ctx.BottomUp("variable", android.VariableMutator).Parallel() |
| 4315 | }) |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4316 | ctx.Register() |
| Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4317 | |
| 4318 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 4319 | android.FailIfErrored(t, errs) |
| 4320 | _, errs = ctx.PrepareBuildActions(config) |
| 4321 | android.FailIfErrored(t, errs) |
| 4322 | |
| 4323 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Module().(*Module) |
| 4324 | if !android.InList("-DBAR", libfoo.flags.Local.CppFlags) { |
| 4325 | t.Errorf("expected -DBAR in cppflags, got %q", libfoo.flags.Local.CppFlags) |
| 4326 | } |
| 4327 | } |
| Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4328 | |
| 4329 | func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) { |
| 4330 | t.Parallel() |
| 4331 | bp := ` |
| 4332 | cc_library_static { |
| 4333 | name: "libfoo", |
| 4334 | srcs: ["foo.c"], |
| 4335 | whole_static_libs: ["libbar"], |
| 4336 | } |
| 4337 | |
| 4338 | cc_library_static { |
| 4339 | name: "libbar", |
| 4340 | whole_static_libs: ["libmissing"], |
| 4341 | } |
| 4342 | ` |
| 4343 | |
| 4344 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4345 | config.TestProductVariables.Allow_missing_dependencies = BoolPtr(true) |
| 4346 | |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4347 | ctx := CreateTestContext(config) |
| Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4348 | ctx.SetAllowMissingDependencies(true) |
| Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4349 | ctx.Register() |
| Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4350 | |
| 4351 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 4352 | android.FailIfErrored(t, errs) |
| 4353 | _, errs = ctx.PrepareBuildActions(config) |
| 4354 | android.FailIfErrored(t, errs) |
| 4355 | |
| 4356 | libbar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_static").Output("libbar.a") |
| 4357 | if g, w := libbar.Rule, android.ErrorRule; g != w { |
| 4358 | t.Fatalf("Expected libbar rule to be %q, got %q", w, g) |
| 4359 | } |
| 4360 | |
| 4361 | if g, w := libbar.Args["error"], "missing dependencies: libmissing"; !strings.Contains(g, w) { |
| 4362 | t.Errorf("Expected libbar error to contain %q, was %q", w, g) |
| 4363 | } |
| 4364 | |
| 4365 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Output("libfoo.a") |
| 4366 | if g, w := libfoo.Inputs.Strings(), libbar.Output.String(); !android.InList(w, g) { |
| 4367 | t.Errorf("Expected libfoo.a to depend on %q, got %q", w, g) |
| 4368 | } |
| 4369 | |
| 4370 | } |
| Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 4371 | |
| 4372 | func TestInstallSharedLibs(t *testing.T) { |
| 4373 | bp := ` |
| 4374 | cc_binary { |
| 4375 | name: "bin", |
| 4376 | host_supported: true, |
| 4377 | shared_libs: ["libshared"], |
| 4378 | runtime_libs: ["libruntime"], |
| 4379 | srcs: [":gen"], |
| 4380 | } |
| 4381 | |
| 4382 | cc_library_shared { |
| 4383 | name: "libshared", |
| 4384 | host_supported: true, |
| 4385 | shared_libs: ["libtransitive"], |
| 4386 | } |
| 4387 | |
| 4388 | cc_library_shared { |
| 4389 | name: "libtransitive", |
| 4390 | host_supported: true, |
| 4391 | } |
| 4392 | |
| 4393 | cc_library_shared { |
| 4394 | name: "libruntime", |
| 4395 | host_supported: true, |
| 4396 | } |
| 4397 | |
| 4398 | cc_binary_host { |
| 4399 | name: "tool", |
| 4400 | srcs: ["foo.cpp"], |
| 4401 | } |
| 4402 | |
| 4403 | genrule { |
| 4404 | name: "gen", |
| 4405 | tools: ["tool"], |
| 4406 | out: ["gen.cpp"], |
| 4407 | cmd: "$(location tool) $(out)", |
| 4408 | } |
| 4409 | ` |
| 4410 | |
| 4411 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4412 | ctx := testCcWithConfig(t, config) |
| 4413 | |
| 4414 | hostBin := ctx.ModuleForTests("bin", config.BuildOSTarget.String()).Description("install") |
| 4415 | hostShared := ctx.ModuleForTests("libshared", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4416 | hostRuntime := ctx.ModuleForTests("libruntime", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4417 | hostTransitive := ctx.ModuleForTests("libtransitive", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4418 | hostTool := ctx.ModuleForTests("tool", config.BuildOSTarget.String()).Description("install") |
| 4419 | |
| 4420 | if g, w := hostBin.Implicits.Strings(), hostShared.Output.String(); !android.InList(w, g) { |
| 4421 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4422 | } |
| 4423 | |
| 4424 | if g, w := hostBin.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) { |
| 4425 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4426 | } |
| 4427 | |
| 4428 | if g, w := hostShared.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) { |
| 4429 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4430 | } |
| 4431 | |
| 4432 | if g, w := hostBin.Implicits.Strings(), hostRuntime.Output.String(); !android.InList(w, g) { |
| 4433 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4434 | } |
| 4435 | |
| 4436 | if g, w := hostBin.Implicits.Strings(), hostTool.Output.String(); android.InList(w, g) { |
| 4437 | t.Errorf("expected no host bin dependency %q, got %q", w, g) |
| 4438 | } |
| 4439 | |
| 4440 | deviceBin := ctx.ModuleForTests("bin", "android_arm64_armv8-a").Description("install") |
| 4441 | deviceShared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Description("install") |
| 4442 | deviceTransitive := ctx.ModuleForTests("libtransitive", "android_arm64_armv8-a_shared").Description("install") |
| 4443 | deviceRuntime := ctx.ModuleForTests("libruntime", "android_arm64_armv8-a_shared").Description("install") |
| 4444 | |
| 4445 | if g, w := deviceBin.OrderOnly.Strings(), deviceShared.Output.String(); !android.InList(w, g) { |
| 4446 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4447 | } |
| 4448 | |
| 4449 | if g, w := deviceBin.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) { |
| 4450 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4451 | } |
| 4452 | |
| 4453 | if g, w := deviceShared.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) { |
| 4454 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4455 | } |
| 4456 | |
| 4457 | if g, w := deviceBin.OrderOnly.Strings(), deviceRuntime.Output.String(); !android.InList(w, g) { |
| 4458 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4459 | } |
| 4460 | |
| 4461 | if g, w := deviceBin.OrderOnly.Strings(), hostTool.Output.String(); android.InList(w, g) { |
| 4462 | t.Errorf("expected no device bin dependency %q, got %q", w, g) |
| 4463 | } |
| 4464 | |
| 4465 | } |
| Jiyong Park | 1ad8e16 | 2020-12-01 23:40:09 +0900 | [diff] [blame] | 4466 | |
| 4467 | func TestStubsLibReexportsHeaders(t *testing.T) { |
| 4468 | ctx := testCc(t, ` |
| 4469 | cc_library_shared { |
| 4470 | name: "libclient", |
| 4471 | srcs: ["foo.c"], |
| 4472 | shared_libs: ["libfoo#1"], |
| 4473 | } |
| 4474 | |
| 4475 | cc_library_shared { |
| 4476 | name: "libfoo", |
| 4477 | srcs: ["foo.c"], |
| 4478 | shared_libs: ["libbar"], |
| 4479 | export_shared_lib_headers: ["libbar"], |
| 4480 | stubs: { |
| 4481 | symbol_file: "foo.map.txt", |
| 4482 | versions: ["1", "2", "3"], |
| 4483 | }, |
| 4484 | } |
| 4485 | |
| 4486 | cc_library_shared { |
| 4487 | name: "libbar", |
| 4488 | export_include_dirs: ["include/libbar"], |
| 4489 | srcs: ["foo.c"], |
| 4490 | }`) |
| 4491 | |
| 4492 | cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"] |
| 4493 | |
| 4494 | if !strings.Contains(cFlags, "-Iinclude/libbar") { |
| 4495 | t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags) |
| 4496 | } |
| 4497 | } |
| Jooyung Han | e197d8b | 2021-01-05 10:33:16 +0900 | [diff] [blame] | 4498 | |
| 4499 | func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) { |
| 4500 | ctx := testCc(t, ` |
| 4501 | cc_library { |
| 4502 | name: "libfoo", |
| 4503 | srcs: ["a/Foo.aidl"], |
| 4504 | aidl: { flags: ["-Werror"], }, |
| 4505 | } |
| 4506 | `) |
| 4507 | |
| 4508 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static") |
| 4509 | manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto")) |
| 4510 | aidlCommand := manifest.Commands[0].GetCommand() |
| 4511 | expectedAidlFlag := "-Werror" |
| 4512 | if !strings.Contains(aidlCommand, expectedAidlFlag) { |
| 4513 | t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) |
| 4514 | } |
| 4515 | } |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4516 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4517 | type MemtagNoteType int |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4518 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4519 | const ( |
| 4520 | None MemtagNoteType = iota + 1 |
| 4521 | Sync |
| 4522 | Async |
| 4523 | ) |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4524 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4525 | func (t MemtagNoteType) str() string { |
| 4526 | switch t { |
| 4527 | case None: |
| 4528 | return "none" |
| 4529 | case Sync: |
| 4530 | return "sync" |
| 4531 | case Async: |
| 4532 | return "async" |
| 4533 | default: |
| 4534 | panic("invalid note type") |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4535 | } |
| 4536 | } |
| 4537 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4538 | func checkHasMemtagNote(t *testing.T, m android.TestingModule, expected MemtagNoteType) { |
| 4539 | note_async := "note_memtag_heap_async" |
| 4540 | note_sync := "note_memtag_heap_sync" |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4541 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4542 | found := None |
| 4543 | implicits := m.Rule("ld").Implicits |
| 4544 | for _, lib := range implicits { |
| 4545 | if strings.Contains(lib.Rel(), note_async) { |
| 4546 | found = Async |
| 4547 | break |
| 4548 | } else if strings.Contains(lib.Rel(), note_sync) { |
| 4549 | found = Sync |
| 4550 | break |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4551 | } |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4552 | } |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4553 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4554 | if found != expected { |
| 4555 | t.Errorf("Wrong Memtag note in target %q: found %q, expected %q", m.Module().(*Module).Name(), found.str(), expected.str()) |
| 4556 | } |
| 4557 | } |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4558 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4559 | func makeMemtagTestConfig(t *testing.T) android.Config { |
| 4560 | templateBp := ` |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4561 | cc_test { |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4562 | name: "%[1]s_test", |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4563 | gtest: false, |
| 4564 | } |
| 4565 | |
| 4566 | cc_test { |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4567 | name: "%[1]s_test_false", |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4568 | gtest: false, |
| 4569 | sanitize: { memtag_heap: false }, |
| 4570 | } |
| 4571 | |
| 4572 | cc_test { |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4573 | name: "%[1]s_test_true", |
| 4574 | gtest: false, |
| 4575 | sanitize: { memtag_heap: true }, |
| 4576 | } |
| 4577 | |
| 4578 | cc_test { |
| 4579 | name: "%[1]s_test_true_nodiag", |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4580 | gtest: false, |
| 4581 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 4582 | } |
| 4583 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4584 | cc_test { |
| 4585 | name: "%[1]s_test_true_diag", |
| 4586 | gtest: false, |
| 4587 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
| 4588 | } |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4589 | |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4590 | cc_binary { |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4591 | name: "%[1]s_binary", |
| 4592 | } |
| 4593 | |
| 4594 | cc_binary { |
| 4595 | name: "%[1]s_binary_false", |
| 4596 | sanitize: { memtag_heap: false }, |
| 4597 | } |
| 4598 | |
| 4599 | cc_binary { |
| 4600 | name: "%[1]s_binary_true", |
| 4601 | sanitize: { memtag_heap: true }, |
| 4602 | } |
| 4603 | |
| 4604 | cc_binary { |
| 4605 | name: "%[1]s_binary_true_nodiag", |
| 4606 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 4607 | } |
| 4608 | |
| 4609 | cc_binary { |
| 4610 | name: "%[1]s_binary_true_diag", |
| 4611 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4612 | } |
| 4613 | ` |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4614 | subdirDefaultBp := fmt.Sprintf(templateBp, "default") |
| 4615 | subdirExcludeBp := fmt.Sprintf(templateBp, "exclude") |
| 4616 | subdirSyncBp := fmt.Sprintf(templateBp, "sync") |
| 4617 | subdirAsyncBp := fmt.Sprintf(templateBp, "async") |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4618 | |
| 4619 | mockFS := map[string][]byte{ |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4620 | "subdir_default/Android.bp": []byte(subdirDefaultBp), |
| 4621 | "subdir_exclude/Android.bp": []byte(subdirExcludeBp), |
| 4622 | "subdir_sync/Android.bp": []byte(subdirSyncBp), |
| 4623 | "subdir_async/Android.bp": []byte(subdirAsyncBp), |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4624 | } |
| 4625 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4626 | return TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 4627 | } |
| 4628 | |
| 4629 | func TestSanitizeMemtagHeap(t *testing.T) { |
| 4630 | variant := "android_arm64_armv8-a" |
| 4631 | |
| 4632 | config := makeMemtagTestConfig(t) |
| 4633 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4634 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4635 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4636 | ctx := CreateTestContext(config) |
| 4637 | ctx.Register() |
| 4638 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4639 | _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_default/Android.bp", "subdir_exclude/Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4640 | android.FailIfErrored(t, errs) |
| 4641 | _, errs = ctx.PrepareBuildActions(config) |
| 4642 | android.FailIfErrored(t, errs) |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4643 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4644 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4645 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4646 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 4647 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4648 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 4649 | |
| 4650 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), None) |
| 4651 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4652 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 4653 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4654 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4655 | |
| 4656 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4657 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4658 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 4659 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4660 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4661 | |
| 4662 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4663 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4664 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 4665 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4666 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4667 | |
| 4668 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4669 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4670 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 4671 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4672 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4673 | |
| 4674 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 4675 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4676 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 4677 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4678 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4679 | |
| 4680 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4681 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4682 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4683 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4684 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4685 | |
| 4686 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4687 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4688 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4689 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4690 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 4691 | } |
| 4692 | |
| 4693 | func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) { |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4694 | variant := "android_arm64_armv8-a" |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4695 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4696 | config := makeMemtagTestConfig(t) |
| 4697 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| 4698 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
| 4699 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
| 4700 | config.TestProductVariables.SanitizeDevice = []string{"memtag_heap"} |
| 4701 | ctx := CreateTestContext(config) |
| 4702 | ctx.Register() |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4703 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4704 | _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_default/Android.bp", "subdir_exclude/Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) |
| 4705 | android.FailIfErrored(t, errs) |
| 4706 | _, errs = ctx.PrepareBuildActions(config) |
| 4707 | android.FailIfErrored(t, errs) |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4708 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4709 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4710 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4711 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 4712 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4713 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4714 | |
| Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame] | 4715 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Async) |
| 4716 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4717 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 4718 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4719 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4720 | |
| 4721 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4722 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4723 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 4724 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4725 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4726 | |
| 4727 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4728 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4729 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 4730 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4731 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4732 | |
| 4733 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4734 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4735 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 4736 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4737 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4738 | |
| 4739 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 4740 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4741 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 4742 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4743 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4744 | |
| 4745 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4746 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4747 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4748 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4749 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4750 | |
| 4751 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4752 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4753 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4754 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4755 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 4756 | } |
| 4757 | |
| 4758 | func TestSanitizeMemtagHeapWithSanitizeDeviceDiag(t *testing.T) { |
| 4759 | variant := "android_arm64_armv8-a" |
| 4760 | |
| 4761 | config := makeMemtagTestConfig(t) |
| 4762 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| 4763 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
| 4764 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
| 4765 | config.TestProductVariables.SanitizeDevice = []string{"memtag_heap"} |
| 4766 | config.TestProductVariables.SanitizeDeviceDiag = []string{"memtag_heap"} |
| 4767 | ctx := CreateTestContext(config) |
| 4768 | ctx.Register() |
| 4769 | |
| 4770 | _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_default/Android.bp", "subdir_exclude/Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) |
| 4771 | android.FailIfErrored(t, errs) |
| 4772 | _, errs = ctx.PrepareBuildActions(config) |
| 4773 | android.FailIfErrored(t, errs) |
| 4774 | |
| 4775 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4776 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4777 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Sync) |
| 4778 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4779 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 4780 | |
| 4781 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Sync) |
| 4782 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4783 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Sync) |
| 4784 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4785 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4786 | |
| 4787 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4788 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4789 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Sync) |
| 4790 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4791 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4792 | |
| 4793 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4794 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4795 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Sync) |
| 4796 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4797 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4798 | |
| 4799 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4800 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4801 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Sync) |
| 4802 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4803 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4804 | |
| 4805 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Sync) |
| 4806 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4807 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Sync) |
| 4808 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4809 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4810 | |
| 4811 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4812 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4813 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4814 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4815 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4816 | |
| 4817 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4818 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4819 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4820 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4821 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4822 | } |