2018-08-15 07:20:22 +02:00
|
|
|
// Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-06-01 19:45:49 +02:00
|
|
|
package etc
|
2018-08-15 07:20:22 +02:00
|
|
|
|
|
|
|
import (
|
2020-06-01 19:45:49 +02:00
|
|
|
"os"
|
2019-02-23 00:47:57 +01:00
|
|
|
"path/filepath"
|
2018-08-15 07:20:22 +02:00
|
|
|
"testing"
|
2020-06-01 19:45:49 +02:00
|
|
|
|
2021-07-19 04:38:04 +02:00
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
|
2020-06-01 19:45:49 +02:00
|
|
|
"android/soong/android"
|
2018-08-15 07:20:22 +02:00
|
|
|
)
|
|
|
|
|
2020-06-01 19:45:49 +02:00
|
|
|
func TestMain(m *testing.M) {
|
2021-03-15 16:35:49 +01:00
|
|
|
os.Exit(m.Run())
|
2020-06-01 19:45:49 +02:00
|
|
|
}
|
|
|
|
|
2021-03-20 01:36:55 +01:00
|
|
|
var prepareForPrebuiltEtcTest = android.GroupFixturePreparers(
|
2021-03-08 12:28:18 +01:00
|
|
|
android.PrepareForTestWithArchMutator,
|
|
|
|
PrepareForTestWithPrebuiltEtc,
|
|
|
|
android.FixtureMergeMockFs(android.MockFS{
|
2019-12-14 05:41:13 +01:00
|
|
|
"foo.conf": nil,
|
|
|
|
"bar.conf": nil,
|
|
|
|
"baz.conf": nil,
|
2021-03-08 12:28:18 +01:00
|
|
|
}),
|
|
|
|
)
|
2020-06-26 19:12:36 +02:00
|
|
|
|
2018-08-15 07:20:22 +02:00
|
|
|
func TestPrebuiltEtcVariants(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2018-08-15 07:20:22 +02:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "bar.conf",
|
|
|
|
src: "bar.conf",
|
|
|
|
recovery_available: true,
|
|
|
|
}
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "baz.conf",
|
|
|
|
src: "baz.conf",
|
|
|
|
recovery: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
foo_variants := result.ModuleVariantsForTests("foo.conf")
|
2018-08-15 07:20:22 +02:00
|
|
|
if len(foo_variants) != 1 {
|
|
|
|
t.Errorf("expected 1, got %#v", foo_variants)
|
|
|
|
}
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
bar_variants := result.ModuleVariantsForTests("bar.conf")
|
2018-08-15 07:20:22 +02:00
|
|
|
if len(bar_variants) != 2 {
|
|
|
|
t.Errorf("expected 2, got %#v", bar_variants)
|
|
|
|
}
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
baz_variants := result.ModuleVariantsForTests("baz.conf")
|
2018-08-15 07:20:22 +02:00
|
|
|
if len(baz_variants) != 1 {
|
2023-09-02 01:11:47 +02:00
|
|
|
t.Errorf("expected 1, got %#v", baz_variants)
|
2018-08-15 07:20:22 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-26 14:49:39 +02:00
|
|
|
|
|
|
|
func TestPrebuiltEtcOutputPath(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2018-10-26 14:49:39 +02:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
filename: "foo.installed.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2024-03-18 04:06:00 +01:00
|
|
|
android.AssertStringEquals(t, "output file path", "foo.installed.conf", p.outputFilePaths[0].Base())
|
2018-10-26 14:49:39 +02:00
|
|
|
}
|
2018-11-13 03:59:12 +01:00
|
|
|
|
|
|
|
func TestPrebuiltEtcGlob(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2018-11-13 03:59:12 +01:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "my_foo",
|
|
|
|
src: "foo.*",
|
|
|
|
}
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "my_bar",
|
|
|
|
src: "bar.*",
|
|
|
|
filename_from_src: true,
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("my_foo", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2024-03-18 04:06:00 +01:00
|
|
|
android.AssertStringEquals(t, "my_foo output file path", "my_foo", p.outputFilePaths[0].Base())
|
2018-11-13 03:59:12 +01:00
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p = result.Module("my_bar", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2024-03-18 04:06:00 +01:00
|
|
|
android.AssertStringEquals(t, "my_bar output file path", "bar.conf", p.outputFilePaths[0].Base())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrebuiltEtcMultipleSrcs(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo",
|
|
|
|
srcs: ["*.conf"],
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
android.AssertStringEquals(t, "output file path", "bar.conf", p.outputFilePaths[0].Base())
|
|
|
|
android.AssertStringEquals(t, "output file path", "baz.conf", p.outputFilePaths[1].Base())
|
|
|
|
android.AssertStringEquals(t, "output file path", "foo.conf", p.outputFilePaths[2].Base())
|
2018-11-13 03:59:12 +01:00
|
|
|
}
|
2019-02-04 15:19:27 +01:00
|
|
|
|
|
|
|
func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2019-02-04 15:19:27 +01:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo",
|
|
|
|
src: "foo.conf",
|
|
|
|
owner: "abc",
|
|
|
|
filename_from_src: true,
|
2019-04-04 00:47:29 +02:00
|
|
|
required: ["modA", "moduleB"],
|
|
|
|
host_required: ["hostModA", "hostModB"],
|
|
|
|
target_required: ["targetModA"],
|
2019-02-04 15:19:27 +01:00
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2019-04-04 00:47:29 +02:00
|
|
|
expected := map[string][]string{
|
|
|
|
"LOCAL_MODULE": {"foo"},
|
|
|
|
"LOCAL_MODULE_CLASS": {"ETC"},
|
|
|
|
"LOCAL_MODULE_OWNER": {"abc"},
|
|
|
|
"LOCAL_INSTALLED_MODULE_STEM": {"foo.conf"},
|
|
|
|
"LOCAL_REQUIRED_MODULES": {"modA", "moduleB"},
|
|
|
|
"LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"},
|
|
|
|
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
|
2023-01-05 02:12:24 +01:00
|
|
|
"LOCAL_SOONG_MODULE_TYPE": {"prebuilt_etc"},
|
2019-02-04 15:19:27 +01:00
|
|
|
}
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
entries := android.AndroidMkEntriesForTest(t, result.TestContext, mod)[0]
|
2019-04-04 00:47:29 +02:00
|
|
|
for k, expectedValue := range expected {
|
|
|
|
if value, ok := entries.EntryMap[k]; ok {
|
2021-03-12 12:59:43 +01:00
|
|
|
android.AssertDeepEquals(t, k, expectedValue, value)
|
2019-04-04 00:47:29 +02:00
|
|
|
} else {
|
|
|
|
t.Errorf("No %s defined, saw %q", k, entries.EntryMap)
|
2019-02-04 15:19:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-04 23:34:10 +01:00
|
|
|
|
2020-06-26 19:12:36 +02:00
|
|
|
func TestPrebuiltEtcRelativeInstallPathInstallDirPath(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2020-06-26 19:12:36 +02:00
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
relative_install_path: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
expected := "out/soong/target/product/test_device/system/etc/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
2020-06-26 19:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
prepareForPrebuiltEtcTest.
|
2021-03-08 12:28:18 +01:00
|
|
|
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("relative_install_path is set. Cannot set sub_dir")).
|
|
|
|
RunTestWithBp(t, `
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
relative_install_path: "bar",
|
|
|
|
}
|
|
|
|
`)
|
2020-06-26 19:12:36 +02:00
|
|
|
}
|
|
|
|
|
2019-02-04 23:34:10 +01:00
|
|
|
func TestPrebuiltEtcHost(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2019-02-04 23:34:10 +01:00
|
|
|
prebuilt_etc_host {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
buildOS := result.Config.BuildOS.String()
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
2019-02-04 23:34:10 +01:00
|
|
|
if !p.Host() {
|
|
|
|
t.Errorf("host bit is not set for a prebuilt_etc_host module.")
|
|
|
|
}
|
|
|
|
}
|
2019-02-13 14:50:33 +01:00
|
|
|
|
2022-10-04 00:31:29 +02:00
|
|
|
func TestPrebuiltEtcAllowMissingDependencies(t *testing.T) {
|
|
|
|
result := android.GroupFixturePreparers(
|
|
|
|
prepareForPrebuiltEtcTest,
|
|
|
|
android.PrepareForTestDisallowNonExistentPaths,
|
|
|
|
android.FixtureModifyConfig(
|
|
|
|
func(config android.Config) {
|
|
|
|
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
|
|
|
}),
|
|
|
|
).RunTestWithBp(t, `
|
|
|
|
prebuilt_etc {
|
|
|
|
name: "foo.conf",
|
|
|
|
filename_from_src: true,
|
|
|
|
arch: {
|
|
|
|
x86: {
|
|
|
|
src: "x86.conf",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
android.AssertStringEquals(t, "expected error rule", "android/soong/android.Error",
|
|
|
|
result.ModuleForTests("foo.conf", "android_arm64_armv8-a").Output("foo.conf").Rule.String())
|
|
|
|
}
|
|
|
|
|
2021-04-06 14:00:17 +02:00
|
|
|
func TestPrebuiltRootInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_root {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
filename: "foo.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrebuiltRootInstallDirPathValidate(t *testing.T) {
|
|
|
|
prepareForPrebuiltEtcTest.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("filename cannot contain separator")).RunTestWithBp(t, `
|
|
|
|
prebuilt_root {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
filename: "foo/bar.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
}
|
|
|
|
|
2019-02-13 14:50:33 +01:00
|
|
|
func TestPrebuiltUserShareInstallDirPath(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2019-02-13 14:50:33 +01:00
|
|
|
prebuilt_usr_share {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
expected := "out/soong/target/product/test_device/system/usr/share/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
2019-02-13 14:50:33 +01:00
|
|
|
}
|
2019-02-23 00:47:57 +01:00
|
|
|
|
|
|
|
func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2019-02-23 00:47:57 +01:00
|
|
|
prebuilt_usr_share_host {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-07-20 18:47:41 +02:00
|
|
|
buildOS := result.Config.BuildOS.String()
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
2019-02-23 00:47:57 +01:00
|
|
|
}
|
2019-05-14 17:20:45 +02:00
|
|
|
|
2024-03-27 10:02:12 +01:00
|
|
|
func TestPrebuiltPrebuiltUserHyphenDataInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_usr_hyphendata {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system/usr/hyphen-data/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
2024-04-30 10:24:50 +02:00
|
|
|
func TestPrebuiltPrebuiltUserKeyLayoutInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_usr_keylayout {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system/usr/keylayout/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrebuiltPrebuiltUserKeyCharsInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_usr_keychars {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system/usr/keychars/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPrebuiltPrebuiltUserIdcInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_usr_idc {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
sub_dir: "bar",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system/usr/idc/bar"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
2019-05-14 17:20:45 +02:00
|
|
|
func TestPrebuiltFontInstallDirPath(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
2019-05-14 17:20:45 +02:00
|
|
|
prebuilt_font {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
expected := "out/soong/target/product/test_device/system/fonts"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
2019-05-14 17:20:45 +02:00
|
|
|
}
|
2019-06-04 00:29:27 +02:00
|
|
|
|
Add support for prebuilt_overlay module type in soong
In Android 11 or higher, you can use OverlayConfig
to configure the mutability, default state, and priority
of overlays.
To configure an overlay, you need to create a config.xml
in partition/overlay/config/. Since there is no module type
in soong to install prebuilt artifacts on that location
(like prebuilt_etc for example) we need to manually create
and move that file using Make duing the build process.
This commit adds support to instead create that file
using soong. Then we can instead do something along the
lines of:
prebuilt_overlay {
name: "test-overlay",
src: ":generate-test-overlay",
sub_dir: "config",
filename: "config.xml",
product_specific: true,
}
which would create a config.xml file at the overlay/
directory of the partion in which the overlay is configured,
product/ in this example.
Test: cd build/soong/etc ; go test -run \
TestPrebuiltOverlayInstallDirPath
Bug: 340833016
Change-Id: Iaecae7784683fb9c4306a6834b3ee705c9c20806
2024-05-02 12:37:59 +02:00
|
|
|
func TestPrebuiltOverlayInstallDirPath(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
|
|
|
|
prebuilt_overlay {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
expected := "out/soong/target/product/test_device/system/overlay"
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
|
|
|
|
}
|
|
|
|
|
2019-06-04 00:29:27 +02:00
|
|
|
func TestPrebuiltFirmwareDirPath(t *testing.T) {
|
2021-03-15 16:35:49 +01:00
|
|
|
targetPath := "out/soong/target/product/test_device"
|
2019-06-04 00:29:27 +02:00
|
|
|
tests := []struct {
|
|
|
|
description string
|
|
|
|
config string
|
|
|
|
expectedPath string
|
|
|
|
}{{
|
|
|
|
description: "prebuilt: system firmware",
|
|
|
|
config: `
|
|
|
|
prebuilt_firmware {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "system/etc/firmware"),
|
|
|
|
}, {
|
|
|
|
description: "prebuilt: vendor firmware",
|
|
|
|
config: `
|
|
|
|
prebuilt_firmware {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
soc_specific: true,
|
|
|
|
sub_dir: "sub_dir",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "vendor/firmware/sub_dir"),
|
|
|
|
}}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.description, func(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
|
2019-06-04 00:29:27 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-06-08 23:40:25 +02:00
|
|
|
|
|
|
|
func TestPrebuiltDSPDirPath(t *testing.T) {
|
2021-03-15 16:35:49 +01:00
|
|
|
targetPath := "out/soong/target/product/test_device"
|
2020-06-08 23:40:25 +02:00
|
|
|
tests := []struct {
|
|
|
|
description string
|
|
|
|
config string
|
|
|
|
expectedPath string
|
|
|
|
}{{
|
|
|
|
description: "prebuilt: system dsp",
|
|
|
|
config: `
|
|
|
|
prebuilt_dsp {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "system/etc/dsp"),
|
|
|
|
}, {
|
|
|
|
description: "prebuilt: vendor dsp",
|
|
|
|
config: `
|
|
|
|
prebuilt_dsp {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
soc_specific: true,
|
|
|
|
sub_dir: "sub_dir",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "vendor/dsp/sub_dir"),
|
|
|
|
}}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.description, func(t *testing.T) {
|
2021-03-20 01:36:55 +01:00
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
|
2021-03-10 10:00:58 +01:00
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
2021-03-15 16:35:49 +01:00
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
|
2020-06-08 23:40:25 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-04-09 18:41:23 +02:00
|
|
|
|
|
|
|
func TestPrebuiltRFSADirPath(t *testing.T) {
|
|
|
|
targetPath := "out/soong/target/product/test_device"
|
|
|
|
tests := []struct {
|
|
|
|
description string
|
|
|
|
config string
|
|
|
|
expectedPath string
|
|
|
|
}{{
|
|
|
|
description: "prebuilt: system rfsa",
|
|
|
|
config: `
|
|
|
|
prebuilt_rfsa {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "system/lib/rfsa"),
|
|
|
|
}, {
|
|
|
|
description: "prebuilt: vendor rfsa",
|
|
|
|
config: `
|
|
|
|
prebuilt_rfsa {
|
|
|
|
name: "foo.conf",
|
|
|
|
src: "foo.conf",
|
|
|
|
soc_specific: true,
|
|
|
|
sub_dir: "sub_dir",
|
|
|
|
}`,
|
|
|
|
expectedPath: filepath.Join(targetPath, "vendor/lib/rfsa/sub_dir"),
|
|
|
|
}}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.description, func(t *testing.T) {
|
|
|
|
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
|
|
|
|
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
|
|
|
|
android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|