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 | "os" |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 19 | "path/filepath" |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 20 | "testing" |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 21 | |
Kiyoung Kim | ae11c23 | 2021-07-19 11:38:04 +0900 | [diff] [blame] | 22 | "github.com/google/blueprint/proptools" |
| 23 | |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 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 | func TestMain(m *testing.M) { |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 28 | os.Exit(m.Run()) |
Jaewoong Jung | 4b79e98 | 2020-06-01 10:45:49 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 31 | var prepareForPrebuiltEtcTest = android.GroupFixturePreparers( |
Paul Duffin | 1172fed | 2021-03-08 11:28:18 +0000 | [diff] [blame] | 32 | android.PrepareForTestWithArchMutator, |
| 33 | PrepareForTestWithPrebuiltEtc, |
| 34 | android.FixtureMergeMockFs(android.MockFS{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 35 | "foo.conf": nil, |
| 36 | "bar.conf": nil, |
| 37 | "baz.conf": nil, |
Paul Duffin | 1172fed | 2021-03-08 11:28:18 +0000 | [diff] [blame] | 38 | }), |
| 39 | ) |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 40 | |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 41 | func TestPrebuiltEtcVariants(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 42 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 43 | prebuilt_etc { |
| 44 | name: "foo.conf", |
| 45 | src: "foo.conf", |
| 46 | } |
| 47 | prebuilt_etc { |
| 48 | name: "bar.conf", |
| 49 | src: "bar.conf", |
| 50 | recovery_available: true, |
| 51 | } |
| 52 | prebuilt_etc { |
| 53 | name: "baz.conf", |
| 54 | src: "baz.conf", |
| 55 | recovery: true, |
| 56 | } |
| 57 | `) |
| 58 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 59 | foo_variants := result.ModuleVariantsForTests("foo.conf") |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 60 | if len(foo_variants) != 1 { |
| 61 | t.Errorf("expected 1, got %#v", foo_variants) |
| 62 | } |
| 63 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 64 | bar_variants := result.ModuleVariantsForTests("bar.conf") |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 65 | if len(bar_variants) != 2 { |
| 66 | t.Errorf("expected 2, got %#v", bar_variants) |
| 67 | } |
| 68 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 69 | baz_variants := result.ModuleVariantsForTests("baz.conf") |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 70 | if len(baz_variants) != 1 { |
Cole Faust | dff9c14 | 2023-09-01 16:11:47 -0700 | [diff] [blame] | 71 | t.Errorf("expected 1, got %#v", baz_variants) |
Tao Bao | 0ba5c94 | 2018-08-14 22:20:22 -0700 | [diff] [blame] | 72 | } |
| 73 | } |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 74 | |
| 75 | func TestPrebuiltEtcOutputPath(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 76 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 77 | prebuilt_etc { |
| 78 | name: "foo.conf", |
| 79 | src: "foo.conf", |
| 80 | filename: "foo.installed.conf", |
| 81 | } |
| 82 | `) |
| 83 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 84 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 85 | android.AssertStringEquals(t, "output file path", "foo.installed.conf", p.outputFilePaths[0].Base()) |
Jiyong Park | 139a2e6 | 2018-10-26 21:49:39 +0900 | [diff] [blame] | 86 | } |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 87 | |
| 88 | func TestPrebuiltEtcGlob(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 89 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 90 | prebuilt_etc { |
| 91 | name: "my_foo", |
| 92 | src: "foo.*", |
| 93 | } |
| 94 | prebuilt_etc { |
| 95 | name: "my_bar", |
| 96 | src: "bar.*", |
| 97 | filename_from_src: true, |
| 98 | } |
| 99 | `) |
| 100 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 101 | p := result.Module("my_foo", "android_arm64_armv8-a").(*PrebuiltEtc) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 102 | android.AssertStringEquals(t, "my_foo output file path", "my_foo", p.outputFilePaths[0].Base()) |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 103 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 104 | p = result.Module("my_bar", "android_arm64_armv8-a").(*PrebuiltEtc) |
Thiébaud Weksteen | 00e8b31 | 2024-03-18 14:06:00 +1100 | [diff] [blame] | 105 | android.AssertStringEquals(t, "my_bar output file path", "bar.conf", p.outputFilePaths[0].Base()) |
| 106 | } |
| 107 | |
| 108 | func TestPrebuiltEtcMultipleSrcs(t *testing.T) { |
| 109 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 110 | prebuilt_etc { |
| 111 | name: "foo", |
| 112 | srcs: ["*.conf"], |
| 113 | } |
| 114 | `) |
| 115 | |
| 116 | p := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 117 | android.AssertStringEquals(t, "output file path", "bar.conf", p.outputFilePaths[0].Base()) |
| 118 | android.AssertStringEquals(t, "output file path", "baz.conf", p.outputFilePaths[1].Base()) |
| 119 | android.AssertStringEquals(t, "output file path", "foo.conf", p.outputFilePaths[2].Base()) |
Jiyong Park | 1a7cf08 | 2018-11-13 11:59:12 +0900 | [diff] [blame] | 120 | } |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 121 | |
| 122 | func TestPrebuiltEtcAndroidMk(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 123 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 124 | prebuilt_etc { |
| 125 | name: "foo", |
| 126 | src: "foo.conf", |
| 127 | owner: "abc", |
| 128 | filename_from_src: true, |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 129 | required: ["modA", "moduleB"], |
| 130 | host_required: ["hostModA", "hostModB"], |
| 131 | target_required: ["targetModA"], |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 132 | } |
| 133 | `) |
| 134 | |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 135 | expected := map[string][]string{ |
| 136 | "LOCAL_MODULE": {"foo"}, |
| 137 | "LOCAL_MODULE_CLASS": {"ETC"}, |
| 138 | "LOCAL_MODULE_OWNER": {"abc"}, |
| 139 | "LOCAL_INSTALLED_MODULE_STEM": {"foo.conf"}, |
| 140 | "LOCAL_REQUIRED_MODULES": {"modA", "moduleB"}, |
| 141 | "LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"}, |
| 142 | "LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"}, |
Wei Li | 598f92d | 2023-01-04 17:12:24 -0800 | [diff] [blame] | 143 | "LOCAL_SOONG_MODULE_TYPE": {"prebuilt_etc"}, |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 146 | mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 147 | entries := android.AndroidMkEntriesForTest(t, result.TestContext, mod)[0] |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 148 | for k, expectedValue := range expected { |
| 149 | if value, ok := entries.EntryMap[k]; ok { |
Paul Duffin | e84b133 | 2021-03-12 11:59:43 +0000 | [diff] [blame] | 150 | android.AssertDeepEquals(t, k, expectedValue, value) |
Jaewoong Jung | 9aa3ab1 | 2019-04-03 15:47:29 -0700 | [diff] [blame] | 151 | } else { |
| 152 | t.Errorf("No %s defined, saw %q", k, entries.EntryMap) |
Anton Hansson | ce0e258 | 2019-02-04 14:19:27 +0000 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | } |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 156 | |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 157 | func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 158 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 159 | prebuilt_etc { |
| 160 | name: "foo.conf", |
| 161 | src: "foo.conf", |
| 162 | relative_install_path: "bar", |
| 163 | } |
| 164 | `) |
| 165 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 166 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 167 | expected := "out/soong/target/product/test_device/system/etc/bar" |
| 168 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 172 | prepareForPrebuiltEtcTest. |
Paul Duffin | 1172fed | 2021-03-08 11:28:18 +0000 | [diff] [blame] | 173 | ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("relative_install_path is set. Cannot set sub_dir")). |
| 174 | RunTestWithBp(t, ` |
| 175 | prebuilt_etc { |
| 176 | name: "foo.conf", |
| 177 | src: "foo.conf", |
| 178 | sub_dir: "bar", |
| 179 | relative_install_path: "bar", |
| 180 | } |
| 181 | `) |
Liz Kammer | 0449a63 | 2020-06-26 10:12:36 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 184 | func TestPrebuiltEtcHost(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 185 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 186 | prebuilt_etc_host { |
| 187 | name: "foo.conf", |
| 188 | src: "foo.conf", |
| 189 | } |
| 190 | `) |
| 191 | |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 192 | buildOS := result.Config.BuildOS.String() |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 193 | p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc) |
Jaewoong Jung | 2478818 | 2019-02-04 14:34:10 -0800 | [diff] [blame] | 194 | if !p.Host() { |
| 195 | t.Errorf("host bit is not set for a prebuilt_etc_host module.") |
| 196 | } |
| 197 | } |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 198 | |
Colin Cross | 725eac6 | 2022-10-03 15:31:29 -0700 | [diff] [blame] | 199 | func TestPrebuiltEtcAllowMissingDependencies(t *testing.T) { |
| 200 | result := android.GroupFixturePreparers( |
| 201 | prepareForPrebuiltEtcTest, |
| 202 | android.PrepareForTestDisallowNonExistentPaths, |
| 203 | android.FixtureModifyConfig( |
| 204 | func(config android.Config) { |
| 205 | config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true) |
| 206 | }), |
| 207 | ).RunTestWithBp(t, ` |
| 208 | prebuilt_etc { |
| 209 | name: "foo.conf", |
| 210 | filename_from_src: true, |
| 211 | arch: { |
| 212 | x86: { |
| 213 | src: "x86.conf", |
| 214 | }, |
| 215 | }, |
| 216 | } |
| 217 | `) |
| 218 | |
| 219 | android.AssertStringEquals(t, "expected error rule", "android/soong/android.Error", |
| 220 | result.ModuleForTests("foo.conf", "android_arm64_armv8-a").Output("foo.conf").Rule.String()) |
| 221 | } |
| 222 | |
Inseob Kim | 27408bf | 2021-04-06 21:00:17 +0900 | [diff] [blame] | 223 | func TestPrebuiltRootInstallDirPath(t *testing.T) { |
| 224 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 225 | prebuilt_root { |
| 226 | name: "foo.conf", |
| 227 | src: "foo.conf", |
| 228 | filename: "foo.conf", |
| 229 | } |
| 230 | `) |
| 231 | |
| 232 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 233 | expected := "out/soong/target/product/test_device/system" |
| 234 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 235 | } |
| 236 | |
| 237 | func TestPrebuiltRootInstallDirPathValidate(t *testing.T) { |
| 238 | prepareForPrebuiltEtcTest.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("filename cannot contain separator")).RunTestWithBp(t, ` |
| 239 | prebuilt_root { |
| 240 | name: "foo.conf", |
| 241 | src: "foo.conf", |
| 242 | filename: "foo/bar.conf", |
| 243 | } |
| 244 | `) |
| 245 | } |
| 246 | |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 247 | func TestPrebuiltUserShareInstallDirPath(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 248 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 249 | prebuilt_usr_share { |
| 250 | name: "foo.conf", |
| 251 | src: "foo.conf", |
| 252 | sub_dir: "bar", |
| 253 | } |
| 254 | `) |
| 255 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 256 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 257 | expected := "out/soong/target/product/test_device/system/usr/share/bar" |
| 258 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
Jaewoong Jung | c3fcdb4 | 2019-02-13 05:50:33 -0800 | [diff] [blame] | 259 | } |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 260 | |
| 261 | func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 262 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 263 | prebuilt_usr_share_host { |
| 264 | name: "foo.conf", |
| 265 | src: "foo.conf", |
| 266 | sub_dir: "bar", |
| 267 | } |
| 268 | `) |
| 269 | |
Colin Cross | 0c66bc6 | 2021-07-20 09:47:41 -0700 | [diff] [blame] | 270 | buildOS := result.Config.BuildOS.String() |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 271 | p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 272 | expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar") |
| 273 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
Patrice Arruda | 300cef9 | 2019-02-22 15:47:57 -0800 | [diff] [blame] | 274 | } |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 275 | |
yangbill | 63c5e19 | 2024-03-27 09:02:12 +0000 | [diff] [blame] | 276 | func TestPrebuiltPrebuiltUserHyphenDataInstallDirPath(t *testing.T) { |
| 277 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 278 | prebuilt_usr_hyphendata { |
| 279 | name: "foo.conf", |
| 280 | src: "foo.conf", |
| 281 | sub_dir: "bar", |
| 282 | } |
| 283 | `) |
| 284 | |
| 285 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 286 | expected := "out/soong/target/product/test_device/system/usr/hyphen-data/bar" |
| 287 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 288 | } |
| 289 | |
yangbill | 85527e6 | 2024-04-30 08:24:50 +0000 | [diff] [blame] | 290 | func TestPrebuiltPrebuiltUserKeyLayoutInstallDirPath(t *testing.T) { |
| 291 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 292 | prebuilt_usr_keylayout { |
| 293 | name: "foo.conf", |
| 294 | src: "foo.conf", |
| 295 | sub_dir: "bar", |
| 296 | } |
| 297 | `) |
| 298 | |
| 299 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 300 | expected := "out/soong/target/product/test_device/system/usr/keylayout/bar" |
| 301 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 302 | } |
| 303 | |
| 304 | func TestPrebuiltPrebuiltUserKeyCharsInstallDirPath(t *testing.T) { |
| 305 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 306 | prebuilt_usr_keychars { |
| 307 | name: "foo.conf", |
| 308 | src: "foo.conf", |
| 309 | sub_dir: "bar", |
| 310 | } |
| 311 | `) |
| 312 | |
| 313 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 314 | expected := "out/soong/target/product/test_device/system/usr/keychars/bar" |
| 315 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 316 | } |
| 317 | |
| 318 | func TestPrebuiltPrebuiltUserIdcInstallDirPath(t *testing.T) { |
| 319 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 320 | prebuilt_usr_idc { |
| 321 | name: "foo.conf", |
| 322 | src: "foo.conf", |
| 323 | sub_dir: "bar", |
| 324 | } |
| 325 | `) |
| 326 | |
| 327 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 328 | expected := "out/soong/target/product/test_device/system/usr/idc/bar" |
| 329 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 330 | } |
| 331 | |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 332 | func TestPrebuiltFontInstallDirPath(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 333 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 334 | prebuilt_font { |
| 335 | name: "foo.conf", |
| 336 | src: "foo.conf", |
| 337 | } |
| 338 | `) |
| 339 | |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 340 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 341 | expected := "out/soong/target/product/test_device/system/fonts" |
| 342 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
Patrice Arruda | 61583eb | 2019-05-14 08:20:45 -0700 | [diff] [blame] | 343 | } |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 344 | |
Kevin | 93f7cd8 | 2024-05-02 12:37:59 +0200 | [diff] [blame] | 345 | func TestPrebuiltOverlayInstallDirPath(t *testing.T) { |
| 346 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` |
| 347 | prebuilt_overlay { |
| 348 | name: "foo.conf", |
| 349 | src: "foo.conf", |
| 350 | } |
| 351 | `) |
| 352 | |
| 353 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 354 | expected := "out/soong/target/product/test_device/system/overlay" |
| 355 | android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) |
| 356 | } |
| 357 | |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 358 | func TestPrebuiltFirmwareDirPath(t *testing.T) { |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 359 | targetPath := "out/soong/target/product/test_device" |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 360 | tests := []struct { |
| 361 | description string |
| 362 | config string |
| 363 | expectedPath string |
| 364 | }{{ |
| 365 | description: "prebuilt: system firmware", |
| 366 | config: ` |
| 367 | prebuilt_firmware { |
| 368 | name: "foo.conf", |
| 369 | src: "foo.conf", |
| 370 | }`, |
| 371 | expectedPath: filepath.Join(targetPath, "system/etc/firmware"), |
| 372 | }, { |
| 373 | description: "prebuilt: vendor firmware", |
| 374 | config: ` |
| 375 | prebuilt_firmware { |
| 376 | name: "foo.conf", |
| 377 | src: "foo.conf", |
| 378 | soc_specific: true, |
| 379 | sub_dir: "sub_dir", |
| 380 | }`, |
| 381 | expectedPath: filepath.Join(targetPath, "vendor/firmware/sub_dir"), |
| 382 | }} |
| 383 | for _, tt := range tests { |
| 384 | t.Run(tt.description, func(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 385 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config) |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 386 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 387 | android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath) |
Patrice Arruda | 057a8b1 | 2019-06-03 15:29:27 -0700 | [diff] [blame] | 388 | }) |
| 389 | } |
| 390 | } |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 391 | |
| 392 | func TestPrebuiltDSPDirPath(t *testing.T) { |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 393 | targetPath := "out/soong/target/product/test_device" |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 394 | tests := []struct { |
| 395 | description string |
| 396 | config string |
| 397 | expectedPath string |
| 398 | }{{ |
| 399 | description: "prebuilt: system dsp", |
| 400 | config: ` |
| 401 | prebuilt_dsp { |
| 402 | name: "foo.conf", |
| 403 | src: "foo.conf", |
| 404 | }`, |
| 405 | expectedPath: filepath.Join(targetPath, "system/etc/dsp"), |
| 406 | }, { |
| 407 | description: "prebuilt: vendor dsp", |
| 408 | config: ` |
| 409 | prebuilt_dsp { |
| 410 | name: "foo.conf", |
| 411 | src: "foo.conf", |
| 412 | soc_specific: true, |
| 413 | sub_dir: "sub_dir", |
| 414 | }`, |
| 415 | expectedPath: filepath.Join(targetPath, "vendor/dsp/sub_dir"), |
| 416 | }} |
| 417 | for _, tt := range tests { |
| 418 | t.Run(tt.description, func(t *testing.T) { |
Paul Duffin | 89648f9 | 2021-03-20 00:36:55 +0000 | [diff] [blame] | 419 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config) |
Paul Duffin | 921fac7 | 2021-03-10 09:00:58 +0000 | [diff] [blame] | 420 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
Paul Duffin | 5f9f771 | 2021-03-15 15:35:49 +0000 | [diff] [blame] | 421 | android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath) |
Patrice Arruda | 0f68800 | 2020-06-08 21:40:25 +0000 | [diff] [blame] | 422 | }) |
| 423 | } |
| 424 | } |
Colin Cross | 83ebf23 | 2021-04-09 09:41:23 -0700 | [diff] [blame] | 425 | |
| 426 | func TestPrebuiltRFSADirPath(t *testing.T) { |
| 427 | targetPath := "out/soong/target/product/test_device" |
| 428 | tests := []struct { |
| 429 | description string |
| 430 | config string |
| 431 | expectedPath string |
| 432 | }{{ |
| 433 | description: "prebuilt: system rfsa", |
| 434 | config: ` |
| 435 | prebuilt_rfsa { |
| 436 | name: "foo.conf", |
| 437 | src: "foo.conf", |
| 438 | }`, |
| 439 | expectedPath: filepath.Join(targetPath, "system/lib/rfsa"), |
| 440 | }, { |
| 441 | description: "prebuilt: vendor rfsa", |
| 442 | config: ` |
| 443 | prebuilt_rfsa { |
| 444 | name: "foo.conf", |
| 445 | src: "foo.conf", |
| 446 | soc_specific: true, |
| 447 | sub_dir: "sub_dir", |
| 448 | }`, |
| 449 | expectedPath: filepath.Join(targetPath, "vendor/lib/rfsa/sub_dir"), |
| 450 | }} |
| 451 | for _, tt := range tests { |
| 452 | t.Run(tt.description, func(t *testing.T) { |
| 453 | result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config) |
| 454 | p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) |
| 455 | android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath) |
| 456 | }) |
| 457 | } |
| 458 | } |