Merge "Add ModuleInstallPathContextForTesting."
This commit is contained in:
commit
f1a2e55ac9
|
@ -1557,6 +1557,72 @@ func PathContextForTesting(config Config) PathContext {
|
|||
}
|
||||
}
|
||||
|
||||
type testModuleInstallPathContext struct {
|
||||
baseModuleContext
|
||||
|
||||
inData bool
|
||||
inTestcases bool
|
||||
inSanitizerDir bool
|
||||
inRamdisk bool
|
||||
inVendorRamdisk bool
|
||||
inRecovery bool
|
||||
inRoot bool
|
||||
forceOS *OsType
|
||||
forceArch *ArchType
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) Config() Config {
|
||||
return m.baseModuleContext.config
|
||||
}
|
||||
|
||||
func (testModuleInstallPathContext) AddNinjaFileDeps(deps ...string) {}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInData() bool {
|
||||
return m.inData
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInTestcases() bool {
|
||||
return m.inTestcases
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInSanitizerDir() bool {
|
||||
return m.inSanitizerDir
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInRamdisk() bool {
|
||||
return m.inRamdisk
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInVendorRamdisk() bool {
|
||||
return m.inVendorRamdisk
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInRecovery() bool {
|
||||
return m.inRecovery
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallInRoot() bool {
|
||||
return m.inRoot
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallBypassMake() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m testModuleInstallPathContext) InstallForceOS() (*OsType, *ArchType) {
|
||||
return m.forceOS, m.forceArch
|
||||
}
|
||||
|
||||
// Construct a minimal ModuleInstallPathContext for testing. Note that baseModuleContext is
|
||||
// default-initialized, which leaves blueprint.baseModuleContext set to nil, so methods that are
|
||||
// delegated to it will panic.
|
||||
func ModuleInstallPathContextForTesting(config Config) ModuleInstallPathContext {
|
||||
ctx := &testModuleInstallPathContext{}
|
||||
ctx.config = config
|
||||
ctx.os = Android
|
||||
return ctx
|
||||
}
|
||||
|
||||
// Rel performs the same function as filepath.Rel, but reports errors to a PathContext, and reports an error if
|
||||
// targetPath is not inside basePath.
|
||||
func Rel(ctx PathContext, basePath string, targetPath string) string {
|
||||
|
|
|
@ -197,62 +197,6 @@ func p(in interface{}) string {
|
|||
}
|
||||
}
|
||||
|
||||
type moduleInstallPathContextImpl struct {
|
||||
baseModuleContext
|
||||
|
||||
inData bool
|
||||
inTestcases bool
|
||||
inSanitizerDir bool
|
||||
inRamdisk bool
|
||||
inVendorRamdisk bool
|
||||
inRecovery bool
|
||||
inRoot bool
|
||||
forceOS *OsType
|
||||
forceArch *ArchType
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) Config() Config {
|
||||
return m.baseModuleContext.config
|
||||
}
|
||||
|
||||
func (moduleInstallPathContextImpl) AddNinjaFileDeps(deps ...string) {}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInData() bool {
|
||||
return m.inData
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInTestcases() bool {
|
||||
return m.inTestcases
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInSanitizerDir() bool {
|
||||
return m.inSanitizerDir
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInRamdisk() bool {
|
||||
return m.inRamdisk
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInVendorRamdisk() bool {
|
||||
return m.inVendorRamdisk
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInRecovery() bool {
|
||||
return m.inRecovery
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallInRoot() bool {
|
||||
return m.inRoot
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallBypassMake() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (m moduleInstallPathContextImpl) InstallForceOS() (*OsType, *ArchType) {
|
||||
return m.forceOS, m.forceArch
|
||||
}
|
||||
|
||||
func pathTestConfig(buildDir string) Config {
|
||||
return TestConfig(buildDir, nil, "", nil)
|
||||
}
|
||||
|
@ -265,14 +209,14 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
name string
|
||||
ctx *moduleInstallPathContextImpl
|
||||
ctx *testModuleInstallPathContext
|
||||
in []string
|
||||
out string
|
||||
partitionDir string
|
||||
}{
|
||||
{
|
||||
name: "host binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: hostTarget.Os,
|
||||
target: hostTarget,
|
||||
|
@ -285,7 +229,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "system binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -297,7 +241,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "vendor binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -312,7 +256,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "odm binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -327,7 +271,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "product binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -342,7 +286,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "system_ext binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -357,7 +301,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "root binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -370,7 +314,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "recovery binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -383,7 +327,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "recovery root binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -398,7 +342,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "system native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -411,7 +355,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "vendor native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -427,7 +371,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "odm native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -443,7 +387,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "product native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -460,7 +404,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "system_ext native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -477,7 +421,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "sanitized system binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -490,7 +434,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized vendor binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -506,7 +450,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized odm binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -522,7 +466,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized product binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -539,7 +483,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "sanitized system_ext binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -556,7 +500,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
|
||||
{
|
||||
name: "sanitized system native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -570,7 +514,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized vendor native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -587,7 +531,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized odm native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -604,7 +548,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized product native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -621,7 +565,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "sanitized system_ext native test binary",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -637,7 +581,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
}, {
|
||||
name: "device testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -649,7 +593,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
partitionDir: "target/product/test_device/testcases",
|
||||
}, {
|
||||
name: "host testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: hostTarget.Os,
|
||||
target: hostTarget,
|
||||
|
@ -661,7 +605,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||
partitionDir: "host/linux-x86/testcases",
|
||||
}, {
|
||||
name: "forced host testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
ctx: &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
@ -697,7 +641,7 @@ func TestBaseDirForInstallPath(t *testing.T) {
|
|||
testConfig := pathTestConfig("")
|
||||
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
|
||||
|
||||
ctx := &moduleInstallPathContextImpl{
|
||||
ctx := &testModuleInstallPathContext{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
|
|
Loading…
Reference in New Issue