Add path tests for ramdisk
Ramdisk path tests existed once, but have been removed for whatever reason. This change revives the tests. Test: soong test Change-Id: Ibade91fbe3e044f772a50df15f448b04aa12d807
This commit is contained in:
parent
ff5cc064c2
commit
d9580b84a2
|
@ -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}}
|
||||
|
|
Loading…
Reference in New Issue