Merge "InstallPath keeps its partition dir"
This commit is contained in:
@@ -264,10 +264,11 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
ctx *moduleInstallPathContextImpl
|
||||
in []string
|
||||
out string
|
||||
name string
|
||||
ctx *moduleInstallPathContextImpl
|
||||
in []string
|
||||
out string
|
||||
partitionDir string
|
||||
}{
|
||||
{
|
||||
name: "host binary",
|
||||
@@ -277,8 +278,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
target: hostTarget,
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "host/linux-x86/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "host/linux-x86/bin/my_test",
|
||||
partitionDir: "host/linux-x86",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -289,8 +291,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
target: deviceTarget,
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/system/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/system/bin/my_test",
|
||||
partitionDir: "target/product/test_device/system",
|
||||
},
|
||||
{
|
||||
name: "vendor binary",
|
||||
@@ -303,8 +306,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/vendor/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/vendor/bin/my_test",
|
||||
partitionDir: "target/product/test_device/vendor",
|
||||
},
|
||||
{
|
||||
name: "odm binary",
|
||||
@@ -317,8 +321,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/odm/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/odm/bin/my_test",
|
||||
partitionDir: "target/product/test_device/odm",
|
||||
},
|
||||
{
|
||||
name: "product binary",
|
||||
@@ -331,8 +336,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/product/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/product/bin/my_test",
|
||||
partitionDir: "target/product/test_device/product",
|
||||
},
|
||||
{
|
||||
name: "system_ext binary",
|
||||
@@ -345,8 +351,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/system_ext/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/system_ext/bin/my_test",
|
||||
partitionDir: "target/product/test_device/system_ext",
|
||||
},
|
||||
{
|
||||
name: "root binary",
|
||||
@@ -357,8 +364,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inRoot: true,
|
||||
},
|
||||
in: []string{"my_test"},
|
||||
out: "target/product/test_device/root/my_test",
|
||||
in: []string{"my_test"},
|
||||
out: "target/product/test_device/root/my_test",
|
||||
partitionDir: "target/product/test_device/root",
|
||||
},
|
||||
{
|
||||
name: "recovery binary",
|
||||
@@ -369,8 +377,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inRecovery: true,
|
||||
},
|
||||
in: []string{"bin/my_test"},
|
||||
out: "target/product/test_device/recovery/root/system/bin/my_test",
|
||||
in: []string{"bin/my_test"},
|
||||
out: "target/product/test_device/recovery/root/system/bin/my_test",
|
||||
partitionDir: "target/product/test_device/recovery/root/system",
|
||||
},
|
||||
{
|
||||
name: "recovery root binary",
|
||||
@@ -382,8 +391,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inRecovery: true,
|
||||
inRoot: true,
|
||||
},
|
||||
in: []string{"my_test"},
|
||||
out: "target/product/test_device/recovery/root/my_test",
|
||||
in: []string{"my_test"},
|
||||
out: "target/product/test_device/recovery/root/my_test",
|
||||
partitionDir: "target/product/test_device/recovery/root",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -395,8 +405,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inData: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data",
|
||||
},
|
||||
{
|
||||
name: "vendor native test binary",
|
||||
@@ -410,8 +421,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inData: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data",
|
||||
},
|
||||
{
|
||||
name: "odm native test binary",
|
||||
@@ -425,8 +437,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inData: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data",
|
||||
},
|
||||
{
|
||||
name: "product native test binary",
|
||||
@@ -440,8 +453,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inData: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -456,8 +470,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inData: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -469,8 +484,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/system/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/system/bin/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/system",
|
||||
},
|
||||
{
|
||||
name: "sanitized vendor binary",
|
||||
@@ -484,8 +500,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/vendor/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/vendor/bin/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/vendor",
|
||||
},
|
||||
{
|
||||
name: "sanitized odm binary",
|
||||
@@ -499,8 +516,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/odm/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/odm/bin/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/odm",
|
||||
},
|
||||
{
|
||||
name: "sanitized product binary",
|
||||
@@ -514,8 +532,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/product/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/product/bin/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/product",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -530,8 +549,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/system_ext/bin/my_test",
|
||||
in: []string{"bin", "my_test"},
|
||||
out: "target/product/test_device/data/asan/system_ext/bin/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/system_ext",
|
||||
},
|
||||
|
||||
{
|
||||
@@ -544,8 +564,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inData: true,
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
},
|
||||
{
|
||||
name: "sanitized vendor native test binary",
|
||||
@@ -560,8 +581,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inData: true,
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
},
|
||||
{
|
||||
name: "sanitized odm native test binary",
|
||||
@@ -576,8 +598,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inData: true,
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
},
|
||||
{
|
||||
name: "sanitized product native test binary",
|
||||
@@ -592,8 +615,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inData: true,
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
},
|
||||
{
|
||||
name: "sanitized system_ext native test binary",
|
||||
@@ -608,8 +632,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
inData: true,
|
||||
inSanitizerDir: true,
|
||||
},
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
in: []string{"nativetest", "my_test"},
|
||||
out: "target/product/test_device/data/asan/data/nativetest/my_test",
|
||||
partitionDir: "target/product/test_device/data/asan/data",
|
||||
}, {
|
||||
name: "device testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
@@ -619,8 +644,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inTestcases: true,
|
||||
},
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "target/product/test_device/testcases/my_test/my_test_bin",
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "target/product/test_device/testcases/my_test/my_test_bin",
|
||||
partitionDir: "target/product/test_device/testcases",
|
||||
}, {
|
||||
name: "host testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
@@ -630,8 +656,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
},
|
||||
inTestcases: true,
|
||||
},
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||
partitionDir: "host/linux-x86/testcases",
|
||||
}, {
|
||||
name: "forced host testcases",
|
||||
ctx: &moduleInstallPathContextImpl{
|
||||
@@ -643,8 +670,9 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
forceOS: &Linux,
|
||||
forceArch: &X86,
|
||||
},
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||
in: []string{"my_test", "my_test_bin"},
|
||||
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||
partitionDir: "host/linux-x86/testcases",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -657,10 +685,48 @@ func TestPathForModuleInstall(t *testing.T) {
|
||||
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}}
|
||||
|
||||
ctx := &moduleInstallPathContextImpl{
|
||||
baseModuleContext: baseModuleContext{
|
||||
os: deviceTarget.Os,
|
||||
target: deviceTarget,
|
||||
},
|
||||
}
|
||||
ctx.baseModuleContext.config = testConfig
|
||||
|
||||
actual := PathForModuleInstall(ctx, "foo", "bar")
|
||||
expectedBaseDir := "target/product/test_device/system"
|
||||
if actual.partitionDir != expectedBaseDir {
|
||||
t.Errorf("unexpected partitionDir:\n got: %q\nwant: %q\n", actual.partitionDir, expectedBaseDir)
|
||||
}
|
||||
expectedRelPath := "foo/bar"
|
||||
if actual.Rel() != expectedRelPath {
|
||||
t.Errorf("unexpected Rel():\n got: %q\nwant: %q\n", actual.Rel(), expectedRelPath)
|
||||
}
|
||||
|
||||
actualAfterJoin := actual.Join(ctx, "baz")
|
||||
// partitionDir is preserved even after joining
|
||||
if actualAfterJoin.partitionDir != expectedBaseDir {
|
||||
t.Errorf("unexpected partitionDir after joining:\n got: %q\nwant: %q\n", actualAfterJoin.partitionDir, expectedBaseDir)
|
||||
}
|
||||
// Rel() is updated though
|
||||
expectedRelAfterJoin := "baz"
|
||||
if actualAfterJoin.Rel() != expectedRelAfterJoin {
|
||||
t.Errorf("unexpected Rel() after joining:\n got: %q\nwant: %q\n", actualAfterJoin.Rel(), expectedRelAfterJoin)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDirectorySortedPaths(t *testing.T) {
|
||||
config := TestConfig("out", nil, "", map[string][]byte{
|
||||
"Android.bp": nil,
|
||||
|
Reference in New Issue
Block a user