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 | |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1627 | func assertExcludeFromVendorSnapshotIs(t *testing.T, c *Module, expected bool) { |
| 1628 | t.Helper() |
| 1629 | if c.ExcludeFromVendorSnapshot() != expected { |
| 1630 | t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", c.String(), expected) |
| 1631 | } |
| 1632 | } |
| 1633 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1634 | func assertExcludeFromRecoverySnapshotIs(t *testing.T, c *Module, expected bool) { |
| 1635 | t.Helper() |
| 1636 | if c.ExcludeFromRecoverySnapshot() != expected { |
| 1637 | t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", c.String(), expected) |
| 1638 | } |
| 1639 | } |
| 1640 | |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1641 | func TestVendorSnapshotExclude(t *testing.T) { |
| 1642 | |
| 1643 | // This test verifies that the exclude_from_vendor_snapshot property |
| 1644 | // makes its way from the Android.bp source file into the module data |
| 1645 | // structure. It also verifies that modules are correctly included or |
| 1646 | // excluded in the vendor snapshot based on their path (framework or |
| 1647 | // vendor) and the exclude_from_vendor_snapshot property. |
| 1648 | |
| 1649 | frameworkBp := ` |
| 1650 | cc_library_shared { |
| 1651 | name: "libinclude", |
| 1652 | srcs: ["src/include.cpp"], |
| 1653 | vendor_available: true, |
| 1654 | } |
| 1655 | cc_library_shared { |
| 1656 | name: "libexclude", |
| 1657 | srcs: ["src/exclude.cpp"], |
| 1658 | vendor: true, |
| 1659 | exclude_from_vendor_snapshot: true, |
| 1660 | } |
| 1661 | ` |
| 1662 | |
| 1663 | vendorProprietaryBp := ` |
| 1664 | cc_library_shared { |
| 1665 | name: "libvendor", |
| 1666 | srcs: ["vendor.cpp"], |
| 1667 | vendor: true, |
| 1668 | } |
| 1669 | ` |
| 1670 | |
| 1671 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1672 | |
| 1673 | mockFS := map[string][]byte{ |
| 1674 | "deps/Android.bp": []byte(depsBp), |
| 1675 | "framework/Android.bp": []byte(frameworkBp), |
| 1676 | "framework/include.cpp": nil, |
| 1677 | "framework/exclude.cpp": nil, |
| 1678 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1679 | "device/vendor.cpp": nil, |
| 1680 | } |
| 1681 | |
| 1682 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1683 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1684 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1685 | ctx := CreateTestContext(config) |
| 1686 | ctx.Register() |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1687 | |
| 1688 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 1689 | android.FailIfErrored(t, errs) |
| 1690 | _, errs = ctx.PrepareBuildActions(config) |
| 1691 | android.FailIfErrored(t, errs) |
| 1692 | |
| 1693 | // Test an include and exclude framework module. |
| 1694 | assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false) |
| 1695 | assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", vendorVariant).Module().(*Module), false) |
| 1696 | assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libexclude", vendorVariant).Module().(*Module), true) |
| 1697 | |
| 1698 | // A vendor module is excluded, but by its path, not the |
| 1699 | // exclude_from_vendor_snapshot property. |
| 1700 | assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libvendor", vendorVariant).Module().(*Module), false) |
| 1701 | |
| 1702 | // Verify the content of the vendor snapshot. |
| 1703 | |
| 1704 | snapshotDir := "vendor-snapshot" |
| 1705 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1706 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 1707 | |
| 1708 | var includeJsonFiles []string |
| 1709 | var excludeJsonFiles []string |
| 1710 | |
| 1711 | for _, arch := range [][]string{ |
| 1712 | []string{"arm64", "armv8-a"}, |
| 1713 | []string{"arm", "armv7-a-neon"}, |
| 1714 | } { |
| 1715 | archType := arch[0] |
| 1716 | archVariant := arch[1] |
| 1717 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1718 | |
| 1719 | sharedVariant := fmt.Sprintf("android_vendor.VER_%s_%s_shared", archType, archVariant) |
| 1720 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1721 | |
| 1722 | // Included modules |
| 1723 | checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
| 1724 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 1725 | |
| 1726 | // Excluded modules |
| 1727 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
| 1728 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
| 1729 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 1730 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
| 1731 | } |
| 1732 | |
| 1733 | // Verify that each json file for an included module has a rule. |
| 1734 | for _, jsonFile := range includeJsonFiles { |
| 1735 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1736 | t.Errorf("include json file %q not found", jsonFile) |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | // Verify that each json file for an excluded module has no rule. |
| 1741 | for _, jsonFile := range excludeJsonFiles { |
| 1742 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 1743 | t.Errorf("exclude json file %q found", jsonFile) |
| 1744 | } |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) { |
| 1749 | |
| 1750 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1751 | // property on a module in a vendor proprietary path generates an |
| 1752 | // error. These modules are already excluded, so we prohibit using the |
| 1753 | // property in this way, which could add to confusion. |
| 1754 | |
| 1755 | vendorProprietaryBp := ` |
| 1756 | cc_library_shared { |
| 1757 | name: "libvendor", |
| 1758 | srcs: ["vendor.cpp"], |
| 1759 | vendor: true, |
| 1760 | exclude_from_vendor_snapshot: true, |
| 1761 | } |
| 1762 | ` |
| 1763 | |
| 1764 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1765 | |
| 1766 | mockFS := map[string][]byte{ |
| 1767 | "deps/Android.bp": []byte(depsBp), |
| 1768 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 1769 | "device/vendor.cpp": nil, |
| 1770 | } |
| 1771 | |
| 1772 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1773 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1774 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1775 | ctx := CreateTestContext(config) |
| 1776 | ctx.Register() |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1777 | |
| 1778 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "device/Android.bp"}) |
| 1779 | android.FailIfErrored(t, errs) |
| 1780 | |
| 1781 | _, errs = ctx.PrepareBuildActions(config) |
| 1782 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1783 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1784 | `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] | 1785 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1786 | `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] | 1787 | `module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`, |
| 1788 | `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] | 1789 | }) |
| 1790 | } |
| 1791 | |
| 1792 | func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) { |
| 1793 | |
| 1794 | // This test verifies that using the exclude_from_vendor_snapshot |
| 1795 | // property on a module that is vendor available generates an error. A |
| 1796 | // vendor available module must be captured in the vendor snapshot and |
| 1797 | // must not built from source when building the vendor image against |
| 1798 | // the vendor snapshot. |
| 1799 | |
| 1800 | frameworkBp := ` |
| 1801 | cc_library_shared { |
| 1802 | name: "libinclude", |
| 1803 | srcs: ["src/include.cpp"], |
| 1804 | vendor_available: true, |
| 1805 | exclude_from_vendor_snapshot: true, |
| 1806 | } |
| 1807 | ` |
| 1808 | |
| 1809 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1810 | |
| 1811 | mockFS := map[string][]byte{ |
| 1812 | "deps/Android.bp": []byte(depsBp), |
| 1813 | "framework/Android.bp": []byte(frameworkBp), |
| 1814 | "framework/include.cpp": nil, |
| 1815 | } |
| 1816 | |
| 1817 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 1818 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 1819 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 1820 | ctx := CreateTestContext(config) |
| 1821 | ctx.Register() |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1822 | |
| 1823 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp"}) |
| 1824 | android.FailIfErrored(t, errs) |
| 1825 | |
| 1826 | _, errs = ctx.PrepareBuildActions(config) |
| 1827 | android.CheckErrorsAgainstExpectations(t, errs, []string{ |
| 1828 | `module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1829 | `module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1830 | `module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1831 | `module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
Inseob Kim | e9aec6a | 2021-01-05 20:03:22 +0900 | [diff] [blame] | 1832 | `module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1833 | `module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1834 | `module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
| 1835 | `module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`, |
Bill Peckham | 945441c | 2020-08-31 16:07:58 -0700 | [diff] [blame] | 1836 | }) |
| 1837 | } |
| 1838 | |
Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 1839 | func TestRecoverySnapshotCapture(t *testing.T) { |
| 1840 | bp := ` |
| 1841 | cc_library { |
| 1842 | name: "libvndk", |
| 1843 | vendor_available: true, |
| 1844 | recovery_available: true, |
| 1845 | product_available: true, |
| 1846 | vndk: { |
| 1847 | enabled: true, |
| 1848 | }, |
| 1849 | nocrt: true, |
| 1850 | } |
| 1851 | |
| 1852 | cc_library { |
| 1853 | name: "librecovery", |
| 1854 | recovery: true, |
| 1855 | nocrt: true, |
| 1856 | } |
| 1857 | |
| 1858 | cc_library { |
| 1859 | name: "librecovery_available", |
| 1860 | recovery_available: true, |
| 1861 | nocrt: true, |
| 1862 | } |
| 1863 | |
| 1864 | cc_library_headers { |
| 1865 | name: "librecovery_headers", |
| 1866 | recovery_available: true, |
| 1867 | nocrt: true, |
| 1868 | } |
| 1869 | |
| 1870 | cc_binary { |
| 1871 | name: "recovery_bin", |
| 1872 | recovery: true, |
| 1873 | nocrt: true, |
| 1874 | } |
| 1875 | |
| 1876 | cc_binary { |
| 1877 | name: "recovery_available_bin", |
| 1878 | recovery_available: true, |
| 1879 | nocrt: true, |
| 1880 | } |
| 1881 | |
| 1882 | toolchain_library { |
| 1883 | name: "libb", |
| 1884 | recovery_available: true, |
| 1885 | src: "libb.a", |
| 1886 | } |
| 1887 | |
| 1888 | cc_object { |
| 1889 | name: "obj", |
| 1890 | recovery_available: true, |
| 1891 | } |
| 1892 | ` |
| 1893 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1894 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
Jose Galmes | f729458 | 2020-11-13 12:07:36 -0800 | [diff] [blame] | 1895 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 1896 | ctx := testCcWithConfig(t, config) |
| 1897 | |
| 1898 | // Check Recovery snapshot output. |
| 1899 | |
| 1900 | snapshotDir := "recovery-snapshot" |
| 1901 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 1902 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 1903 | |
| 1904 | var jsonFiles []string |
| 1905 | |
| 1906 | for _, arch := range [][]string{ |
| 1907 | []string{"arm64", "armv8-a"}, |
| 1908 | } { |
| 1909 | archType := arch[0] |
| 1910 | archVariant := arch[1] |
| 1911 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 1912 | |
| 1913 | // For shared libraries, only recovery_available modules are captured. |
| 1914 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 1915 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 1916 | checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", sharedDir, sharedVariant) |
| 1917 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant) |
| 1918 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.so", sharedDir, sharedVariant) |
| 1919 | jsonFiles = append(jsonFiles, |
| 1920 | filepath.Join(sharedDir, "libvndk.so.json"), |
| 1921 | filepath.Join(sharedDir, "librecovery.so.json"), |
| 1922 | filepath.Join(sharedDir, "librecovery_available.so.json")) |
| 1923 | |
| 1924 | // For static libraries, all recovery:true and recovery_available modules are captured. |
| 1925 | staticVariant := fmt.Sprintf("android_recovery_%s_%s_static", archType, archVariant) |
| 1926 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
| 1927 | checkSnapshot(t, ctx, snapshotSingleton, "libb", "libb.a", staticDir, staticVariant) |
| 1928 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery", "librecovery.a", staticDir, staticVariant) |
| 1929 | checkSnapshot(t, ctx, snapshotSingleton, "librecovery_available", "librecovery_available.a", staticDir, staticVariant) |
| 1930 | jsonFiles = append(jsonFiles, |
| 1931 | filepath.Join(staticDir, "libb.a.json"), |
| 1932 | filepath.Join(staticDir, "librecovery.a.json"), |
| 1933 | filepath.Join(staticDir, "librecovery_available.a.json")) |
| 1934 | |
| 1935 | // For binary executables, all recovery:true and recovery_available modules are captured. |
| 1936 | if archType == "arm64" { |
| 1937 | binaryVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1938 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
| 1939 | checkSnapshot(t, ctx, snapshotSingleton, "recovery_bin", "recovery_bin", binaryDir, binaryVariant) |
| 1940 | checkSnapshot(t, ctx, snapshotSingleton, "recovery_available_bin", "recovery_available_bin", binaryDir, binaryVariant) |
| 1941 | jsonFiles = append(jsonFiles, |
| 1942 | filepath.Join(binaryDir, "recovery_bin.json"), |
| 1943 | filepath.Join(binaryDir, "recovery_available_bin.json")) |
| 1944 | } |
| 1945 | |
| 1946 | // For header libraries, all vendor:true and vendor_available modules are captured. |
| 1947 | headerDir := filepath.Join(snapshotVariantPath, archDir, "header") |
| 1948 | jsonFiles = append(jsonFiles, filepath.Join(headerDir, "librecovery_headers.json")) |
| 1949 | |
| 1950 | // For object modules, all vendor:true and vendor_available modules are captured. |
| 1951 | objectVariant := fmt.Sprintf("android_recovery_%s_%s", archType, archVariant) |
| 1952 | objectDir := filepath.Join(snapshotVariantPath, archDir, "object") |
| 1953 | checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant) |
| 1954 | jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json")) |
| 1955 | } |
| 1956 | |
| 1957 | for _, jsonFile := range jsonFiles { |
| 1958 | // verify all json files exist |
| 1959 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 1960 | t.Errorf("%q expected but not found", jsonFile) |
| 1961 | } |
| 1962 | } |
| 1963 | } |
| 1964 | |
Jose Galmes | 6f843bc | 2020-12-11 13:36:29 -0800 | [diff] [blame] | 1965 | func TestRecoverySnapshotExclude(t *testing.T) { |
| 1966 | // This test verifies that the exclude_from_recovery_snapshot property |
| 1967 | // makes its way from the Android.bp source file into the module data |
| 1968 | // structure. It also verifies that modules are correctly included or |
| 1969 | // excluded in the recovery snapshot based on their path (framework or |
| 1970 | // vendor) and the exclude_from_recovery_snapshot property. |
| 1971 | |
| 1972 | frameworkBp := ` |
| 1973 | cc_library_shared { |
| 1974 | name: "libinclude", |
| 1975 | srcs: ["src/include.cpp"], |
| 1976 | recovery_available: true, |
| 1977 | } |
| 1978 | cc_library_shared { |
| 1979 | name: "libexclude", |
| 1980 | srcs: ["src/exclude.cpp"], |
| 1981 | recovery: true, |
| 1982 | exclude_from_recovery_snapshot: true, |
| 1983 | } |
| 1984 | ` |
| 1985 | |
| 1986 | vendorProprietaryBp := ` |
| 1987 | cc_library_shared { |
| 1988 | name: "libvendor", |
| 1989 | srcs: ["vendor.cpp"], |
| 1990 | recovery: true, |
| 1991 | } |
| 1992 | ` |
| 1993 | |
| 1994 | depsBp := GatherRequiredDepsForTest(android.Android) |
| 1995 | |
| 1996 | mockFS := map[string][]byte{ |
| 1997 | "deps/Android.bp": []byte(depsBp), |
| 1998 | "framework/Android.bp": []byte(frameworkBp), |
| 1999 | "framework/include.cpp": nil, |
| 2000 | "framework/exclude.cpp": nil, |
| 2001 | "device/Android.bp": []byte(vendorProprietaryBp), |
| 2002 | "device/vendor.cpp": nil, |
| 2003 | } |
| 2004 | |
| 2005 | config := TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 2006 | config.TestProductVariables.RecoverySnapshotVersion = StringPtr("current") |
| 2007 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 2008 | ctx := CreateTestContext(config) |
| 2009 | ctx.Register() |
| 2010 | |
| 2011 | _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp", "device/Android.bp"}) |
| 2012 | android.FailIfErrored(t, errs) |
| 2013 | _, errs = ctx.PrepareBuildActions(config) |
| 2014 | android.FailIfErrored(t, errs) |
| 2015 | |
| 2016 | // Test an include and exclude framework module. |
| 2017 | assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false) |
| 2018 | assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", recoveryVariant).Module().(*Module), false) |
| 2019 | assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libexclude", recoveryVariant).Module().(*Module), true) |
| 2020 | |
| 2021 | // A vendor module is excluded, but by its path, not the |
| 2022 | // exclude_from_recovery_snapshot property. |
| 2023 | assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libvendor", recoveryVariant).Module().(*Module), false) |
| 2024 | |
| 2025 | // Verify the content of the recovery snapshot. |
| 2026 | |
| 2027 | snapshotDir := "recovery-snapshot" |
| 2028 | snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64") |
| 2029 | snapshotSingleton := ctx.SingletonForTests("recovery-snapshot") |
| 2030 | |
| 2031 | var includeJsonFiles []string |
| 2032 | var excludeJsonFiles []string |
| 2033 | |
| 2034 | for _, arch := range [][]string{ |
| 2035 | []string{"arm64", "armv8-a"}, |
| 2036 | } { |
| 2037 | archType := arch[0] |
| 2038 | archVariant := arch[1] |
| 2039 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 2040 | |
| 2041 | sharedVariant := fmt.Sprintf("android_recovery_%s_%s_shared", archType, archVariant) |
| 2042 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
| 2043 | |
| 2044 | // Included modules |
| 2045 | checkSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
| 2046 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
| 2047 | |
| 2048 | // Excluded modules |
| 2049 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
| 2050 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
| 2051 | checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant) |
| 2052 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json")) |
| 2053 | } |
| 2054 | |
| 2055 | // Verify that each json file for an included module has a rule. |
| 2056 | for _, jsonFile := range includeJsonFiles { |
| 2057 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 2058 | t.Errorf("include json file %q not found", jsonFile) |
| 2059 | } |
| 2060 | } |
| 2061 | |
| 2062 | // Verify that each json file for an excluded module has no rule. |
| 2063 | for _, jsonFile := range excludeJsonFiles { |
| 2064 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 2065 | t.Errorf("exclude json file %q found", jsonFile) |
| 2066 | } |
| 2067 | } |
| 2068 | } |
| 2069 | |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2070 | func TestDoubleLoadableDepError(t *testing.T) { |
| 2071 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib. |
| 2072 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2073 | cc_library { |
| 2074 | name: "libllndk", |
| 2075 | shared_libs: ["libnondoubleloadable"], |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2076 | llndk_stubs: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2077 | } |
| 2078 | |
| 2079 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2080 | name: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2081 | symbol_file: "", |
| 2082 | } |
| 2083 | |
| 2084 | cc_library { |
| 2085 | name: "libnondoubleloadable", |
| 2086 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2087 | product_available: true, |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2088 | vndk: { |
| 2089 | enabled: true, |
| 2090 | }, |
| 2091 | } |
| 2092 | `) |
| 2093 | |
| 2094 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable vendor_available lib. |
| 2095 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2096 | cc_library { |
| 2097 | name: "libllndk", |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 2098 | no_libcrt: true, |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2099 | shared_libs: ["libnondoubleloadable"], |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2100 | llndk_stubs: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2101 | } |
| 2102 | |
| 2103 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2104 | name: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2105 | symbol_file: "", |
| 2106 | } |
| 2107 | |
| 2108 | cc_library { |
| 2109 | name: "libnondoubleloadable", |
| 2110 | vendor_available: true, |
| 2111 | } |
| 2112 | `) |
| 2113 | |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2114 | // Check whether an error is emitted when a LLNDK depends on a non-double_loadable indirectly. |
| 2115 | testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", ` |
| 2116 | cc_library { |
| 2117 | name: "libllndk", |
| 2118 | shared_libs: ["libcoreonly"], |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2119 | llndk_stubs: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2120 | } |
| 2121 | |
| 2122 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2123 | name: "libllndk.llndk", |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2124 | symbol_file: "", |
| 2125 | } |
| 2126 | |
| 2127 | cc_library { |
| 2128 | name: "libcoreonly", |
| 2129 | shared_libs: ["libvendoravailable"], |
| 2130 | } |
| 2131 | |
| 2132 | // indirect dependency of LLNDK |
| 2133 | cc_library { |
| 2134 | name: "libvendoravailable", |
| 2135 | vendor_available: true, |
| 2136 | } |
| 2137 | `) |
Jiyong Park | 0474e1f | 2021-01-14 14:26:06 +0900 | [diff] [blame] | 2138 | |
| 2139 | // The error is not from 'client' but from 'libllndk' |
| 2140 | testCcError(t, "module \"libllndk\".* links a library \"libnondoubleloadable\".*double_loadable", ` |
| 2141 | cc_library { |
| 2142 | name: "client", |
| 2143 | vendor_available: true, |
| 2144 | double_loadable: true, |
| 2145 | shared_libs: ["libllndk"], |
| 2146 | } |
| 2147 | cc_library { |
| 2148 | name: "libllndk", |
| 2149 | shared_libs: ["libnondoubleloadable"], |
| 2150 | llndk_stubs: "libllndk.llndk", |
| 2151 | } |
| 2152 | llndk_library { |
| 2153 | name: "libllndk.llndk", |
| 2154 | symbol_file: "", |
| 2155 | } |
| 2156 | cc_library { |
| 2157 | name: "libnondoubleloadable", |
| 2158 | vendor_available: true, |
| 2159 | } |
| 2160 | `) |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2161 | } |
| 2162 | |
Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 2163 | func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) { |
| 2164 | testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", ` |
| 2165 | cc_library { |
| 2166 | name: "libvndksp", |
| 2167 | shared_libs: ["libanothervndksp"], |
| 2168 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2169 | product_available: true, |
Jooyung Han | 479ca17 | 2020-10-19 18:51:07 +0900 | [diff] [blame] | 2170 | vndk: { |
| 2171 | enabled: true, |
| 2172 | support_system_process: true, |
| 2173 | } |
| 2174 | } |
| 2175 | |
| 2176 | cc_library { |
| 2177 | name: "libllndk", |
| 2178 | shared_libs: ["libanothervndksp"], |
| 2179 | } |
| 2180 | |
| 2181 | llndk_library { |
| 2182 | name: "libllndk", |
| 2183 | symbol_file: "", |
| 2184 | } |
| 2185 | |
| 2186 | cc_library { |
| 2187 | name: "libanothervndksp", |
| 2188 | vendor_available: true, |
| 2189 | } |
| 2190 | `) |
| 2191 | } |
| 2192 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2193 | func TestVndkExt(t *testing.T) { |
| 2194 | // This test checks the VNDK-Ext properties. |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2195 | bp := ` |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2196 | cc_library { |
| 2197 | name: "libvndk", |
| 2198 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2199 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2200 | vndk: { |
| 2201 | enabled: true, |
| 2202 | }, |
| 2203 | nocrt: true, |
| 2204 | } |
Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2205 | cc_library { |
| 2206 | name: "libvndk2", |
| 2207 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2208 | product_available: true, |
Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2209 | vndk: { |
| 2210 | enabled: true, |
| 2211 | }, |
| 2212 | target: { |
| 2213 | vendor: { |
| 2214 | suffix: "-suffix", |
| 2215 | }, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2216 | product: { |
| 2217 | suffix: "-suffix", |
| 2218 | }, |
Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2219 | }, |
| 2220 | nocrt: true, |
| 2221 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2222 | |
| 2223 | cc_library { |
| 2224 | name: "libvndk_ext", |
| 2225 | vendor: true, |
| 2226 | vndk: { |
| 2227 | enabled: true, |
| 2228 | extends: "libvndk", |
| 2229 | }, |
| 2230 | nocrt: true, |
| 2231 | } |
Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2232 | |
| 2233 | cc_library { |
| 2234 | name: "libvndk2_ext", |
| 2235 | vendor: true, |
| 2236 | vndk: { |
| 2237 | enabled: true, |
| 2238 | extends: "libvndk2", |
| 2239 | }, |
| 2240 | nocrt: true, |
| 2241 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2242 | |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2243 | cc_library { |
| 2244 | name: "libvndk_ext_product", |
| 2245 | product_specific: true, |
| 2246 | vndk: { |
| 2247 | enabled: true, |
| 2248 | extends: "libvndk", |
| 2249 | }, |
| 2250 | nocrt: true, |
| 2251 | } |
Jooyung Han | 4c2b942 | 2019-10-22 19:53:47 +0900 | [diff] [blame] | 2252 | |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2253 | cc_library { |
| 2254 | name: "libvndk2_ext_product", |
| 2255 | product_specific: true, |
| 2256 | vndk: { |
| 2257 | enabled: true, |
| 2258 | extends: "libvndk2", |
| 2259 | }, |
| 2260 | nocrt: true, |
| 2261 | } |
| 2262 | ` |
| 2263 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 2264 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 2265 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 2266 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 2267 | |
| 2268 | ctx := testCcWithConfig(t, config) |
| 2269 | |
| 2270 | checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk", vendorVariant) |
| 2271 | checkVndkModule(t, ctx, "libvndk_ext_product", "vndk", false, "libvndk", productVariant) |
| 2272 | |
| 2273 | mod_vendor := ctx.ModuleForTests("libvndk2_ext", vendorVariant).Module().(*Module) |
| 2274 | assertString(t, mod_vendor.outputFile.Path().Base(), "libvndk2-suffix.so") |
| 2275 | |
| 2276 | mod_product := ctx.ModuleForTests("libvndk2_ext_product", productVariant).Module().(*Module) |
| 2277 | assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so") |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2278 | } |
| 2279 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2280 | func TestVndkExtWithoutBoardVndkVersion(t *testing.T) { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2281 | // This test checks the VNDK-Ext properties when BOARD_VNDK_VERSION is not set. |
| 2282 | ctx := testCcNoVndk(t, ` |
| 2283 | cc_library { |
| 2284 | name: "libvndk", |
| 2285 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2286 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2287 | vndk: { |
| 2288 | enabled: true, |
| 2289 | }, |
| 2290 | nocrt: true, |
| 2291 | } |
| 2292 | |
| 2293 | cc_library { |
| 2294 | name: "libvndk_ext", |
| 2295 | vendor: true, |
| 2296 | vndk: { |
| 2297 | enabled: true, |
| 2298 | extends: "libvndk", |
| 2299 | }, |
| 2300 | nocrt: true, |
| 2301 | } |
| 2302 | `) |
| 2303 | |
| 2304 | // Ensures that the core variant of "libvndk_ext" can be found. |
| 2305 | mod := ctx.ModuleForTests("libvndk_ext", coreVariant).Module().(*Module) |
| 2306 | if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" { |
| 2307 | t.Errorf("\"libvndk_ext\" must extend from \"libvndk\" but get %q", extends) |
| 2308 | } |
| 2309 | } |
| 2310 | |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2311 | func TestVndkExtWithoutProductVndkVersion(t *testing.T) { |
| 2312 | // 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] | 2313 | ctx := testCcNoProductVndk(t, ` |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2314 | cc_library { |
| 2315 | name: "libvndk", |
| 2316 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2317 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2318 | vndk: { |
| 2319 | enabled: true, |
| 2320 | }, |
| 2321 | nocrt: true, |
| 2322 | } |
| 2323 | |
| 2324 | cc_library { |
| 2325 | name: "libvndk_ext_product", |
| 2326 | product_specific: true, |
| 2327 | vndk: { |
| 2328 | enabled: true, |
| 2329 | extends: "libvndk", |
| 2330 | }, |
| 2331 | nocrt: true, |
| 2332 | } |
| 2333 | `) |
| 2334 | |
| 2335 | // Ensures that the core variant of "libvndk_ext_product" can be found. |
| 2336 | mod := ctx.ModuleForTests("libvndk_ext_product", coreVariant).Module().(*Module) |
| 2337 | if extends := mod.getVndkExtendsModuleName(); extends != "libvndk" { |
| 2338 | t.Errorf("\"libvndk_ext_product\" must extend from \"libvndk\" but get %q", extends) |
| 2339 | } |
| 2340 | } |
| 2341 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2342 | func TestVndkExtError(t *testing.T) { |
| 2343 | // 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] | 2344 | 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] | 2345 | cc_library { |
| 2346 | name: "libvndk", |
| 2347 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2348 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2349 | vndk: { |
| 2350 | enabled: true, |
| 2351 | }, |
| 2352 | nocrt: true, |
| 2353 | } |
| 2354 | |
| 2355 | cc_library { |
| 2356 | name: "libvndk_ext", |
| 2357 | vndk: { |
| 2358 | enabled: true, |
| 2359 | extends: "libvndk", |
| 2360 | }, |
| 2361 | nocrt: true, |
| 2362 | } |
| 2363 | `) |
| 2364 | |
| 2365 | testCcError(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` |
| 2366 | cc_library { |
| 2367 | name: "libvndk", |
| 2368 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2369 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2370 | vndk: { |
| 2371 | enabled: true, |
| 2372 | }, |
| 2373 | nocrt: true, |
| 2374 | } |
| 2375 | |
| 2376 | cc_library { |
| 2377 | name: "libvndk_ext", |
| 2378 | vendor: true, |
| 2379 | vndk: { |
| 2380 | enabled: true, |
| 2381 | }, |
| 2382 | nocrt: true, |
| 2383 | } |
| 2384 | `) |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2385 | |
| 2386 | testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", ` |
| 2387 | cc_library { |
| 2388 | name: "libvndk", |
| 2389 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2390 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2391 | vndk: { |
| 2392 | enabled: true, |
| 2393 | }, |
| 2394 | nocrt: true, |
| 2395 | } |
| 2396 | |
| 2397 | cc_library { |
| 2398 | name: "libvndk_ext_product", |
| 2399 | product_specific: true, |
| 2400 | vndk: { |
| 2401 | enabled: true, |
| 2402 | }, |
| 2403 | nocrt: true, |
| 2404 | } |
| 2405 | `) |
| 2406 | |
| 2407 | testCcErrorProductVndk(t, "must not set at the same time as `vndk: {extends: \"\\.\\.\\.\"}`", ` |
| 2408 | cc_library { |
| 2409 | name: "libvndk", |
| 2410 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2411 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2412 | vndk: { |
| 2413 | enabled: true, |
| 2414 | }, |
| 2415 | nocrt: true, |
| 2416 | } |
| 2417 | |
| 2418 | cc_library { |
| 2419 | name: "libvndk_ext_product", |
| 2420 | product_specific: true, |
| 2421 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2422 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2423 | vndk: { |
| 2424 | enabled: true, |
| 2425 | extends: "libvndk", |
| 2426 | }, |
| 2427 | nocrt: true, |
| 2428 | } |
| 2429 | `) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2430 | } |
| 2431 | |
| 2432 | func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) { |
| 2433 | // This test ensures an error is emitted for inconsistent support_system_process. |
| 2434 | testCcError(t, "module \".*\" with mismatched support_system_process", ` |
| 2435 | cc_library { |
| 2436 | name: "libvndk", |
| 2437 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2438 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2439 | vndk: { |
| 2440 | enabled: true, |
| 2441 | }, |
| 2442 | nocrt: true, |
| 2443 | } |
| 2444 | |
| 2445 | cc_library { |
| 2446 | name: "libvndk_sp_ext", |
| 2447 | vendor: true, |
| 2448 | vndk: { |
| 2449 | enabled: true, |
| 2450 | extends: "libvndk", |
| 2451 | support_system_process: true, |
| 2452 | }, |
| 2453 | nocrt: true, |
| 2454 | } |
| 2455 | `) |
| 2456 | |
| 2457 | testCcError(t, "module \".*\" with mismatched support_system_process", ` |
| 2458 | cc_library { |
| 2459 | name: "libvndk_sp", |
| 2460 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2461 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2462 | vndk: { |
| 2463 | enabled: true, |
| 2464 | support_system_process: true, |
| 2465 | }, |
| 2466 | nocrt: true, |
| 2467 | } |
| 2468 | |
| 2469 | cc_library { |
| 2470 | name: "libvndk_ext", |
| 2471 | vendor: true, |
| 2472 | vndk: { |
| 2473 | enabled: true, |
| 2474 | extends: "libvndk_sp", |
| 2475 | }, |
| 2476 | nocrt: true, |
| 2477 | } |
| 2478 | `) |
| 2479 | } |
| 2480 | |
| 2481 | func TestVndkExtVendorAvailableFalseError(t *testing.T) { |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2482 | // 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] | 2483 | // with `private: true`. |
| 2484 | testCcError(t, "`extends` refers module \".*\" which has `private: true`", ` |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2485 | cc_library { |
| 2486 | name: "libvndk", |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2487 | vendor_available: true, |
| 2488 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2489 | vndk: { |
| 2490 | enabled: true, |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2491 | private: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2492 | }, |
| 2493 | nocrt: true, |
| 2494 | } |
| 2495 | |
| 2496 | cc_library { |
| 2497 | name: "libvndk_ext", |
| 2498 | vendor: true, |
| 2499 | vndk: { |
| 2500 | enabled: true, |
| 2501 | extends: "libvndk", |
| 2502 | }, |
| 2503 | nocrt: true, |
| 2504 | } |
| 2505 | `) |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2506 | |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2507 | testCcErrorProductVndk(t, "`extends` refers module \".*\" which has `private: true`", ` |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2508 | cc_library { |
| 2509 | name: "libvndk", |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2510 | vendor_available: true, |
| 2511 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2512 | vndk: { |
| 2513 | enabled: true, |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 2514 | private: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2515 | }, |
| 2516 | nocrt: true, |
| 2517 | } |
| 2518 | |
| 2519 | cc_library { |
| 2520 | name: "libvndk_ext_product", |
| 2521 | product_specific: true, |
| 2522 | vndk: { |
| 2523 | enabled: true, |
| 2524 | extends: "libvndk", |
| 2525 | }, |
| 2526 | nocrt: true, |
| 2527 | } |
| 2528 | `) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2529 | } |
| 2530 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2531 | func TestVendorModuleUseVndkExt(t *testing.T) { |
| 2532 | // 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] | 2533 | testCc(t, ` |
| 2534 | cc_library { |
| 2535 | name: "libvndk", |
| 2536 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2537 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2538 | vndk: { |
| 2539 | enabled: true, |
| 2540 | }, |
| 2541 | nocrt: true, |
| 2542 | } |
| 2543 | |
| 2544 | cc_library { |
| 2545 | name: "libvndk_ext", |
| 2546 | vendor: true, |
| 2547 | vndk: { |
| 2548 | enabled: true, |
| 2549 | extends: "libvndk", |
| 2550 | }, |
| 2551 | nocrt: true, |
| 2552 | } |
| 2553 | |
| 2554 | cc_library { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2555 | name: "libvndk_sp", |
| 2556 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2557 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2558 | vndk: { |
| 2559 | enabled: true, |
| 2560 | support_system_process: true, |
| 2561 | }, |
| 2562 | nocrt: true, |
| 2563 | } |
| 2564 | |
| 2565 | cc_library { |
| 2566 | name: "libvndk_sp_ext", |
| 2567 | vendor: true, |
| 2568 | vndk: { |
| 2569 | enabled: true, |
| 2570 | extends: "libvndk_sp", |
| 2571 | support_system_process: true, |
| 2572 | }, |
| 2573 | nocrt: true, |
| 2574 | } |
| 2575 | |
| 2576 | cc_library { |
| 2577 | name: "libvendor", |
| 2578 | vendor: true, |
| 2579 | shared_libs: ["libvndk_ext", "libvndk_sp_ext"], |
| 2580 | nocrt: true, |
| 2581 | } |
| 2582 | `) |
| 2583 | } |
| 2584 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2585 | func TestVndkExtUseVendorLib(t *testing.T) { |
| 2586 | // 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] | 2587 | testCc(t, ` |
| 2588 | cc_library { |
| 2589 | name: "libvndk", |
| 2590 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2591 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2592 | vndk: { |
| 2593 | enabled: true, |
| 2594 | }, |
| 2595 | nocrt: true, |
| 2596 | } |
| 2597 | |
| 2598 | cc_library { |
| 2599 | name: "libvndk_ext", |
| 2600 | vendor: true, |
| 2601 | vndk: { |
| 2602 | enabled: true, |
| 2603 | extends: "libvndk", |
| 2604 | }, |
| 2605 | shared_libs: ["libvendor"], |
| 2606 | nocrt: true, |
| 2607 | } |
| 2608 | |
| 2609 | cc_library { |
| 2610 | name: "libvendor", |
| 2611 | vendor: true, |
| 2612 | nocrt: true, |
| 2613 | } |
| 2614 | `) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2615 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2616 | // This test ensures a VNDK-SP-Ext library can depend on a vendor library. |
| 2617 | testCc(t, ` |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2618 | cc_library { |
| 2619 | name: "libvndk_sp", |
| 2620 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2621 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2622 | vndk: { |
| 2623 | enabled: true, |
| 2624 | support_system_process: true, |
| 2625 | }, |
| 2626 | nocrt: true, |
| 2627 | } |
| 2628 | |
| 2629 | cc_library { |
| 2630 | name: "libvndk_sp_ext", |
| 2631 | vendor: true, |
| 2632 | vndk: { |
| 2633 | enabled: true, |
| 2634 | extends: "libvndk_sp", |
| 2635 | support_system_process: true, |
| 2636 | }, |
| 2637 | shared_libs: ["libvendor"], // Cause an error |
| 2638 | nocrt: true, |
| 2639 | } |
| 2640 | |
| 2641 | cc_library { |
| 2642 | name: "libvendor", |
| 2643 | vendor: true, |
| 2644 | nocrt: true, |
| 2645 | } |
| 2646 | `) |
| 2647 | } |
| 2648 | |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2649 | func TestProductVndkExtDependency(t *testing.T) { |
| 2650 | bp := ` |
| 2651 | cc_library { |
| 2652 | name: "libvndk", |
| 2653 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2654 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2655 | vndk: { |
| 2656 | enabled: true, |
| 2657 | }, |
| 2658 | nocrt: true, |
| 2659 | } |
| 2660 | |
| 2661 | cc_library { |
| 2662 | name: "libvndk_ext_product", |
| 2663 | product_specific: true, |
| 2664 | vndk: { |
| 2665 | enabled: true, |
| 2666 | extends: "libvndk", |
| 2667 | }, |
| 2668 | shared_libs: ["libproduct_for_vndklibs"], |
| 2669 | nocrt: true, |
| 2670 | } |
| 2671 | |
| 2672 | cc_library { |
| 2673 | name: "libvndk_sp", |
| 2674 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2675 | product_available: true, |
Justin Yun | 0ecf0b2 | 2020-02-28 15:07:59 +0900 | [diff] [blame] | 2676 | vndk: { |
| 2677 | enabled: true, |
| 2678 | support_system_process: true, |
| 2679 | }, |
| 2680 | nocrt: true, |
| 2681 | } |
| 2682 | |
| 2683 | cc_library { |
| 2684 | name: "libvndk_sp_ext_product", |
| 2685 | product_specific: true, |
| 2686 | vndk: { |
| 2687 | enabled: true, |
| 2688 | extends: "libvndk_sp", |
| 2689 | support_system_process: true, |
| 2690 | }, |
| 2691 | shared_libs: ["libproduct_for_vndklibs"], |
| 2692 | nocrt: true, |
| 2693 | } |
| 2694 | |
| 2695 | cc_library { |
| 2696 | name: "libproduct", |
| 2697 | product_specific: true, |
| 2698 | shared_libs: ["libvndk_ext_product", "libvndk_sp_ext_product"], |
| 2699 | nocrt: true, |
| 2700 | } |
| 2701 | |
| 2702 | cc_library { |
| 2703 | name: "libproduct_for_vndklibs", |
| 2704 | product_specific: true, |
| 2705 | nocrt: true, |
| 2706 | } |
| 2707 | ` |
| 2708 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 2709 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 2710 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 2711 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 2712 | |
| 2713 | testCcWithConfig(t, config) |
| 2714 | } |
| 2715 | |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2716 | func TestVndkSpExtUseVndkError(t *testing.T) { |
| 2717 | // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK |
| 2718 | // library. |
| 2719 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 2720 | cc_library { |
| 2721 | name: "libvndk", |
| 2722 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2723 | product_available: true, |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2724 | vndk: { |
| 2725 | enabled: true, |
| 2726 | }, |
| 2727 | nocrt: true, |
| 2728 | } |
| 2729 | |
| 2730 | cc_library { |
| 2731 | name: "libvndk_sp", |
| 2732 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2733 | product_available: true, |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2734 | vndk: { |
| 2735 | enabled: true, |
| 2736 | support_system_process: true, |
| 2737 | }, |
| 2738 | nocrt: true, |
| 2739 | } |
| 2740 | |
| 2741 | cc_library { |
| 2742 | name: "libvndk_sp_ext", |
| 2743 | vendor: true, |
| 2744 | vndk: { |
| 2745 | enabled: true, |
| 2746 | extends: "libvndk_sp", |
| 2747 | support_system_process: true, |
| 2748 | }, |
| 2749 | shared_libs: ["libvndk"], // Cause an error |
| 2750 | nocrt: true, |
| 2751 | } |
| 2752 | `) |
| 2753 | |
| 2754 | // This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK-Ext |
| 2755 | // library. |
| 2756 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
| 2757 | cc_library { |
| 2758 | name: "libvndk", |
| 2759 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2760 | product_available: true, |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2761 | vndk: { |
| 2762 | enabled: true, |
| 2763 | }, |
| 2764 | nocrt: true, |
| 2765 | } |
| 2766 | |
| 2767 | cc_library { |
| 2768 | name: "libvndk_ext", |
| 2769 | vendor: true, |
| 2770 | vndk: { |
| 2771 | enabled: true, |
| 2772 | extends: "libvndk", |
| 2773 | }, |
| 2774 | nocrt: true, |
| 2775 | } |
| 2776 | |
| 2777 | cc_library { |
| 2778 | name: "libvndk_sp", |
| 2779 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2780 | product_available: true, |
Logan Chien | d3c59a2 | 2018-03-29 14:08:15 +0800 | [diff] [blame] | 2781 | vndk: { |
| 2782 | enabled: true, |
| 2783 | support_system_process: true, |
| 2784 | }, |
| 2785 | nocrt: true, |
| 2786 | } |
| 2787 | |
| 2788 | cc_library { |
| 2789 | name: "libvndk_sp_ext", |
| 2790 | vendor: true, |
| 2791 | vndk: { |
| 2792 | enabled: true, |
| 2793 | extends: "libvndk_sp", |
| 2794 | support_system_process: true, |
| 2795 | }, |
| 2796 | shared_libs: ["libvndk_ext"], // Cause an error |
| 2797 | nocrt: true, |
| 2798 | } |
| 2799 | `) |
| 2800 | } |
| 2801 | |
| 2802 | func TestVndkUseVndkExtError(t *testing.T) { |
| 2803 | // This test ensures an error is emitted if a VNDK/VNDK-SP library depends on a |
| 2804 | // VNDK-Ext/VNDK-SP-Ext library. |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2805 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 2806 | cc_library { |
| 2807 | name: "libvndk", |
| 2808 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2809 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2810 | vndk: { |
| 2811 | enabled: true, |
| 2812 | }, |
| 2813 | nocrt: true, |
| 2814 | } |
| 2815 | |
| 2816 | cc_library { |
| 2817 | name: "libvndk_ext", |
| 2818 | vendor: true, |
| 2819 | vndk: { |
| 2820 | enabled: true, |
| 2821 | extends: "libvndk", |
| 2822 | }, |
| 2823 | nocrt: true, |
| 2824 | } |
| 2825 | |
| 2826 | cc_library { |
| 2827 | name: "libvndk2", |
| 2828 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2829 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2830 | vndk: { |
| 2831 | enabled: true, |
| 2832 | }, |
| 2833 | shared_libs: ["libvndk_ext"], |
| 2834 | nocrt: true, |
| 2835 | } |
| 2836 | `) |
| 2837 | |
Martin Stjernholm | ef449fe | 2018-11-06 16:12:13 +0000 | [diff] [blame] | 2838 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2839 | cc_library { |
| 2840 | name: "libvndk", |
| 2841 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2842 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2843 | vndk: { |
| 2844 | enabled: true, |
| 2845 | }, |
| 2846 | nocrt: true, |
| 2847 | } |
| 2848 | |
| 2849 | cc_library { |
| 2850 | name: "libvndk_ext", |
| 2851 | vendor: true, |
| 2852 | vndk: { |
| 2853 | enabled: true, |
| 2854 | extends: "libvndk", |
| 2855 | }, |
| 2856 | nocrt: true, |
| 2857 | } |
| 2858 | |
| 2859 | cc_library { |
| 2860 | name: "libvndk2", |
| 2861 | vendor_available: true, |
| 2862 | vndk: { |
| 2863 | enabled: true, |
| 2864 | }, |
| 2865 | target: { |
| 2866 | vendor: { |
| 2867 | shared_libs: ["libvndk_ext"], |
| 2868 | }, |
| 2869 | }, |
| 2870 | nocrt: true, |
| 2871 | } |
| 2872 | `) |
| 2873 | |
| 2874 | testCcError(t, "dependency \".*\" of \".*\" missing variant", ` |
| 2875 | cc_library { |
| 2876 | name: "libvndk_sp", |
| 2877 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2878 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2879 | vndk: { |
| 2880 | enabled: true, |
| 2881 | support_system_process: true, |
| 2882 | }, |
| 2883 | nocrt: true, |
| 2884 | } |
| 2885 | |
| 2886 | cc_library { |
| 2887 | name: "libvndk_sp_ext", |
| 2888 | vendor: true, |
| 2889 | vndk: { |
| 2890 | enabled: true, |
| 2891 | extends: "libvndk_sp", |
| 2892 | support_system_process: true, |
| 2893 | }, |
| 2894 | nocrt: true, |
| 2895 | } |
| 2896 | |
| 2897 | cc_library { |
| 2898 | name: "libvndk_sp_2", |
| 2899 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2900 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2901 | vndk: { |
| 2902 | enabled: true, |
| 2903 | support_system_process: true, |
| 2904 | }, |
| 2905 | shared_libs: ["libvndk_sp_ext"], |
| 2906 | nocrt: true, |
| 2907 | } |
| 2908 | `) |
| 2909 | |
Martin Stjernholm | ef449fe | 2018-11-06 16:12:13 +0000 | [diff] [blame] | 2910 | testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", ` |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2911 | cc_library { |
| 2912 | name: "libvndk_sp", |
| 2913 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2914 | product_available: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2915 | vndk: { |
| 2916 | enabled: true, |
| 2917 | }, |
| 2918 | nocrt: true, |
| 2919 | } |
| 2920 | |
| 2921 | cc_library { |
| 2922 | name: "libvndk_sp_ext", |
| 2923 | vendor: true, |
| 2924 | vndk: { |
| 2925 | enabled: true, |
| 2926 | extends: "libvndk_sp", |
| 2927 | }, |
| 2928 | nocrt: true, |
| 2929 | } |
| 2930 | |
| 2931 | cc_library { |
| 2932 | name: "libvndk_sp2", |
| 2933 | vendor_available: true, |
| 2934 | vndk: { |
| 2935 | enabled: true, |
| 2936 | }, |
| 2937 | target: { |
| 2938 | vendor: { |
| 2939 | shared_libs: ["libvndk_sp_ext"], |
| 2940 | }, |
| 2941 | }, |
| 2942 | nocrt: true, |
| 2943 | } |
| 2944 | `) |
| 2945 | } |
| 2946 | |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2947 | func TestEnforceProductVndkVersion(t *testing.T) { |
| 2948 | bp := ` |
| 2949 | cc_library { |
| 2950 | name: "libllndk", |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2951 | llndk_stubs: "libllndk.llndk", |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2952 | } |
| 2953 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 2954 | name: "libllndk.llndk", |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2955 | symbol_file: "", |
| 2956 | } |
| 2957 | cc_library { |
| 2958 | name: "libvndk", |
| 2959 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2960 | product_available: true, |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2961 | vndk: { |
| 2962 | enabled: true, |
| 2963 | }, |
| 2964 | nocrt: true, |
| 2965 | } |
| 2966 | cc_library { |
| 2967 | name: "libvndk_sp", |
| 2968 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2969 | product_available: true, |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2970 | vndk: { |
| 2971 | enabled: true, |
| 2972 | support_system_process: true, |
| 2973 | }, |
| 2974 | nocrt: true, |
| 2975 | } |
| 2976 | cc_library { |
| 2977 | name: "libva", |
| 2978 | vendor_available: true, |
| 2979 | nocrt: true, |
| 2980 | } |
| 2981 | cc_library { |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 2982 | name: "libpa", |
| 2983 | product_available: true, |
| 2984 | nocrt: true, |
| 2985 | } |
| 2986 | cc_library { |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 2987 | name: "libboth_available", |
| 2988 | vendor_available: true, |
| 2989 | product_available: true, |
| 2990 | nocrt: true, |
| 2991 | target: { |
| 2992 | vendor: { |
| 2993 | suffix: "-vendor", |
| 2994 | }, |
| 2995 | product: { |
| 2996 | suffix: "-product", |
| 2997 | }, |
| 2998 | } |
| 2999 | } |
| 3000 | cc_library { |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3001 | name: "libproduct_va", |
| 3002 | product_specific: true, |
| 3003 | vendor_available: true, |
| 3004 | nocrt: true, |
| 3005 | } |
| 3006 | cc_library { |
| 3007 | name: "libprod", |
| 3008 | product_specific: true, |
| 3009 | shared_libs: [ |
| 3010 | "libllndk", |
| 3011 | "libvndk", |
| 3012 | "libvndk_sp", |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3013 | "libpa", |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3014 | "libboth_available", |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3015 | "libproduct_va", |
| 3016 | ], |
| 3017 | nocrt: true, |
| 3018 | } |
| 3019 | cc_library { |
| 3020 | name: "libvendor", |
| 3021 | vendor: true, |
| 3022 | shared_libs: [ |
| 3023 | "libllndk", |
| 3024 | "libvndk", |
| 3025 | "libvndk_sp", |
| 3026 | "libva", |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3027 | "libboth_available", |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3028 | "libproduct_va", |
| 3029 | ], |
| 3030 | nocrt: true, |
| 3031 | } |
| 3032 | ` |
| 3033 | |
| 3034 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 3035 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 3036 | config.TestProductVariables.ProductVndkVersion = StringPtr("current") |
| 3037 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 3038 | |
| 3039 | ctx := testCcWithConfig(t, config) |
| 3040 | |
Jooyung Han | 261e158 | 2020-10-20 18:54:21 +0900 | [diff] [blame] | 3041 | checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant) |
| 3042 | checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant) |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3043 | |
| 3044 | mod_vendor := ctx.ModuleForTests("libboth_available", vendorVariant).Module().(*Module) |
| 3045 | assertString(t, mod_vendor.outputFile.Path().Base(), "libboth_available-vendor.so") |
| 3046 | |
| 3047 | mod_product := ctx.ModuleForTests("libboth_available", productVariant).Module().(*Module) |
| 3048 | assertString(t, mod_product.outputFile.Path().Base(), "libboth_available-product.so") |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3049 | } |
| 3050 | |
| 3051 | func TestEnforceProductVndkVersionErrors(t *testing.T) { |
| 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 | "libvendor", |
| 3058 | ], |
| 3059 | nocrt: true, |
| 3060 | } |
| 3061 | cc_library { |
| 3062 | name: "libvendor", |
| 3063 | vendor: true, |
| 3064 | nocrt: true, |
| 3065 | } |
| 3066 | `) |
| 3067 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3068 | cc_library { |
| 3069 | name: "libprod", |
| 3070 | product_specific: true, |
| 3071 | shared_libs: [ |
| 3072 | "libsystem", |
| 3073 | ], |
| 3074 | nocrt: true, |
| 3075 | } |
| 3076 | cc_library { |
| 3077 | name: "libsystem", |
| 3078 | nocrt: true, |
| 3079 | } |
| 3080 | `) |
Justin Yun | 6977e8a | 2020-10-29 18:24:11 +0900 | [diff] [blame] | 3081 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3082 | cc_library { |
| 3083 | name: "libprod", |
| 3084 | product_specific: true, |
| 3085 | shared_libs: [ |
| 3086 | "libva", |
| 3087 | ], |
| 3088 | nocrt: true, |
| 3089 | } |
| 3090 | cc_library { |
| 3091 | name: "libva", |
| 3092 | vendor_available: true, |
| 3093 | nocrt: true, |
| 3094 | } |
| 3095 | `) |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3096 | 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] | 3097 | cc_library { |
| 3098 | name: "libprod", |
| 3099 | product_specific: true, |
| 3100 | shared_libs: [ |
| 3101 | "libvndk_private", |
| 3102 | ], |
| 3103 | nocrt: true, |
| 3104 | } |
| 3105 | cc_library { |
| 3106 | name: "libvndk_private", |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3107 | vendor_available: true, |
| 3108 | product_available: true, |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3109 | vndk: { |
| 3110 | enabled: true, |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3111 | private: true, |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 3112 | }, |
| 3113 | nocrt: true, |
| 3114 | } |
| 3115 | `) |
| 3116 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", ` |
| 3117 | cc_library { |
| 3118 | name: "libprod", |
| 3119 | product_specific: true, |
| 3120 | shared_libs: [ |
| 3121 | "libsystem_ext", |
| 3122 | ], |
| 3123 | nocrt: true, |
| 3124 | } |
| 3125 | cc_library { |
| 3126 | name: "libsystem_ext", |
| 3127 | system_ext_specific: true, |
| 3128 | nocrt: true, |
| 3129 | } |
| 3130 | `) |
| 3131 | testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:", ` |
| 3132 | cc_library { |
| 3133 | name: "libsystem", |
| 3134 | shared_libs: [ |
| 3135 | "libproduct_va", |
| 3136 | ], |
| 3137 | nocrt: true, |
| 3138 | } |
| 3139 | cc_library { |
| 3140 | name: "libproduct_va", |
| 3141 | product_specific: true, |
| 3142 | vendor_available: true, |
| 3143 | nocrt: true, |
| 3144 | } |
| 3145 | `) |
| 3146 | } |
| 3147 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3148 | func TestMakeLinkType(t *testing.T) { |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3149 | bp := ` |
| 3150 | cc_library { |
| 3151 | name: "libvndk", |
| 3152 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3153 | product_available: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3154 | vndk: { |
| 3155 | enabled: true, |
| 3156 | }, |
| 3157 | } |
| 3158 | cc_library { |
| 3159 | name: "libvndksp", |
| 3160 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3161 | product_available: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3162 | vndk: { |
| 3163 | enabled: true, |
| 3164 | support_system_process: true, |
| 3165 | }, |
| 3166 | } |
| 3167 | cc_library { |
| 3168 | name: "libvndkprivate", |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3169 | vendor_available: true, |
| 3170 | product_available: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3171 | vndk: { |
| 3172 | enabled: true, |
Justin Yun | fd9e804 | 2020-12-23 18:23:14 +0900 | [diff] [blame] | 3173 | private: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3174 | }, |
| 3175 | } |
| 3176 | cc_library { |
| 3177 | name: "libvendor", |
| 3178 | vendor: true, |
| 3179 | } |
| 3180 | cc_library { |
| 3181 | name: "libvndkext", |
| 3182 | vendor: true, |
| 3183 | vndk: { |
| 3184 | enabled: true, |
| 3185 | extends: "libvndk", |
| 3186 | }, |
| 3187 | } |
| 3188 | vndk_prebuilt_shared { |
| 3189 | name: "prevndk", |
| 3190 | version: "27", |
| 3191 | target_arch: "arm", |
| 3192 | binder32bit: true, |
| 3193 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 3194 | product_available: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3195 | vndk: { |
| 3196 | enabled: true, |
| 3197 | }, |
| 3198 | arch: { |
| 3199 | arm: { |
| 3200 | srcs: ["liba.so"], |
| 3201 | }, |
| 3202 | }, |
| 3203 | } |
| 3204 | cc_library { |
| 3205 | name: "libllndk", |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3206 | llndk_stubs: "libllndk.llndk", |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3207 | } |
| 3208 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3209 | name: "libllndk.llndk", |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3210 | symbol_file: "", |
| 3211 | } |
| 3212 | cc_library { |
| 3213 | name: "libllndkprivate", |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3214 | llndk_stubs: "libllndkprivate.llndk", |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3215 | } |
| 3216 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3217 | name: "libllndkprivate.llndk", |
Justin Yun | c0d8c49 | 2021-01-07 17:45:31 +0900 | [diff] [blame] | 3218 | private: true, |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3219 | symbol_file: "", |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 3220 | } |
| 3221 | |
| 3222 | llndk_libraries_txt { |
| 3223 | name: "llndk.libraries.txt", |
| 3224 | } |
| 3225 | vndkcore_libraries_txt { |
| 3226 | name: "vndkcore.libraries.txt", |
| 3227 | } |
| 3228 | vndksp_libraries_txt { |
| 3229 | name: "vndksp.libraries.txt", |
| 3230 | } |
| 3231 | vndkprivate_libraries_txt { |
| 3232 | name: "vndkprivate.libraries.txt", |
| 3233 | } |
| 3234 | vndkcorevariant_libraries_txt { |
| 3235 | name: "vndkcorevariant.libraries.txt", |
| 3236 | insert_vndk_version: false, |
| 3237 | } |
| 3238 | ` |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3239 | |
| 3240 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3241 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 3242 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 3243 | // native:vndk |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 3244 | ctx := testCcWithConfig(t, config) |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3245 | |
Colin Cross | 7821224 | 2021-01-06 14:51:30 -0800 | [diff] [blame] | 3246 | checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", |
| 3247 | []string{"libvndk.so", "libvndkprivate.so"}) |
| 3248 | checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", |
| 3249 | []string{"libc++.so", "libvndksp.so"}) |
| 3250 | checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", |
| 3251 | []string{"libc.so", "libdl.so", "libft2.so", "libllndk.so", "libllndkprivate.so", "libm.so"}) |
| 3252 | checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", |
| 3253 | []string{"libft2.so", "libllndkprivate.so", "libvndkprivate.so"}) |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3254 | |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3255 | vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared" |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 3256 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3257 | tests := []struct { |
| 3258 | variant string |
| 3259 | name string |
| 3260 | expected string |
| 3261 | }{ |
| 3262 | {vendorVariant, "libvndk", "native:vndk"}, |
| 3263 | {vendorVariant, "libvndksp", "native:vndk"}, |
| 3264 | {vendorVariant, "libvndkprivate", "native:vndk_private"}, |
| 3265 | {vendorVariant, "libvendor", "native:vendor"}, |
| 3266 | {vendorVariant, "libvndkext", "native:vendor"}, |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3267 | {vendorVariant, "libllndk", "native:vndk"}, |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 3268 | {vendorVariant27, "prevndk.vndk.27.arm.binder32", "native:vndk"}, |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 3269 | {coreVariant, "libvndk", "native:platform"}, |
| 3270 | {coreVariant, "libvndkprivate", "native:platform"}, |
| 3271 | {coreVariant, "libllndk", "native:platform"}, |
| 3272 | } |
| 3273 | for _, test := range tests { |
| 3274 | t.Run(test.name, func(t *testing.T) { |
| 3275 | module := ctx.ModuleForTests(test.name, test.variant).Module().(*Module) |
| 3276 | assertString(t, module.makeLinkType, test.expected) |
| 3277 | }) |
| 3278 | } |
| 3279 | } |
| 3280 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3281 | var staticLinkDepOrderTestCases = []struct { |
| 3282 | // This is a string representation of a map[moduleName][]moduleDependency . |
| 3283 | // It models the dependencies declared in an Android.bp file. |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3284 | inStatic string |
| 3285 | |
| 3286 | // This is a string representation of a map[moduleName][]moduleDependency . |
| 3287 | // It models the dependencies declared in an Android.bp file. |
| 3288 | inShared string |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3289 | |
| 3290 | // allOrdered is a string representation of a map[moduleName][]moduleDependency . |
| 3291 | // The keys of allOrdered specify which modules we would like to check. |
| 3292 | // The values of allOrdered specify the expected result (of the transitive closure of all |
| 3293 | // dependencies) for each module to test |
| 3294 | allOrdered string |
| 3295 | |
| 3296 | // outOrdered is a string representation of a map[moduleName][]moduleDependency . |
| 3297 | // The keys of outOrdered specify which modules we would like to check. |
| 3298 | // The values of outOrdered specify the expected result (of the ordered linker command line) |
| 3299 | // for each module to test. |
| 3300 | outOrdered string |
| 3301 | }{ |
| 3302 | // Simple tests |
| 3303 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3304 | inStatic: "", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3305 | outOrdered: "", |
| 3306 | }, |
| 3307 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3308 | inStatic: "a:", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3309 | outOrdered: "a:", |
| 3310 | }, |
| 3311 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3312 | inStatic: "a:b; b:", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3313 | outOrdered: "a:b; b:", |
| 3314 | }, |
| 3315 | // Tests of reordering |
| 3316 | { |
| 3317 | // diamond example |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3318 | inStatic: "a:d,b,c; b:d; c:d; d:", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3319 | outOrdered: "a:b,c,d; b:d; c:d; d:", |
| 3320 | }, |
| 3321 | { |
| 3322 | // somewhat real example |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3323 | 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] | 3324 | outOrdered: "bsdiff_unittest:c,d,e,b,f,g,h,i; e:b", |
| 3325 | }, |
| 3326 | { |
| 3327 | // multiple reorderings |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3328 | inStatic: "a:b,c,d,e; d:b; e:c", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3329 | outOrdered: "a:d,b,e,c; d:b; e:c", |
| 3330 | }, |
| 3331 | { |
| 3332 | // should reorder without adding new transitive dependencies |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3333 | inStatic: "bin:lib2,lib1; lib1:lib2,liboptional", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3334 | allOrdered: "bin:lib1,lib2,liboptional; lib1:lib2,liboptional", |
| 3335 | outOrdered: "bin:lib1,lib2; lib1:lib2,liboptional", |
| 3336 | }, |
| 3337 | { |
| 3338 | // multiple levels of dependencies |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3339 | 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] | 3340 | allOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d", |
| 3341 | outOrdered: "a:e,f,b,c,d,g,h; f:b,c,d; b:c,d; c:d", |
| 3342 | }, |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3343 | // shared dependencies |
| 3344 | { |
| 3345 | // Note that this test doesn't recurse, to minimize the amount of logic it tests. |
| 3346 | // So, we don't actually have to check that a shared dependency of c will change the order |
| 3347 | // of a library that depends statically on b and on c. We only need to check that if c has |
| 3348 | // a shared dependency on b, that that shows up in allOrdered. |
| 3349 | inShared: "c:b", |
| 3350 | allOrdered: "c:b", |
| 3351 | outOrdered: "c:", |
| 3352 | }, |
| 3353 | { |
| 3354 | // This test doesn't actually include any shared dependencies but it's a reminder of what |
| 3355 | // the second phase of the above test would look like |
| 3356 | inStatic: "a:b,c; c:b", |
| 3357 | allOrdered: "a:c,b; c:b", |
| 3358 | outOrdered: "a:c,b; c:b", |
| 3359 | }, |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3360 | // tiebreakers for when two modules specifying different orderings and there is no dependency |
| 3361 | // to dictate an order |
| 3362 | { |
| 3363 | // 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] | 3364 | 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] | 3365 | outOrdered: "a1:b,c,d,e; a2:b,c,e,d; b:d,e; c:e,d", |
| 3366 | }, |
| 3367 | { |
| 3368 | // 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] | 3369 | 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] | 3370 | outOrdered: "a1:b1,c1,e,d; b1:d,e; c1:e,d; a2:b2,c2,d,e; b2:d,e; c2:d,e", |
| 3371 | }, |
| 3372 | // Tests involving duplicate dependencies |
| 3373 | { |
| 3374 | // simple duplicate |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3375 | inStatic: "a:b,c,c,b", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3376 | outOrdered: "a:c,b", |
| 3377 | }, |
| 3378 | { |
| 3379 | // duplicates with reordering |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3380 | inStatic: "a:b,c,d,c; c:b", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3381 | outOrdered: "a:d,c,b", |
| 3382 | }, |
| 3383 | // Tests to confirm the nonexistence of infinite loops. |
| 3384 | // These cases should never happen, so as long as the test terminates and the |
| 3385 | // result is deterministic then that should be fine. |
| 3386 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3387 | inStatic: "a:a", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3388 | outOrdered: "a:a", |
| 3389 | }, |
| 3390 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3391 | inStatic: "a:b; b:c; c:a", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3392 | allOrdered: "a:b,c; b:c,a; c:a,b", |
| 3393 | outOrdered: "a:b; b:c; c:a", |
| 3394 | }, |
| 3395 | { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3396 | inStatic: "a:b,c; b:c,a; c:a,b", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3397 | allOrdered: "a:c,a,b; b:a,b,c; c:b,c,a", |
| 3398 | outOrdered: "a:c,b; b:a,c; c:b,a", |
| 3399 | }, |
| 3400 | } |
| 3401 | |
| 3402 | // converts from a string like "a:b,c; d:e" to (["a","b"], {"a":["b","c"], "d":["e"]}, [{"a", "a.o"}, {"b", "b.o"}]) |
| 3403 | func parseModuleDeps(text string) (modulesInOrder []android.Path, allDeps map[android.Path][]android.Path) { |
| 3404 | // convert from "a:b,c; d:e" to "a:b,c;d:e" |
| 3405 | strippedText := strings.Replace(text, " ", "", -1) |
| 3406 | if len(strippedText) < 1 { |
| 3407 | return []android.Path{}, make(map[android.Path][]android.Path, 0) |
| 3408 | } |
| 3409 | allDeps = make(map[android.Path][]android.Path, 0) |
| 3410 | |
| 3411 | // convert from "a:b,c;d:e" to ["a:b,c", "d:e"] |
| 3412 | moduleTexts := strings.Split(strippedText, ";") |
| 3413 | |
| 3414 | outputForModuleName := func(moduleName string) android.Path { |
| 3415 | return android.PathForTesting(moduleName) |
| 3416 | } |
| 3417 | |
| 3418 | for _, moduleText := range moduleTexts { |
| 3419 | // convert from "a:b,c" to ["a", "b,c"] |
| 3420 | components := strings.Split(moduleText, ":") |
| 3421 | if len(components) != 2 { |
| 3422 | panic(fmt.Sprintf("illegal module dep string %q from larger string %q; must contain one ':', not %v", moduleText, text, len(components)-1)) |
| 3423 | } |
| 3424 | moduleName := components[0] |
| 3425 | moduleOutput := outputForModuleName(moduleName) |
| 3426 | modulesInOrder = append(modulesInOrder, moduleOutput) |
| 3427 | |
| 3428 | depString := components[1] |
| 3429 | // convert from "b,c" to ["b", "c"] |
| 3430 | depNames := strings.Split(depString, ",") |
| 3431 | if len(depString) < 1 { |
| 3432 | depNames = []string{} |
| 3433 | } |
| 3434 | var deps []android.Path |
| 3435 | for _, depName := range depNames { |
| 3436 | deps = append(deps, outputForModuleName(depName)) |
| 3437 | } |
| 3438 | allDeps[moduleOutput] = deps |
| 3439 | } |
| 3440 | return modulesInOrder, allDeps |
| 3441 | } |
| 3442 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3443 | func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) { |
| 3444 | for _, moduleName := range moduleNames { |
| 3445 | module := ctx.ModuleForTests(moduleName, variant).Module().(*Module) |
| 3446 | output := module.outputFile.Path() |
| 3447 | paths = append(paths, output) |
| 3448 | } |
| 3449 | return paths |
| 3450 | } |
| 3451 | |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3452 | func TestStaticLibDepReordering(t *testing.T) { |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3453 | ctx := testCc(t, ` |
| 3454 | cc_library { |
| 3455 | name: "a", |
| 3456 | static_libs: ["b", "c", "d"], |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3457 | stl: "none", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3458 | } |
| 3459 | cc_library { |
| 3460 | name: "b", |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3461 | stl: "none", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3462 | } |
| 3463 | cc_library { |
| 3464 | name: "c", |
| 3465 | static_libs: ["b"], |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3466 | stl: "none", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3467 | } |
| 3468 | cc_library { |
| 3469 | name: "d", |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3470 | stl: "none", |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3471 | } |
| 3472 | |
| 3473 | `) |
| 3474 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3475 | variant := "android_arm64_armv8-a_static" |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3476 | moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3477 | actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList() |
| 3478 | expected := getOutputPaths(ctx, variant, []string{"a", "c", "b", "d"}) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3479 | |
| 3480 | if !reflect.DeepEqual(actual, expected) { |
| 3481 | t.Errorf("staticDeps orderings were not propagated correctly"+ |
| 3482 | "\nactual: %v"+ |
| 3483 | "\nexpected: %v", |
| 3484 | actual, |
| 3485 | expected, |
| 3486 | ) |
| 3487 | } |
Jiyong Park | d08b697 | 2017-09-26 10:50:54 +0900 | [diff] [blame] | 3488 | } |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3489 | |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3490 | func TestStaticLibDepReorderingWithShared(t *testing.T) { |
| 3491 | ctx := testCc(t, ` |
| 3492 | cc_library { |
| 3493 | name: "a", |
| 3494 | static_libs: ["b", "c"], |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3495 | stl: "none", |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3496 | } |
| 3497 | cc_library { |
| 3498 | name: "b", |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3499 | stl: "none", |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3500 | } |
| 3501 | cc_library { |
| 3502 | name: "c", |
| 3503 | shared_libs: ["b"], |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3504 | stl: "none", |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3505 | } |
| 3506 | |
| 3507 | `) |
| 3508 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3509 | variant := "android_arm64_armv8-a_static" |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3510 | moduleA := ctx.ModuleForTests("a", variant).Module().(*Module) |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3511 | actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList() |
| 3512 | expected := getOutputPaths(ctx, variant, []string{"a", "c", "b"}) |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 3513 | |
| 3514 | if !reflect.DeepEqual(actual, expected) { |
| 3515 | t.Errorf("staticDeps orderings did not account for shared libs"+ |
| 3516 | "\nactual: %v"+ |
| 3517 | "\nexpected: %v", |
| 3518 | actual, |
| 3519 | expected, |
| 3520 | ) |
| 3521 | } |
| 3522 | } |
| 3523 | |
Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 3524 | func checkEquals(t *testing.T, message string, expected, actual interface{}) { |
Colin Cross | d1f898e | 2020-08-18 18:35:15 -0700 | [diff] [blame] | 3525 | t.Helper() |
Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 3526 | if !reflect.DeepEqual(actual, expected) { |
| 3527 | t.Errorf(message+ |
| 3528 | "\nactual: %v"+ |
| 3529 | "\nexpected: %v", |
| 3530 | actual, |
| 3531 | expected, |
| 3532 | ) |
| 3533 | } |
| 3534 | } |
| 3535 | |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3536 | func TestLlndkLibrary(t *testing.T) { |
| 3537 | ctx := testCc(t, ` |
| 3538 | cc_library { |
| 3539 | name: "libllndk", |
| 3540 | stubs: { versions: ["1", "2"] }, |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3541 | llndk_stubs: "libllndk.llndk", |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3542 | } |
| 3543 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3544 | name: "libllndk.llndk", |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3545 | } |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3546 | |
| 3547 | cc_prebuilt_library_shared { |
| 3548 | name: "libllndkprebuilt", |
| 3549 | stubs: { versions: ["1", "2"] }, |
| 3550 | llndk_stubs: "libllndkprebuilt.llndk", |
| 3551 | } |
| 3552 | llndk_library { |
| 3553 | name: "libllndkprebuilt.llndk", |
| 3554 | } |
| 3555 | |
| 3556 | cc_library { |
| 3557 | name: "libllndk_with_external_headers", |
| 3558 | stubs: { versions: ["1", "2"] }, |
| 3559 | llndk_stubs: "libllndk_with_external_headers.llndk", |
| 3560 | header_libs: ["libexternal_headers"], |
| 3561 | export_header_lib_headers: ["libexternal_headers"], |
| 3562 | } |
| 3563 | llndk_library { |
| 3564 | name: "libllndk_with_external_headers.llndk", |
| 3565 | } |
| 3566 | cc_library_headers { |
| 3567 | name: "libexternal_headers", |
| 3568 | export_include_dirs: ["include"], |
| 3569 | vendor_available: true, |
| 3570 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3571 | `) |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3572 | actual := ctx.ModuleVariantsForTests("libllndk") |
| 3573 | for i := 0; i < len(actual); i++ { |
| 3574 | if !strings.HasPrefix(actual[i], "android_vendor.VER_") { |
| 3575 | actual = append(actual[:i], actual[i+1:]...) |
| 3576 | i-- |
| 3577 | } |
| 3578 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3579 | expected := []string{ |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3580 | "android_vendor.VER_arm64_armv8-a_shared_1", |
| 3581 | "android_vendor.VER_arm64_armv8-a_shared_2", |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3582 | "android_vendor.VER_arm64_armv8-a_shared", |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3583 | "android_vendor.VER_arm_armv7-a-neon_shared_1", |
| 3584 | "android_vendor.VER_arm_armv7-a-neon_shared_2", |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 3585 | "android_vendor.VER_arm_armv7-a-neon_shared", |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 3586 | } |
| 3587 | checkEquals(t, "variants for llndk stubs", expected, actual) |
| 3588 | |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3589 | 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] | 3590 | checkEquals(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"]) |
| 3591 | |
Colin Cross | 127bb8b | 2020-12-16 16:46:01 -0800 | [diff] [blame] | 3592 | 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] | 3593 | checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"]) |
| 3594 | } |
| 3595 | |
Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3596 | func TestLlndkHeaders(t *testing.T) { |
| 3597 | ctx := testCc(t, ` |
| 3598 | llndk_headers { |
| 3599 | name: "libllndk_headers", |
| 3600 | export_include_dirs: ["my_include"], |
| 3601 | } |
| 3602 | llndk_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3603 | name: "libllndk.llndk", |
Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3604 | export_llndk_headers: ["libllndk_headers"], |
| 3605 | } |
| 3606 | cc_library { |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 3607 | name: "libllndk", |
| 3608 | llndk_stubs: "libllndk.llndk", |
| 3609 | } |
| 3610 | |
| 3611 | cc_library { |
Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3612 | name: "libvendor", |
| 3613 | shared_libs: ["libllndk"], |
| 3614 | vendor: true, |
| 3615 | srcs: ["foo.c"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3616 | no_libcrt: true, |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 3617 | nocrt: true, |
Jiyong Park | a46a4d5 | 2017-12-14 19:54:34 +0900 | [diff] [blame] | 3618 | } |
| 3619 | `) |
| 3620 | |
| 3621 | // _static variant is used since _shared reuses *.o from the static variant |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3622 | 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] | 3623 | cflags := cc.Args["cFlags"] |
| 3624 | if !strings.Contains(cflags, "-Imy_include") { |
| 3625 | t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags) |
| 3626 | } |
| 3627 | } |
| 3628 | |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3629 | func checkRuntimeLibs(t *testing.T, expected []string, module *Module) { |
| 3630 | actual := module.Properties.AndroidMkRuntimeLibs |
| 3631 | if !reflect.DeepEqual(actual, expected) { |
| 3632 | t.Errorf("incorrect runtime_libs for shared libs"+ |
| 3633 | "\nactual: %v"+ |
| 3634 | "\nexpected: %v", |
| 3635 | actual, |
| 3636 | expected, |
| 3637 | ) |
| 3638 | } |
| 3639 | } |
| 3640 | |
| 3641 | const runtimeLibAndroidBp = ` |
| 3642 | cc_library { |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3643 | name: "liball_available", |
| 3644 | vendor_available: true, |
| 3645 | product_available: true, |
| 3646 | no_libcrt : true, |
| 3647 | nocrt : true, |
| 3648 | system_shared_libs : [], |
| 3649 | } |
| 3650 | cc_library { |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3651 | name: "libvendor_available1", |
| 3652 | vendor_available: true, |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3653 | runtime_libs: ["liball_available"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3654 | no_libcrt : true, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3655 | nocrt : true, |
| 3656 | system_shared_libs : [], |
| 3657 | } |
| 3658 | cc_library { |
| 3659 | name: "libvendor_available2", |
| 3660 | vendor_available: true, |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3661 | runtime_libs: ["liball_available"], |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3662 | target: { |
| 3663 | vendor: { |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3664 | exclude_runtime_libs: ["liball_available"], |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3665 | } |
| 3666 | }, |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3667 | no_libcrt : true, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3668 | nocrt : true, |
| 3669 | system_shared_libs : [], |
| 3670 | } |
| 3671 | cc_library { |
| 3672 | name: "libcore", |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3673 | runtime_libs: ["liball_available"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3674 | no_libcrt : true, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3675 | nocrt : true, |
| 3676 | system_shared_libs : [], |
| 3677 | } |
| 3678 | cc_library { |
| 3679 | name: "libvendor1", |
| 3680 | vendor: true, |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3681 | no_libcrt : true, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3682 | nocrt : true, |
| 3683 | system_shared_libs : [], |
| 3684 | } |
| 3685 | cc_library { |
| 3686 | name: "libvendor2", |
| 3687 | vendor: true, |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3688 | runtime_libs: ["liball_available", "libvendor1"], |
| 3689 | no_libcrt : true, |
| 3690 | nocrt : true, |
| 3691 | system_shared_libs : [], |
| 3692 | } |
| 3693 | cc_library { |
| 3694 | name: "libproduct_available1", |
| 3695 | product_available: true, |
| 3696 | runtime_libs: ["liball_available"], |
| 3697 | no_libcrt : true, |
| 3698 | nocrt : true, |
| 3699 | system_shared_libs : [], |
| 3700 | } |
| 3701 | cc_library { |
| 3702 | name: "libproduct1", |
| 3703 | product_specific: true, |
| 3704 | no_libcrt : true, |
| 3705 | nocrt : true, |
| 3706 | system_shared_libs : [], |
| 3707 | } |
| 3708 | cc_library { |
| 3709 | name: "libproduct2", |
| 3710 | product_specific: true, |
| 3711 | runtime_libs: ["liball_available", "libproduct1"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3712 | no_libcrt : true, |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3713 | nocrt : true, |
| 3714 | system_shared_libs : [], |
| 3715 | } |
| 3716 | ` |
| 3717 | |
| 3718 | func TestRuntimeLibs(t *testing.T) { |
| 3719 | ctx := testCc(t, runtimeLibAndroidBp) |
| 3720 | |
| 3721 | // runtime_libs for core variants use the module names without suffixes. |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3722 | variant := "android_arm64_armv8-a_shared" |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3723 | |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3724 | module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3725 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
| 3726 | |
| 3727 | module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module) |
| 3728 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3729 | |
| 3730 | module = ctx.ModuleForTests("libcore", variant).Module().(*Module) |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3731 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3732 | |
| 3733 | // runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core |
| 3734 | // and vendor variants. |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3735 | variant = "android_vendor.VER_arm64_armv8-a_shared" |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3736 | |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3737 | module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3738 | checkRuntimeLibs(t, []string{"liball_available.vendor"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3739 | |
| 3740 | module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module) |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3741 | checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1"}, module) |
| 3742 | |
| 3743 | // runtime_libs for product variants have '.product' suffixes if the modules have both core |
| 3744 | // and product variants. |
| 3745 | variant = "android_product.VER_arm64_armv8-a_shared" |
| 3746 | |
| 3747 | module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module) |
| 3748 | checkRuntimeLibs(t, []string{"liball_available.product"}, module) |
| 3749 | |
| 3750 | module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module) |
| 3751 | checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3752 | } |
| 3753 | |
| 3754 | func TestExcludeRuntimeLibs(t *testing.T) { |
| 3755 | ctx := testCc(t, runtimeLibAndroidBp) |
| 3756 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3757 | variant := "android_arm64_armv8-a_shared" |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3758 | module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) |
| 3759 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3760 | |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3761 | variant = "android_vendor.VER_arm64_armv8-a_shared" |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3762 | module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3763 | checkRuntimeLibs(t, nil, module) |
| 3764 | } |
| 3765 | |
| 3766 | func TestRuntimeLibsNoVndk(t *testing.T) { |
| 3767 | ctx := testCcNoVndk(t, runtimeLibAndroidBp) |
| 3768 | |
| 3769 | // If DeviceVndkVersion is not defined, then runtime_libs are copied as-is. |
| 3770 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3771 | variant := "android_arm64_armv8-a_shared" |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3772 | |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3773 | module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module) |
| 3774 | checkRuntimeLibs(t, []string{"liball_available"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3775 | |
| 3776 | module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module) |
Justin Yun | 8a2600c | 2020-12-07 12:44:03 +0900 | [diff] [blame] | 3777 | checkRuntimeLibs(t, []string{"liball_available", "libvendor1"}, module) |
| 3778 | |
| 3779 | module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module) |
| 3780 | checkRuntimeLibs(t, []string{"liball_available", "libproduct1"}, module) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 3781 | } |
| 3782 | |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3783 | func checkStaticLibs(t *testing.T, expected []string, module *Module) { |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 3784 | t.Helper() |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3785 | actual := module.Properties.AndroidMkStaticLibs |
| 3786 | if !reflect.DeepEqual(actual, expected) { |
| 3787 | t.Errorf("incorrect static_libs"+ |
| 3788 | "\nactual: %v"+ |
| 3789 | "\nexpected: %v", |
| 3790 | actual, |
| 3791 | expected, |
| 3792 | ) |
| 3793 | } |
| 3794 | } |
| 3795 | |
| 3796 | const staticLibAndroidBp = ` |
| 3797 | cc_library { |
| 3798 | name: "lib1", |
| 3799 | } |
| 3800 | cc_library { |
| 3801 | name: "lib2", |
| 3802 | static_libs: ["lib1"], |
| 3803 | } |
| 3804 | ` |
| 3805 | |
| 3806 | func TestStaticLibDepExport(t *testing.T) { |
| 3807 | ctx := testCc(t, staticLibAndroidBp) |
| 3808 | |
| 3809 | // Check the shared version of lib2. |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3810 | variant := "android_arm64_armv8-a_shared" |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3811 | module := ctx.ModuleForTests("lib2", variant).Module().(*Module) |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 3812 | 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] | 3813 | |
| 3814 | // Check the static version of lib2. |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3815 | variant = "android_arm64_armv8-a_static" |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 3816 | module = ctx.ModuleForTests("lib2", variant).Module().(*Module) |
| 3817 | // libc++_static is linked additionally. |
Peter Collingbourne | e5ba286 | 2019-12-10 18:37:45 -0800 | [diff] [blame] | 3818 | 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] | 3819 | } |
| 3820 | |
Jiyong Park | d08b697 | 2017-09-26 10:50:54 +0900 | [diff] [blame] | 3821 | var compilerFlagsTestCases = []struct { |
| 3822 | in string |
| 3823 | out bool |
| 3824 | }{ |
| 3825 | { |
| 3826 | in: "a", |
| 3827 | out: false, |
| 3828 | }, |
| 3829 | { |
| 3830 | in: "-a", |
| 3831 | out: true, |
| 3832 | }, |
| 3833 | { |
| 3834 | in: "-Ipath/to/something", |
| 3835 | out: false, |
| 3836 | }, |
| 3837 | { |
| 3838 | in: "-isystempath/to/something", |
| 3839 | out: false, |
| 3840 | }, |
| 3841 | { |
| 3842 | in: "--coverage", |
| 3843 | out: false, |
| 3844 | }, |
| 3845 | { |
| 3846 | in: "-include a/b", |
| 3847 | out: true, |
| 3848 | }, |
| 3849 | { |
| 3850 | in: "-include a/b c/d", |
| 3851 | out: false, |
| 3852 | }, |
| 3853 | { |
| 3854 | in: "-DMACRO", |
| 3855 | out: true, |
| 3856 | }, |
| 3857 | { |
| 3858 | in: "-DMAC RO", |
| 3859 | out: false, |
| 3860 | }, |
| 3861 | { |
| 3862 | in: "-a -b", |
| 3863 | out: false, |
| 3864 | }, |
| 3865 | { |
| 3866 | in: "-DMACRO=definition", |
| 3867 | out: true, |
| 3868 | }, |
| 3869 | { |
| 3870 | in: "-DMACRO=defi nition", |
| 3871 | out: true, // TODO(jiyong): this should be false |
| 3872 | }, |
| 3873 | { |
| 3874 | in: "-DMACRO(x)=x + 1", |
| 3875 | out: true, |
| 3876 | }, |
| 3877 | { |
| 3878 | in: "-DMACRO=\"defi nition\"", |
| 3879 | out: true, |
| 3880 | }, |
| 3881 | } |
| 3882 | |
| 3883 | type mockContext struct { |
| 3884 | BaseModuleContext |
| 3885 | result bool |
| 3886 | } |
| 3887 | |
| 3888 | func (ctx *mockContext) PropertyErrorf(property, format string, args ...interface{}) { |
| 3889 | // CheckBadCompilerFlags calls this function when the flag should be rejected |
| 3890 | ctx.result = false |
| 3891 | } |
| 3892 | |
| 3893 | func TestCompilerFlags(t *testing.T) { |
| 3894 | for _, testCase := range compilerFlagsTestCases { |
| 3895 | ctx := &mockContext{result: true} |
| 3896 | CheckBadCompilerFlags(ctx, "", []string{testCase.in}) |
| 3897 | if ctx.result != testCase.out { |
| 3898 | t.Errorf("incorrect output:") |
| 3899 | t.Errorf(" input: %#v", testCase.in) |
| 3900 | t.Errorf(" expected: %#v", testCase.out) |
| 3901 | t.Errorf(" got: %#v", ctx.result) |
| 3902 | } |
| 3903 | } |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 3904 | } |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3905 | |
| 3906 | func TestVendorPublicLibraries(t *testing.T) { |
| 3907 | ctx := testCc(t, ` |
| 3908 | cc_library_headers { |
| 3909 | name: "libvendorpublic_headers", |
| 3910 | export_include_dirs: ["my_include"], |
| 3911 | } |
| 3912 | vendor_public_library { |
| 3913 | name: "libvendorpublic", |
| 3914 | symbol_file: "", |
| 3915 | export_public_headers: ["libvendorpublic_headers"], |
| 3916 | } |
| 3917 | cc_library { |
| 3918 | name: "libvendorpublic", |
| 3919 | srcs: ["foo.c"], |
| 3920 | vendor: true, |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3921 | no_libcrt: true, |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3922 | nocrt: true, |
| 3923 | } |
| 3924 | |
| 3925 | cc_library { |
| 3926 | name: "libsystem", |
| 3927 | shared_libs: ["libvendorpublic"], |
| 3928 | vendor: false, |
| 3929 | srcs: ["foo.c"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3930 | no_libcrt: true, |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3931 | nocrt: true, |
| 3932 | } |
| 3933 | cc_library { |
| 3934 | name: "libvendor", |
| 3935 | shared_libs: ["libvendorpublic"], |
| 3936 | vendor: true, |
| 3937 | srcs: ["foo.c"], |
Yi Kong | e7fe991 | 2019-06-02 00:53:50 -0700 | [diff] [blame] | 3938 | no_libcrt: true, |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3939 | nocrt: true, |
| 3940 | } |
| 3941 | `) |
| 3942 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3943 | coreVariant := "android_arm64_armv8-a_shared" |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3944 | vendorVariant := "android_vendor.VER_arm64_armv8-a_shared" |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3945 | |
| 3946 | // test if header search paths are correctly added |
| 3947 | // _static variant is used since _shared reuses *.o from the static variant |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3948 | cc := ctx.ModuleForTests("libsystem", strings.Replace(coreVariant, "_shared", "_static", 1)).Rule("cc") |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3949 | cflags := cc.Args["cFlags"] |
| 3950 | if !strings.Contains(cflags, "-Imy_include") { |
| 3951 | t.Errorf("cflags for libsystem must contain -Imy_include, but was %#v.", cflags) |
| 3952 | } |
| 3953 | |
| 3954 | // test if libsystem is linked to the stub |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3955 | ld := ctx.ModuleForTests("libsystem", coreVariant).Rule("ld") |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3956 | libflags := ld.Args["libFlags"] |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3957 | stubPaths := getOutputPaths(ctx, coreVariant, []string{"libvendorpublic" + vendorPublicLibrarySuffix}) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3958 | if !strings.Contains(libflags, stubPaths[0].String()) { |
| 3959 | t.Errorf("libflags for libsystem must contain %#v, but was %#v", stubPaths[0], libflags) |
| 3960 | } |
| 3961 | |
| 3962 | // test if libvendor is linked to the real shared lib |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3963 | ld = ctx.ModuleForTests("libvendor", vendorVariant).Rule("ld") |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3964 | libflags = ld.Args["libFlags"] |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 3965 | stubPaths = getOutputPaths(ctx, vendorVariant, []string{"libvendorpublic"}) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 3966 | if !strings.Contains(libflags, stubPaths[0].String()) { |
| 3967 | t.Errorf("libflags for libvendor must contain %#v, but was %#v", stubPaths[0], libflags) |
| 3968 | } |
| 3969 | |
| 3970 | } |
Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3971 | |
| 3972 | func TestRecovery(t *testing.T) { |
| 3973 | ctx := testCc(t, ` |
| 3974 | cc_library_shared { |
| 3975 | name: "librecovery", |
| 3976 | recovery: true, |
| 3977 | } |
| 3978 | cc_library_shared { |
| 3979 | name: "librecovery32", |
| 3980 | recovery: true, |
| 3981 | compile_multilib:"32", |
| 3982 | } |
Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 3983 | cc_library_shared { |
| 3984 | name: "libHalInRecovery", |
| 3985 | recovery_available: true, |
| 3986 | vendor: true, |
| 3987 | } |
Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3988 | `) |
| 3989 | |
| 3990 | variants := ctx.ModuleVariantsForTests("librecovery") |
Colin Cross | fb0c16e | 2019-11-20 17:12:35 -0800 | [diff] [blame] | 3991 | const arm64 = "android_recovery_arm64_armv8-a_shared" |
Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 3992 | if len(variants) != 1 || !android.InList(arm64, variants) { |
| 3993 | t.Errorf("variants of librecovery must be \"%s\" only, but was %#v", arm64, variants) |
| 3994 | } |
| 3995 | |
| 3996 | variants = ctx.ModuleVariantsForTests("librecovery32") |
| 3997 | if android.InList(arm64, variants) { |
| 3998 | t.Errorf("multilib was set to 32 for librecovery32, but its variants has %s.", arm64) |
| 3999 | } |
Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 4000 | |
| 4001 | recoveryModule := ctx.ModuleForTests("libHalInRecovery", recoveryVariant).Module().(*Module) |
| 4002 | if !recoveryModule.Platform() { |
| 4003 | t.Errorf("recovery variant of libHalInRecovery must not specific to device, soc, or product") |
| 4004 | } |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4005 | } |
Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 4006 | |
Chris Parsons | 1f6d90f | 2020-06-17 16:10:42 -0400 | [diff] [blame] | 4007 | func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) { |
| 4008 | bp := ` |
| 4009 | cc_prebuilt_test_library_shared { |
| 4010 | name: "test_lib", |
| 4011 | relative_install_path: "foo/bar/baz", |
| 4012 | srcs: ["srcpath/dontusethispath/baz.so"], |
| 4013 | } |
| 4014 | |
| 4015 | cc_test { |
| 4016 | name: "main_test", |
| 4017 | data_libs: ["test_lib"], |
| 4018 | gtest: false, |
| 4019 | } |
| 4020 | ` |
| 4021 | |
| 4022 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4023 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
| 4024 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
| 4025 | config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true) |
| 4026 | |
| 4027 | ctx := testCcWithConfig(t, config) |
| 4028 | module := ctx.ModuleForTests("main_test", "android_arm_armv7-a-neon").Module() |
| 4029 | testBinary := module.(*Module).linker.(*testBinary) |
| 4030 | outputFiles, err := module.(android.OutputFileProducer).OutputFiles("") |
| 4031 | if err != nil { |
| 4032 | t.Fatalf("Expected cc_test to produce output files, error: %s", err) |
| 4033 | } |
| 4034 | if len(outputFiles) != 1 { |
| 4035 | t.Errorf("expected exactly one output file. output files: [%s]", outputFiles) |
| 4036 | } |
| 4037 | if len(testBinary.dataPaths()) != 1 { |
| 4038 | t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths()) |
| 4039 | } |
| 4040 | |
| 4041 | outputPath := outputFiles[0].String() |
| 4042 | |
| 4043 | if !strings.HasSuffix(outputPath, "/main_test") { |
| 4044 | t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath) |
| 4045 | } |
| 4046 | entries := android.AndroidMkEntriesForTest(t, config, "", module)[0] |
| 4047 | if !strings.HasSuffix(entries.EntryMap["LOCAL_TEST_DATA"][0], ":test_lib.so:foo/bar/baz") { |
| 4048 | t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+ |
| 4049 | " but was '%s'", entries.EntryMap["LOCAL_TEST_DATA"][0]) |
| 4050 | } |
| 4051 | } |
| 4052 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4053 | func TestVersionedStubs(t *testing.T) { |
| 4054 | ctx := testCc(t, ` |
| 4055 | cc_library_shared { |
| 4056 | name: "libFoo", |
Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4057 | srcs: ["foo.c"], |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4058 | stubs: { |
| 4059 | symbol_file: "foo.map.txt", |
| 4060 | versions: ["1", "2", "3"], |
| 4061 | }, |
| 4062 | } |
Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4063 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4064 | cc_library_shared { |
| 4065 | name: "libBar", |
Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4066 | srcs: ["bar.c"], |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4067 | shared_libs: ["libFoo#1"], |
| 4068 | }`) |
| 4069 | |
| 4070 | variants := ctx.ModuleVariantsForTests("libFoo") |
| 4071 | expectedVariants := []string{ |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4072 | "android_arm64_armv8-a_shared", |
| 4073 | "android_arm64_armv8-a_shared_1", |
| 4074 | "android_arm64_armv8-a_shared_2", |
| 4075 | "android_arm64_armv8-a_shared_3", |
| 4076 | "android_arm_armv7-a-neon_shared", |
| 4077 | "android_arm_armv7-a-neon_shared_1", |
| 4078 | "android_arm_armv7-a-neon_shared_2", |
| 4079 | "android_arm_armv7-a-neon_shared_3", |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4080 | } |
| 4081 | variantsMismatch := false |
| 4082 | if len(variants) != len(expectedVariants) { |
| 4083 | variantsMismatch = true |
| 4084 | } else { |
| 4085 | for _, v := range expectedVariants { |
| 4086 | if !inList(v, variants) { |
| 4087 | variantsMismatch = false |
| 4088 | } |
| 4089 | } |
| 4090 | } |
| 4091 | if variantsMismatch { |
| 4092 | t.Errorf("variants of libFoo expected:\n") |
| 4093 | for _, v := range expectedVariants { |
| 4094 | t.Errorf("%q\n", v) |
| 4095 | } |
| 4096 | t.Errorf(", but got:\n") |
| 4097 | for _, v := range variants { |
| 4098 | t.Errorf("%q\n", v) |
| 4099 | } |
| 4100 | } |
| 4101 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4102 | libBarLinkRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("ld") |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4103 | libFlags := libBarLinkRule.Args["libFlags"] |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4104 | libFoo1StubPath := "libFoo/android_arm64_armv8-a_shared_1/libFoo.so" |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 4105 | if !strings.Contains(libFlags, libFoo1StubPath) { |
| 4106 | t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags) |
| 4107 | } |
Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4108 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4109 | libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_shared").Rule("cc") |
Jiyong Park | da732bd | 2018-11-02 18:23:15 +0900 | [diff] [blame] | 4110 | cFlags := libBarCompileRule.Args["cFlags"] |
| 4111 | libFoo1VersioningMacro := "-D__LIBFOO_API__=1" |
| 4112 | if !strings.Contains(cFlags, libFoo1VersioningMacro) { |
| 4113 | t.Errorf("%q is not found in %q", libFoo1VersioningMacro, cFlags) |
| 4114 | } |
Jiyong Park | 37b2520 | 2018-07-11 10:49:27 +0900 | [diff] [blame] | 4115 | } |
Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4116 | |
Jooyung Han | b04a499 | 2020-03-13 18:57:35 +0900 | [diff] [blame] | 4117 | func TestVersioningMacro(t *testing.T) { |
| 4118 | for _, tc := range []struct{ moduleName, expected string }{ |
| 4119 | {"libc", "__LIBC_API__"}, |
| 4120 | {"libfoo", "__LIBFOO_API__"}, |
| 4121 | {"libfoo@1", "__LIBFOO_1_API__"}, |
| 4122 | {"libfoo-v1", "__LIBFOO_V1_API__"}, |
| 4123 | {"libfoo.v1", "__LIBFOO_V1_API__"}, |
| 4124 | } { |
| 4125 | checkEquals(t, tc.moduleName, tc.expected, versioningMacroName(tc.moduleName)) |
| 4126 | } |
| 4127 | } |
| 4128 | |
Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4129 | func TestStaticExecutable(t *testing.T) { |
| 4130 | ctx := testCc(t, ` |
| 4131 | cc_binary { |
| 4132 | name: "static_test", |
Pete Bentley | fcf55bf | 2019-08-16 20:14:32 +0100 | [diff] [blame] | 4133 | srcs: ["foo.c", "baz.o"], |
Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4134 | static_executable: true, |
| 4135 | }`) |
| 4136 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4137 | variant := "android_arm64_armv8-a" |
Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4138 | binModuleRule := ctx.ModuleForTests("static_test", variant).Rule("ld") |
| 4139 | libFlags := binModuleRule.Args["libFlags"] |
Ryan Prichard | b49fe1b | 2019-10-11 15:03:34 -0700 | [diff] [blame] | 4140 | systemStaticLibs := []string{"libc.a", "libm.a"} |
Jaewoong Jung | 232c07c | 2018-12-18 11:08:25 -0800 | [diff] [blame] | 4141 | for _, lib := range systemStaticLibs { |
| 4142 | if !strings.Contains(libFlags, lib) { |
| 4143 | t.Errorf("Static lib %q was not found in %q", lib, libFlags) |
| 4144 | } |
| 4145 | } |
| 4146 | systemSharedLibs := []string{"libc.so", "libm.so", "libdl.so"} |
| 4147 | for _, lib := range systemSharedLibs { |
| 4148 | if strings.Contains(libFlags, lib) { |
| 4149 | t.Errorf("Shared lib %q was found in %q", lib, libFlags) |
| 4150 | } |
| 4151 | } |
| 4152 | } |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4153 | |
| 4154 | func TestStaticDepsOrderWithStubs(t *testing.T) { |
| 4155 | ctx := testCc(t, ` |
| 4156 | cc_binary { |
| 4157 | name: "mybin", |
| 4158 | srcs: ["foo.c"], |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 4159 | static_libs: ["libfooC", "libfooB"], |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4160 | static_executable: true, |
| 4161 | stl: "none", |
| 4162 | } |
| 4163 | |
| 4164 | cc_library { |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4165 | name: "libfooB", |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4166 | srcs: ["foo.c"], |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4167 | shared_libs: ["libfooC"], |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4168 | stl: "none", |
| 4169 | } |
| 4170 | |
| 4171 | cc_library { |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4172 | name: "libfooC", |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4173 | srcs: ["foo.c"], |
| 4174 | stl: "none", |
| 4175 | stubs: { |
| 4176 | versions: ["1"], |
| 4177 | }, |
| 4178 | }`) |
| 4179 | |
Colin Cross | 0de8a1e | 2020-09-18 14:15:30 -0700 | [diff] [blame] | 4180 | mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a").Rule("ld") |
| 4181 | actual := mybin.Implicits[:2] |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 4182 | expected := getOutputPaths(ctx, "android_arm64_armv8-a_static", []string{"libfooB", "libfooC"}) |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 4183 | |
| 4184 | if !reflect.DeepEqual(actual, expected) { |
| 4185 | t.Errorf("staticDeps orderings were not propagated correctly"+ |
| 4186 | "\nactual: %v"+ |
| 4187 | "\nexpected: %v", |
| 4188 | actual, |
| 4189 | expected, |
| 4190 | ) |
| 4191 | } |
| 4192 | } |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 4193 | |
Jooyung Han | d48f3c3 | 2019-08-23 11:18:57 +0900 | [diff] [blame] | 4194 | func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) { |
| 4195 | testCcError(t, `module "libA" .* depends on disabled module "libB"`, ` |
| 4196 | cc_library { |
| 4197 | name: "libA", |
| 4198 | srcs: ["foo.c"], |
| 4199 | shared_libs: ["libB"], |
| 4200 | stl: "none", |
| 4201 | } |
| 4202 | |
| 4203 | cc_library { |
| 4204 | name: "libB", |
| 4205 | srcs: ["foo.c"], |
| 4206 | enabled: false, |
| 4207 | stl: "none", |
| 4208 | } |
| 4209 | `) |
| 4210 | } |
| 4211 | |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 4212 | // Simple smoke test for the cc_fuzz target that ensures the rule compiles |
| 4213 | // correctly. |
| 4214 | func TestFuzzTarget(t *testing.T) { |
| 4215 | ctx := testCc(t, ` |
| 4216 | cc_fuzz { |
| 4217 | name: "fuzz_smoke_test", |
| 4218 | srcs: ["foo.c"], |
| 4219 | }`) |
| 4220 | |
Paul Duffin | 075c417 | 2019-12-19 19:06:13 +0000 | [diff] [blame] | 4221 | variant := "android_arm64_armv8-a_fuzzer" |
Mitch Phillips | da9a463 | 2019-07-15 09:34:09 -0700 | [diff] [blame] | 4222 | ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc") |
| 4223 | } |
| 4224 | |
Jiyong Park | 2907459 | 2019-07-07 16:27:47 +0900 | [diff] [blame] | 4225 | func TestAidl(t *testing.T) { |
| 4226 | } |
| 4227 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 4228 | func assertString(t *testing.T, got, expected string) { |
| 4229 | t.Helper() |
| 4230 | if got != expected { |
| 4231 | t.Errorf("expected %q got %q", expected, got) |
| 4232 | } |
| 4233 | } |
| 4234 | |
| 4235 | func assertArrayString(t *testing.T, got, expected []string) { |
| 4236 | t.Helper() |
| 4237 | if len(got) != len(expected) { |
| 4238 | t.Errorf("expected %d (%q) got (%d) %q", len(expected), expected, len(got), got) |
| 4239 | return |
| 4240 | } |
| 4241 | for i := range got { |
| 4242 | if got[i] != expected[i] { |
| 4243 | t.Errorf("expected %d-th %q (%q) got %q (%q)", |
| 4244 | i, expected[i], expected, got[i], got) |
| 4245 | return |
| 4246 | } |
| 4247 | } |
| 4248 | } |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4249 | |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 4250 | func assertMapKeys(t *testing.T, m map[string]string, expected []string) { |
| 4251 | t.Helper() |
| 4252 | assertArrayString(t, android.SortedStringKeys(m), expected) |
| 4253 | } |
| 4254 | |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4255 | func TestDefaults(t *testing.T) { |
| 4256 | ctx := testCc(t, ` |
| 4257 | cc_defaults { |
| 4258 | name: "defaults", |
| 4259 | srcs: ["foo.c"], |
| 4260 | static: { |
| 4261 | srcs: ["bar.c"], |
| 4262 | }, |
| 4263 | shared: { |
| 4264 | srcs: ["baz.c"], |
| 4265 | }, |
| 4266 | } |
| 4267 | |
| 4268 | cc_library_static { |
| 4269 | name: "libstatic", |
| 4270 | defaults: ["defaults"], |
| 4271 | } |
| 4272 | |
| 4273 | cc_library_shared { |
| 4274 | name: "libshared", |
| 4275 | defaults: ["defaults"], |
| 4276 | } |
| 4277 | |
| 4278 | cc_library { |
| 4279 | name: "libboth", |
| 4280 | defaults: ["defaults"], |
| 4281 | } |
| 4282 | |
| 4283 | cc_binary { |
| 4284 | name: "binary", |
| 4285 | defaults: ["defaults"], |
| 4286 | }`) |
| 4287 | |
| 4288 | pathsToBase := func(paths android.Paths) []string { |
| 4289 | var ret []string |
| 4290 | for _, p := range paths { |
| 4291 | ret = append(ret, p.Base()) |
| 4292 | } |
| 4293 | return ret |
| 4294 | } |
| 4295 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4296 | shared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Rule("ld") |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4297 | if g, w := pathsToBase(shared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) { |
| 4298 | t.Errorf("libshared ld rule wanted %q, got %q", w, g) |
| 4299 | } |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4300 | bothShared := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_shared").Rule("ld") |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4301 | if g, w := pathsToBase(bothShared.Inputs), []string{"foo.o", "baz.o"}; !reflect.DeepEqual(w, g) { |
| 4302 | t.Errorf("libboth ld rule wanted %q, got %q", w, g) |
| 4303 | } |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4304 | binary := ctx.ModuleForTests("binary", "android_arm64_armv8-a").Rule("ld") |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4305 | if g, w := pathsToBase(binary.Inputs), []string{"foo.o"}; !reflect.DeepEqual(w, g) { |
| 4306 | t.Errorf("binary ld rule wanted %q, got %q", w, g) |
| 4307 | } |
| 4308 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4309 | static := ctx.ModuleForTests("libstatic", "android_arm64_armv8-a_static").Rule("ar") |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4310 | if g, w := pathsToBase(static.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) { |
| 4311 | t.Errorf("libstatic ar rule wanted %q, got %q", w, g) |
| 4312 | } |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 4313 | bothStatic := ctx.ModuleForTests("libboth", "android_arm64_armv8-a_static").Rule("ar") |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 4314 | if g, w := pathsToBase(bothStatic.Inputs), []string{"foo.o", "bar.o"}; !reflect.DeepEqual(w, g) { |
| 4315 | t.Errorf("libboth ar rule wanted %q, got %q", w, g) |
| 4316 | } |
| 4317 | } |
Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4318 | |
| 4319 | func TestProductVariableDefaults(t *testing.T) { |
| 4320 | bp := ` |
| 4321 | cc_defaults { |
| 4322 | name: "libfoo_defaults", |
| 4323 | srcs: ["foo.c"], |
| 4324 | cppflags: ["-DFOO"], |
| 4325 | product_variables: { |
| 4326 | debuggable: { |
| 4327 | cppflags: ["-DBAR"], |
| 4328 | }, |
| 4329 | }, |
| 4330 | } |
| 4331 | |
| 4332 | cc_library { |
| 4333 | name: "libfoo", |
| 4334 | defaults: ["libfoo_defaults"], |
| 4335 | } |
| 4336 | ` |
| 4337 | |
| 4338 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4339 | config.TestProductVariables.Debuggable = BoolPtr(true) |
| 4340 | |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4341 | ctx := CreateTestContext(config) |
Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4342 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 4343 | ctx.BottomUp("variable", android.VariableMutator).Parallel() |
| 4344 | }) |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4345 | ctx.Register() |
Colin Cross | eabaedd | 2020-02-06 17:01:55 -0800 | [diff] [blame] | 4346 | |
| 4347 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 4348 | android.FailIfErrored(t, errs) |
| 4349 | _, errs = ctx.PrepareBuildActions(config) |
| 4350 | android.FailIfErrored(t, errs) |
| 4351 | |
| 4352 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Module().(*Module) |
| 4353 | if !android.InList("-DBAR", libfoo.flags.Local.CppFlags) { |
| 4354 | t.Errorf("expected -DBAR in cppflags, got %q", libfoo.flags.Local.CppFlags) |
| 4355 | } |
| 4356 | } |
Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4357 | |
| 4358 | func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) { |
| 4359 | t.Parallel() |
| 4360 | bp := ` |
| 4361 | cc_library_static { |
| 4362 | name: "libfoo", |
| 4363 | srcs: ["foo.c"], |
| 4364 | whole_static_libs: ["libbar"], |
| 4365 | } |
| 4366 | |
| 4367 | cc_library_static { |
| 4368 | name: "libbar", |
| 4369 | whole_static_libs: ["libmissing"], |
| 4370 | } |
| 4371 | ` |
| 4372 | |
| 4373 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4374 | config.TestProductVariables.Allow_missing_dependencies = BoolPtr(true) |
| 4375 | |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4376 | ctx := CreateTestContext(config) |
Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4377 | ctx.SetAllowMissingDependencies(true) |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 4378 | ctx.Register() |
Colin Cross | e4f6eba | 2020-09-22 18:11:25 -0700 | [diff] [blame] | 4379 | |
| 4380 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 4381 | android.FailIfErrored(t, errs) |
| 4382 | _, errs = ctx.PrepareBuildActions(config) |
| 4383 | android.FailIfErrored(t, errs) |
| 4384 | |
| 4385 | libbar := ctx.ModuleForTests("libbar", "android_arm64_armv8-a_static").Output("libbar.a") |
| 4386 | if g, w := libbar.Rule, android.ErrorRule; g != w { |
| 4387 | t.Fatalf("Expected libbar rule to be %q, got %q", w, g) |
| 4388 | } |
| 4389 | |
| 4390 | if g, w := libbar.Args["error"], "missing dependencies: libmissing"; !strings.Contains(g, w) { |
| 4391 | t.Errorf("Expected libbar error to contain %q, was %q", w, g) |
| 4392 | } |
| 4393 | |
| 4394 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static").Output("libfoo.a") |
| 4395 | if g, w := libfoo.Inputs.Strings(), libbar.Output.String(); !android.InList(w, g) { |
| 4396 | t.Errorf("Expected libfoo.a to depend on %q, got %q", w, g) |
| 4397 | } |
| 4398 | |
| 4399 | } |
Colin Cross | e9fe294 | 2020-11-10 18:12:15 -0800 | [diff] [blame] | 4400 | |
| 4401 | func TestInstallSharedLibs(t *testing.T) { |
| 4402 | bp := ` |
| 4403 | cc_binary { |
| 4404 | name: "bin", |
| 4405 | host_supported: true, |
| 4406 | shared_libs: ["libshared"], |
| 4407 | runtime_libs: ["libruntime"], |
| 4408 | srcs: [":gen"], |
| 4409 | } |
| 4410 | |
| 4411 | cc_library_shared { |
| 4412 | name: "libshared", |
| 4413 | host_supported: true, |
| 4414 | shared_libs: ["libtransitive"], |
| 4415 | } |
| 4416 | |
| 4417 | cc_library_shared { |
| 4418 | name: "libtransitive", |
| 4419 | host_supported: true, |
| 4420 | } |
| 4421 | |
| 4422 | cc_library_shared { |
| 4423 | name: "libruntime", |
| 4424 | host_supported: true, |
| 4425 | } |
| 4426 | |
| 4427 | cc_binary_host { |
| 4428 | name: "tool", |
| 4429 | srcs: ["foo.cpp"], |
| 4430 | } |
| 4431 | |
| 4432 | genrule { |
| 4433 | name: "gen", |
| 4434 | tools: ["tool"], |
| 4435 | out: ["gen.cpp"], |
| 4436 | cmd: "$(location tool) $(out)", |
| 4437 | } |
| 4438 | ` |
| 4439 | |
| 4440 | config := TestConfig(buildDir, android.Android, nil, bp, nil) |
| 4441 | ctx := testCcWithConfig(t, config) |
| 4442 | |
| 4443 | hostBin := ctx.ModuleForTests("bin", config.BuildOSTarget.String()).Description("install") |
| 4444 | hostShared := ctx.ModuleForTests("libshared", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4445 | hostRuntime := ctx.ModuleForTests("libruntime", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4446 | hostTransitive := ctx.ModuleForTests("libtransitive", config.BuildOSTarget.String()+"_shared").Description("install") |
| 4447 | hostTool := ctx.ModuleForTests("tool", config.BuildOSTarget.String()).Description("install") |
| 4448 | |
| 4449 | if g, w := hostBin.Implicits.Strings(), hostShared.Output.String(); !android.InList(w, g) { |
| 4450 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4451 | } |
| 4452 | |
| 4453 | if g, w := hostBin.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) { |
| 4454 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4455 | } |
| 4456 | |
| 4457 | if g, w := hostShared.Implicits.Strings(), hostTransitive.Output.String(); !android.InList(w, g) { |
| 4458 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4459 | } |
| 4460 | |
| 4461 | if g, w := hostBin.Implicits.Strings(), hostRuntime.Output.String(); !android.InList(w, g) { |
| 4462 | t.Errorf("expected host bin dependency %q, got %q", w, g) |
| 4463 | } |
| 4464 | |
| 4465 | if g, w := hostBin.Implicits.Strings(), hostTool.Output.String(); android.InList(w, g) { |
| 4466 | t.Errorf("expected no host bin dependency %q, got %q", w, g) |
| 4467 | } |
| 4468 | |
| 4469 | deviceBin := ctx.ModuleForTests("bin", "android_arm64_armv8-a").Description("install") |
| 4470 | deviceShared := ctx.ModuleForTests("libshared", "android_arm64_armv8-a_shared").Description("install") |
| 4471 | deviceTransitive := ctx.ModuleForTests("libtransitive", "android_arm64_armv8-a_shared").Description("install") |
| 4472 | deviceRuntime := ctx.ModuleForTests("libruntime", "android_arm64_armv8-a_shared").Description("install") |
| 4473 | |
| 4474 | if g, w := deviceBin.OrderOnly.Strings(), deviceShared.Output.String(); !android.InList(w, g) { |
| 4475 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4476 | } |
| 4477 | |
| 4478 | if g, w := deviceBin.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) { |
| 4479 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4480 | } |
| 4481 | |
| 4482 | if g, w := deviceShared.OrderOnly.Strings(), deviceTransitive.Output.String(); !android.InList(w, g) { |
| 4483 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4484 | } |
| 4485 | |
| 4486 | if g, w := deviceBin.OrderOnly.Strings(), deviceRuntime.Output.String(); !android.InList(w, g) { |
| 4487 | t.Errorf("expected device bin dependency %q, got %q", w, g) |
| 4488 | } |
| 4489 | |
| 4490 | if g, w := deviceBin.OrderOnly.Strings(), hostTool.Output.String(); android.InList(w, g) { |
| 4491 | t.Errorf("expected no device bin dependency %q, got %q", w, g) |
| 4492 | } |
| 4493 | |
| 4494 | } |
Jiyong Park | 1ad8e16 | 2020-12-01 23:40:09 +0900 | [diff] [blame] | 4495 | |
| 4496 | func TestStubsLibReexportsHeaders(t *testing.T) { |
| 4497 | ctx := testCc(t, ` |
| 4498 | cc_library_shared { |
| 4499 | name: "libclient", |
| 4500 | srcs: ["foo.c"], |
| 4501 | shared_libs: ["libfoo#1"], |
| 4502 | } |
| 4503 | |
| 4504 | cc_library_shared { |
| 4505 | name: "libfoo", |
| 4506 | srcs: ["foo.c"], |
| 4507 | shared_libs: ["libbar"], |
| 4508 | export_shared_lib_headers: ["libbar"], |
| 4509 | stubs: { |
| 4510 | symbol_file: "foo.map.txt", |
| 4511 | versions: ["1", "2", "3"], |
| 4512 | }, |
| 4513 | } |
| 4514 | |
| 4515 | cc_library_shared { |
| 4516 | name: "libbar", |
| 4517 | export_include_dirs: ["include/libbar"], |
| 4518 | srcs: ["foo.c"], |
| 4519 | }`) |
| 4520 | |
| 4521 | cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"] |
| 4522 | |
| 4523 | if !strings.Contains(cFlags, "-Iinclude/libbar") { |
| 4524 | t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags) |
| 4525 | } |
| 4526 | } |
Jooyung Han | e197d8b | 2021-01-05 10:33:16 +0900 | [diff] [blame] | 4527 | |
| 4528 | func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) { |
| 4529 | ctx := testCc(t, ` |
| 4530 | cc_library { |
| 4531 | name: "libfoo", |
| 4532 | srcs: ["a/Foo.aidl"], |
| 4533 | aidl: { flags: ["-Werror"], }, |
| 4534 | } |
| 4535 | `) |
| 4536 | |
| 4537 | libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static") |
| 4538 | manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto")) |
| 4539 | aidlCommand := manifest.Commands[0].GetCommand() |
| 4540 | expectedAidlFlag := "-Werror" |
| 4541 | if !strings.Contains(aidlCommand, expectedAidlFlag) { |
| 4542 | t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) |
| 4543 | } |
| 4544 | } |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4545 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4546 | type MemtagNoteType int |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4547 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4548 | const ( |
| 4549 | None MemtagNoteType = iota + 1 |
| 4550 | Sync |
| 4551 | Async |
| 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 | func (t MemtagNoteType) str() string { |
| 4555 | switch t { |
| 4556 | case None: |
| 4557 | return "none" |
| 4558 | case Sync: |
| 4559 | return "sync" |
| 4560 | case Async: |
| 4561 | return "async" |
| 4562 | default: |
| 4563 | panic("invalid note type") |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4564 | } |
| 4565 | } |
| 4566 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4567 | func checkHasMemtagNote(t *testing.T, m android.TestingModule, expected MemtagNoteType) { |
| 4568 | note_async := "note_memtag_heap_async" |
| 4569 | note_sync := "note_memtag_heap_sync" |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4570 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4571 | found := None |
| 4572 | implicits := m.Rule("ld").Implicits |
| 4573 | for _, lib := range implicits { |
| 4574 | if strings.Contains(lib.Rel(), note_async) { |
| 4575 | found = Async |
| 4576 | break |
| 4577 | } else if strings.Contains(lib.Rel(), note_sync) { |
| 4578 | found = Sync |
| 4579 | break |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4580 | } |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4581 | } |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4582 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4583 | if found != expected { |
| 4584 | t.Errorf("Wrong Memtag note in target %q: found %q, expected %q", m.Module().(*Module).Name(), found.str(), expected.str()) |
| 4585 | } |
| 4586 | } |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4587 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4588 | func makeMemtagTestConfig(t *testing.T) android.Config { |
| 4589 | templateBp := ` |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4590 | cc_test { |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4591 | name: "%[1]s_test", |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4592 | gtest: false, |
| 4593 | } |
| 4594 | |
| 4595 | cc_test { |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4596 | name: "%[1]s_test_false", |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4597 | gtest: false, |
| 4598 | sanitize: { memtag_heap: false }, |
| 4599 | } |
| 4600 | |
| 4601 | cc_test { |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4602 | name: "%[1]s_test_true", |
| 4603 | gtest: false, |
| 4604 | sanitize: { memtag_heap: true }, |
| 4605 | } |
| 4606 | |
| 4607 | cc_test { |
| 4608 | name: "%[1]s_test_true_nodiag", |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4609 | gtest: false, |
| 4610 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 4611 | } |
| 4612 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4613 | cc_test { |
| 4614 | name: "%[1]s_test_true_diag", |
| 4615 | gtest: false, |
| 4616 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
| 4617 | } |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4618 | |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4619 | cc_binary { |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4620 | name: "%[1]s_binary", |
| 4621 | } |
| 4622 | |
| 4623 | cc_binary { |
| 4624 | name: "%[1]s_binary_false", |
| 4625 | sanitize: { memtag_heap: false }, |
| 4626 | } |
| 4627 | |
| 4628 | cc_binary { |
| 4629 | name: "%[1]s_binary_true", |
| 4630 | sanitize: { memtag_heap: true }, |
| 4631 | } |
| 4632 | |
| 4633 | cc_binary { |
| 4634 | name: "%[1]s_binary_true_nodiag", |
| 4635 | sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, |
| 4636 | } |
| 4637 | |
| 4638 | cc_binary { |
| 4639 | name: "%[1]s_binary_true_diag", |
| 4640 | sanitize: { memtag_heap: true, diag: { memtag_heap: true } }, |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4641 | } |
| 4642 | ` |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4643 | subdirDefaultBp := fmt.Sprintf(templateBp, "default") |
| 4644 | subdirExcludeBp := fmt.Sprintf(templateBp, "exclude") |
| 4645 | subdirSyncBp := fmt.Sprintf(templateBp, "sync") |
| 4646 | subdirAsyncBp := fmt.Sprintf(templateBp, "async") |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4647 | |
| 4648 | mockFS := map[string][]byte{ |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4649 | "subdir_default/Android.bp": []byte(subdirDefaultBp), |
| 4650 | "subdir_exclude/Android.bp": []byte(subdirExcludeBp), |
| 4651 | "subdir_sync/Android.bp": []byte(subdirSyncBp), |
| 4652 | "subdir_async/Android.bp": []byte(subdirAsyncBp), |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4653 | } |
| 4654 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4655 | return TestConfig(buildDir, android.Android, nil, "", mockFS) |
| 4656 | } |
| 4657 | |
| 4658 | func TestSanitizeMemtagHeap(t *testing.T) { |
| 4659 | variant := "android_arm64_armv8-a" |
| 4660 | |
| 4661 | config := makeMemtagTestConfig(t) |
| 4662 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4663 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4664 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4665 | ctx := CreateTestContext(config) |
| 4666 | ctx.Register() |
| 4667 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4668 | _, 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] | 4669 | android.FailIfErrored(t, errs) |
| 4670 | _, errs = ctx.PrepareBuildActions(config) |
| 4671 | android.FailIfErrored(t, errs) |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4672 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4673 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4674 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4675 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 4676 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4677 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 4678 | |
| 4679 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), None) |
| 4680 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4681 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 4682 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4683 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4684 | |
| 4685 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4686 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4687 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 4688 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4689 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4690 | |
| 4691 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4692 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4693 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 4694 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4695 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4696 | |
| 4697 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4698 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4699 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 4700 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4701 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4702 | |
| 4703 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 4704 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4705 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 4706 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4707 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4708 | |
| 4709 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4710 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4711 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4712 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4713 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4714 | |
| 4715 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4716 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4717 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4718 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4719 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 4720 | } |
| 4721 | |
| 4722 | func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) { |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4723 | variant := "android_arm64_armv8-a" |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4724 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4725 | config := makeMemtagTestConfig(t) |
| 4726 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| 4727 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
| 4728 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
| 4729 | config.TestProductVariables.SanitizeDevice = []string{"memtag_heap"} |
| 4730 | ctx := CreateTestContext(config) |
| 4731 | ctx.Register() |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4732 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4733 | _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_default/Android.bp", "subdir_exclude/Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) |
| 4734 | android.FailIfErrored(t, errs) |
| 4735 | _, errs = ctx.PrepareBuildActions(config) |
| 4736 | android.FailIfErrored(t, errs) |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4737 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4738 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4739 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4740 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async) |
| 4741 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4742 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
Evgenii Stepanov | 4beaa0c | 2021-01-05 16:41:26 -0800 | [diff] [blame] | 4743 | |
Evgenii Stepanov | 04896ca | 2021-01-12 18:28:33 -0800 | [diff] [blame^] | 4744 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Async) |
| 4745 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4746 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async) |
| 4747 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4748 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4749 | |
| 4750 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4751 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4752 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async) |
| 4753 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4754 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4755 | |
| 4756 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4757 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4758 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async) |
| 4759 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4760 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4761 | |
| 4762 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4763 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4764 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async) |
| 4765 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4766 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4767 | |
| 4768 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async) |
| 4769 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4770 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async) |
| 4771 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4772 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4773 | |
| 4774 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4775 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4776 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4777 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4778 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4779 | |
| 4780 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4781 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4782 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4783 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4784 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
| 4785 | } |
| 4786 | |
| 4787 | func TestSanitizeMemtagHeapWithSanitizeDeviceDiag(t *testing.T) { |
| 4788 | variant := "android_arm64_armv8-a" |
| 4789 | |
| 4790 | config := makeMemtagTestConfig(t) |
| 4791 | config.TestProductVariables.MemtagHeapExcludePaths = []string{"subdir_exclude"} |
| 4792 | config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} |
| 4793 | config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} |
| 4794 | config.TestProductVariables.SanitizeDevice = []string{"memtag_heap"} |
| 4795 | config.TestProductVariables.SanitizeDeviceDiag = []string{"memtag_heap"} |
| 4796 | ctx := CreateTestContext(config) |
| 4797 | ctx.Register() |
| 4798 | |
| 4799 | _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_default/Android.bp", "subdir_exclude/Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) |
| 4800 | android.FailIfErrored(t, errs) |
| 4801 | _, errs = ctx.PrepareBuildActions(config) |
| 4802 | android.FailIfErrored(t, errs) |
| 4803 | |
| 4804 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync) |
| 4805 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None) |
| 4806 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Sync) |
| 4807 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async) |
| 4808 | checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync) |
| 4809 | |
| 4810 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Sync) |
| 4811 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None) |
| 4812 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Sync) |
| 4813 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async) |
| 4814 | checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync) |
| 4815 | |
| 4816 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync) |
| 4817 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None) |
| 4818 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Sync) |
| 4819 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async) |
| 4820 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync) |
| 4821 | |
| 4822 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None) |
| 4823 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None) |
| 4824 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Sync) |
| 4825 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async) |
| 4826 | checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync) |
| 4827 | |
| 4828 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync) |
| 4829 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None) |
| 4830 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Sync) |
| 4831 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async) |
| 4832 | checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync) |
| 4833 | |
| 4834 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Sync) |
| 4835 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None) |
| 4836 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Sync) |
| 4837 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async) |
| 4838 | checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync) |
| 4839 | |
| 4840 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync) |
| 4841 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None) |
| 4842 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync) |
| 4843 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async) |
| 4844 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync) |
| 4845 | |
| 4846 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync) |
| 4847 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None) |
| 4848 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync) |
| 4849 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async) |
| 4850 | checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync) |
Evgenii Stepanov | 193ac2e | 2020-04-28 15:09:12 -0700 | [diff] [blame] | 4851 | } |