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:
commit
df6f8f8fa8
|
@ -21,6 +21,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
type strsTestCase struct {
|
type strsTestCase struct {
|
||||||
|
@ -338,6 +340,60 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||||
partitionDir: "target/product/test_device/recovery/root",
|
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",
|
name: "system native test binary",
|
||||||
ctx: &testModuleInstallPathContext{
|
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) {
|
func TestBaseDirForInstallPath(t *testing.T) {
|
||||||
testConfig := pathTestConfig("")
|
testConfig := pathTestConfig("")
|
||||||
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
|
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
|
||||||
|
|
Loading…
Reference in New Issue