Add path tests for ramdisk am: d9580b84a2

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1674327

Change-Id: I128281177de9109e7e47fb78689377296134b860
This commit is contained in:
Inseob Kim 2021-04-15 05:44:25 +00:00 committed by Automerger Merge Worker
commit df6f8f8fa8
1 changed files with 117 additions and 0 deletions

View File

@ -21,6 +21,8 @@ import (
"strconv"
"strings"
"testing"
"github.com/google/blueprint/proptools"
)
type strsTestCase struct {
@ -338,6 +340,60 @@ func TestPathForModuleInstall(t *testing.T) {
partitionDir: "target/product/test_device/recovery/root",
},
{
name: "ramdisk binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRamdisk: true,
},
in: []string{"my_test"},
out: "target/product/test_device/ramdisk/system/my_test",
partitionDir: "target/product/test_device/ramdisk/system",
},
{
name: "ramdisk root binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRamdisk: true,
inRoot: true,
},
in: []string{"my_test"},
out: "target/product/test_device/ramdisk/my_test",
partitionDir: "target/product/test_device/ramdisk",
},
{
name: "vendor_ramdisk binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inVendorRamdisk: true,
},
in: []string{"my_test"},
out: "target/product/test_device/vendor_ramdisk/system/my_test",
partitionDir: "target/product/test_device/vendor_ramdisk/system",
},
{
name: "vendor_ramdisk root binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inVendorRamdisk: true,
inRoot: true,
},
in: []string{"my_test"},
out: "target/product/test_device/vendor_ramdisk/my_test",
partitionDir: "target/product/test_device/vendor_ramdisk",
},
{
name: "system native test binary",
ctx: &testModuleInstallPathContext{
@ -635,6 +691,67 @@ func TestPathForModuleInstall(t *testing.T) {
}
}
func TestPathForModuleInstallRecoveryAsBoot(t *testing.T) {
testConfig := pathTestConfig("")
testConfig.TestProductVariables.BoardUsesRecoveryAsBoot = proptools.BoolPtr(true)
testConfig.TestProductVariables.BoardMoveRecoveryResourcesToVendorBoot = proptools.BoolPtr(true)
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
testCases := []struct {
name string
ctx *testModuleInstallPathContext
in []string
out string
partitionDir string
}{
{
name: "ramdisk binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRamdisk: true,
inRoot: true,
},
in: []string{"my_test"},
out: "target/product/test_device/recovery/root/first_stage_ramdisk/my_test",
partitionDir: "target/product/test_device/recovery/root/first_stage_ramdisk",
},
{
name: "vendor_ramdisk binary",
ctx: &testModuleInstallPathContext{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inVendorRamdisk: true,
inRoot: true,
},
in: []string{"my_test"},
out: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk/my_test",
partitionDir: "target/product/test_device/vendor_ramdisk/first_stage_ramdisk",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tc.ctx.baseModuleContext.config = testConfig
output := PathForModuleInstall(tc.ctx, tc.in...)
if output.basePath.path != tc.out {
t.Errorf("unexpected path:\n got: %q\nwant: %q\n",
output.basePath.path,
tc.out)
}
if output.partitionDir != tc.partitionDir {
t.Errorf("unexpected partitionDir:\n got: %q\nwant: %q\n",
output.partitionDir, tc.partitionDir)
}
})
}
}
func TestBaseDirForInstallPath(t *testing.T) {
testConfig := pathTestConfig("")
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}