Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 1 | // Copyright 2018 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 15 | package etc |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 16 | |
| 17 | import ( |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 18 | "io/ioutil" |
| 19 | "os" |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 20 | "path/filepath" |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 21 | "reflect" |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 22 | "testing" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 23 | |
| 24 | "android/soong/android" |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 25 | ) |
| 26 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 27 | var buildDir string |
| 28 | |
| 29 | func setUp() { |
| 30 | var err error |
| 31 | buildDir, err = ioutil.TempDir("", "soong_etc_test") |
| 32 | if err != nil { |
| 33 | panic(err) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func tearDown() { |
| 38 | os.RemoveAll(buildDir) |
| 39 | } |
| 40 | |
| 41 | func TestMain(m *testing.M) { |
| 42 | run := func() int { |
| 43 | setUp() |
| 44 | defer tearDown() |
| 45 | |
| 46 | return m.Run() |
| 47 | } |
| 48 | |
| 49 | os.Exit(run()) |
| 50 | } |
| 51 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 52 | func testPrebuiltEtcContext(t *testing.T, bp string) (*android.TestContext, android.Config) { |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 53 | fs := map[string][]byte{ |
| 54 | "foo.conf": nil, |
| 55 | "bar.conf": nil, |
| 56 | "baz.conf": nil, |
| 57 | } |
| 58 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 59 | config := android.TestArchConfig(buildDir, nil, bp, fs) |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 60 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 61 | ctx := android.NewTestArchContext() |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 62 | ctx.RegisterModuleType("prebuilt_etc", PrebuiltEtcFactory) |
| 63 | ctx.RegisterModuleType("prebuilt_etc_host", PrebuiltEtcHostFactory) |
| 64 | ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) |
| 65 | ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory) |
| 66 | ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory) |
| 67 | ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 68 | ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 69 | ctx.Register(config) |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 70 | |
| 71 | return ctx, config |
| 72 | } |
| 73 | |
| 74 | func testPrebuiltEtc(t *testing.T, bp string) (*android.TestContext, android.Config) { |
| 75 | t.Helper() |
| 76 | |
| 77 | ctx, config := testPrebuiltEtcContext(t, bp) |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 78 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 79 | android.FailIfErrored(t, errs) |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 80 | _, errs = ctx.PrepareBuildActions(config) |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 81 | android.FailIfErrored(t, errs) |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 82 | |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 83 | return ctx, config |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 86 | func testPrebuiltEtcError(t *testing.T, pattern, bp string) { |
| 87 | t.Helper() |
| 88 | |
| 89 | ctx, config := testPrebuiltEtcContext(t, bp) |
| 90 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
| 91 | if len(errs) > 0 { |
| 92 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 93 | return |
| 94 | } |
| 95 | |
| 96 | _, errs = ctx.PrepareBuildActions(config) |
| 97 | if len(errs) > 0 { |
| 98 | android.FailIfNoMatchingErrors(t, pattern, errs) |
| 99 | return |
| 100 | } |
| 101 | |
| 102 | t.Fatalf("missing expected error %q (0 errors are returned)", pattern) |
| 103 | } |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 104 | func TestPrebuiltEtcVariants(t *testing.T) { |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 105 | ctx, _ := testPrebuiltEtc(t, ` |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 106 | prebuilt_etc { |
| 107 | name: "foo.conf", |
| 108 | src: "foo.conf", |
| 109 | } |
| 110 | prebuilt_etc { |
| 111 | name: "bar.conf", |
| 112 | src: "bar.conf", |
| 113 | recovery_available: true, |
| 114 | } |
| 115 | prebuilt_etc { |
| 116 | name: "baz.conf", |
| 117 | src: "baz.conf", |
| 118 | recovery: true, |
| 119 | } |
| 120 | `) |
| 121 | |
| 122 | foo_variants := ctx.ModuleVariantsForTests("foo.conf") |
| 123 | if len(foo_variants) != 1 { |
| 124 | t.Errorf("expected 1, got %#v", foo_variants) |
| 125 | } |
| 126 | |
| 127 | bar_variants := ctx.ModuleVariantsForTests("bar.conf") |
| 128 | if len(bar_variants) != 2 { |
| 129 | t.Errorf("expected 2, got %#v", bar_variants) |
| 130 | } |
| 131 | |
| 132 | baz_variants := ctx.ModuleVariantsForTests("baz.conf") |
| 133 | if len(baz_variants) != 1 { |
| 134 | t.Errorf("expected 1, got %#v", bar_variants) |
| 135 | } |
| 136 | } |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 137 | |
| 138 | func TestPrebuiltEtcOutputPath(t *testing.T) { |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 139 | ctx, _ := testPrebuiltEtc(t, ` |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 140 | prebuilt_etc { |
| 141 | name: "foo.conf", |
| 142 | src: "foo.conf", |
| 143 | filename: "foo.installed.conf", |
| 144 | } |
| 145 | `) |
| 146 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 147 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 148 | if p.outputFilePath.Base() != "foo.installed.conf" { |
| 149 | t.Errorf("expected foo.installed.conf, got %q", p.outputFilePath.Base()) |
| 150 | } |
| 151 | } |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 152 | |
| 153 | func TestPrebuiltEtcGlob(t *testing.T) { |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 154 | ctx, _ := testPrebuiltEtc(t, ` |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 155 | prebuilt_etc { |
| 156 | name: "my_foo", |
| 157 | src: "foo.*", |
| 158 | } |
| 159 | prebuilt_etc { |
| 160 | name: "my_bar", |
| 161 | src: "bar.*", |
| 162 | filename_from_src: true, |
| 163 | } |
| 164 | `) |
| 165 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 166 | p := ctx.ModuleForTests("my_foo", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 167 | if p.outputFilePath.Base() != "my_foo" { |
| 168 | t.Errorf("expected my_foo, got %q", p.outputFilePath.Base()) |
| 169 | } |
| 170 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 171 | p = ctx.ModuleForTests("my_bar", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 172 | if p.outputFilePath.Base() != "bar.conf" { |
| 173 | t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base()) |
| 174 | } |
| 175 | } |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 176 | |
| 177 | func TestPrebuiltEtcAndroidMk(t *testing.T) { |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 178 | ctx, config := testPrebuiltEtc(t, ` |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 179 | prebuilt_etc { |
| 180 | name: "foo", |
| 181 | src: "foo.conf", |
| 182 | owner: "abc", |
| 183 | filename_from_src: true, |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 184 | required: ["modA", "moduleB"], |
| 185 | host_required: ["hostModA", "hostModB"], |
| 186 | target_required: ["targetModA"], |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 187 | } |
| 188 | `) |
| 189 | |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 190 | expected := map[string][]string{ |
| 191 | "LOCAL_MODULE": {"foo"}, |
| 192 | "LOCAL_MODULE_CLASS": {"ETC"}, |
| 193 | "LOCAL_MODULE_OWNER": {"abc"}, |
| 194 | "LOCAL_INSTALLED_MODULE_STEM": {"foo.conf"}, |
| 195 | "LOCAL_REQUIRED_MODULES": {"modA", "moduleB"}, |
| 196 | "LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"}, |
| 197 | "LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"}, |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 200 | mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 201 | entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0] |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 202 | for k, expectedValue := range expected { |
| 203 | if value, ok := entries.EntryMap[k]; ok { |
| 204 | if !reflect.DeepEqual(value, expectedValue) { |
| 205 | t.Errorf("Incorrect %s '%s', expected '%s'", k, value, expectedValue) |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 206 | } |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 207 | } else { |
| 208 | t.Errorf("No %s defined, saw %q", k, entries.EntryMap) |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | } |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 212 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 213 | func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) { |
| 214 | ctx, _ := testPrebuiltEtc(t, ` |
| 215 | prebuilt_etc { |
| 216 | name: "foo.conf", |
| 217 | src: "foo.conf", |
| 218 | relative_install_path: "bar", |
| 219 | } |
| 220 | `) |
| 221 | |
| 222 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
| 223 | expected := buildDir + "/target/product/test_device/system/etc/bar" |
| 224 | if p.installDirPath.String() != expected { |
| 225 | t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) { |
| 230 | testPrebuiltEtcError(t, "relative_install_path is set. Cannot set sub_dir", ` |
| 231 | prebuilt_etc { |
| 232 | name: "foo.conf", |
| 233 | src: "foo.conf", |
| 234 | sub_dir: "bar", |
| 235 | relative_install_path: "bar", |
| 236 | } |
| 237 | `) |
| 238 | } |
| 239 | |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 240 | func TestPrebuiltEtcHost(t *testing.T) { |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 241 | ctx, _ := testPrebuiltEtc(t, ` |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 242 | prebuilt_etc_host { |
| 243 | name: "foo.conf", |
| 244 | src: "foo.conf", |
| 245 | } |
| 246 | `) |
| 247 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 248 | buildOS := android.BuildOs.String() |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 249 | p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc) |
| 250 | if !p.Host() { |
| 251 | t.Errorf("host bit is not set for a prebuilt_etc_host module.") |
| 252 | } |
| 253 | } |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 254 | |
| 255 | func TestPrebuiltUserShareInstallDirPath(t *testing.T) { |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 256 | ctx, _ := testPrebuiltEtc(t, ` |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 257 | prebuilt_usr_share { |
| 258 | name: "foo.conf", |
| 259 | src: "foo.conf", |
| 260 | sub_dir: "bar", |
| 261 | } |
| 262 | `) |
| 263 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 264 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 265 | expected := buildDir + "/target/product/test_device/system/usr/share/bar" |
| 266 | if p.installDirPath.String() != expected { |
| 267 | t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 268 | } |
| 269 | } |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 270 | |
| 271 | func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) { |
| 272 | ctx, config := testPrebuiltEtc(t, ` |
| 273 | prebuilt_usr_share_host { |
| 274 | name: "foo.conf", |
| 275 | src: "foo.conf", |
| 276 | sub_dir: "bar", |
| 277 | } |
| 278 | `) |
| 279 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 280 | buildOS := android.BuildOs.String() |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 281 | p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 282 | expected := filepath.Join(buildDir, "host", config.PrebuiltOS(), "usr", "share", "bar") |
| 283 | if p.installDirPath.String() != expected { |
| 284 | t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 285 | } |
| 286 | } |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 287 | |
| 288 | func TestPrebuiltFontInstallDirPath(t *testing.T) { |
| 289 | ctx, _ := testPrebuiltEtc(t, ` |
| 290 | prebuilt_font { |
| 291 | name: "foo.conf", |
| 292 | src: "foo.conf", |
| 293 | } |
| 294 | `) |
| 295 | |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 296 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 297 | expected := buildDir + "/target/product/test_device/system/fonts" |
| 298 | if p.installDirPath.String() != expected { |
| 299 | t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 300 | } |
| 301 | } |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 302 | |
| 303 | func TestPrebuiltFirmwareDirPath(t *testing.T) { |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 304 | targetPath := buildDir + "/target/product/test_device" |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 305 | tests := []struct { |
| 306 | description string |
| 307 | config string |
| 308 | expectedPath string |
| 309 | }{{ |
| 310 | description: "prebuilt: system firmware", |
| 311 | config: ` |
| 312 | prebuilt_firmware { |
| 313 | name: "foo.conf", |
| 314 | src: "foo.conf", |
| 315 | }`, |
| 316 | expectedPath: filepath.Join(targetPath, "system/etc/firmware"), |
| 317 | }, { |
| 318 | description: "prebuilt: vendor firmware", |
| 319 | config: ` |
| 320 | prebuilt_firmware { |
| 321 | name: "foo.conf", |
| 322 | src: "foo.conf", |
| 323 | soc_specific: true, |
| 324 | sub_dir: "sub_dir", |
| 325 | }`, |
| 326 | expectedPath: filepath.Join(targetPath, "vendor/firmware/sub_dir"), |
| 327 | }} |
| 328 | for _, tt := range tests { |
| 329 | t.Run(tt.description, func(t *testing.T) { |
| 330 | ctx, _ := testPrebuiltEtc(t, tt.config) |
Colin Cross | 7113d20 | 2019-11-20 16:39:12 -0800 | [diff] [blame] | 331 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
Colin Cross | ff6c33d | 2019-10-02 16:01:35 -0700 | [diff] [blame] | 332 | if p.installDirPath.String() != tt.expectedPath { |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 333 | t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath) |
| 334 | } |
| 335 | }) |
| 336 | } |
| 337 | } |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 338 | |
| 339 | func TestPrebuiltDSPDirPath(t *testing.T) { |
| 340 | targetPath := filepath.Join(buildDir, "/target/product/test_device") |
| 341 | tests := []struct { |
| 342 | description string |
| 343 | config string |
| 344 | expectedPath string |
| 345 | }{{ |
| 346 | description: "prebuilt: system dsp", |
| 347 | config: ` |
| 348 | prebuilt_dsp { |
| 349 | name: "foo.conf", |
| 350 | src: "foo.conf", |
| 351 | }`, |
| 352 | expectedPath: filepath.Join(targetPath, "system/etc/dsp"), |
| 353 | }, { |
| 354 | description: "prebuilt: vendor dsp", |
| 355 | config: ` |
| 356 | prebuilt_dsp { |
| 357 | name: "foo.conf", |
| 358 | src: "foo.conf", |
| 359 | soc_specific: true, |
| 360 | sub_dir: "sub_dir", |
| 361 | }`, |
| 362 | expectedPath: filepath.Join(targetPath, "vendor/dsp/sub_dir"), |
| 363 | }} |
| 364 | for _, tt := range tests { |
| 365 | t.Run(tt.description, func(t *testing.T) { |
| 366 | ctx, _ := testPrebuiltEtc(t, tt.config) |
| 367 | p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a").Module().(*PrebuiltEtc) |
| 368 | if p.installDirPath.String() != tt.expectedPath { |
| 369 | t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath) |
| 370 | } |
| 371 | }) |
| 372 | } |
| 373 | } |