Merge "Refactor test to use Go subtests idiom."
This commit is contained in:
commit
56b92cf177
1 changed files with 137 additions and 128 deletions
|
@ -4508,10 +4508,78 @@ func TestAppBundle(t *testing.T) {
|
|||
ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo/AppFoo.apk"}]}`)
|
||||
}
|
||||
|
||||
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg, bp string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) {
|
||||
func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, transformDexpreoptConfig func(*dexpreopt.GlobalConfig)) {
|
||||
t.Helper()
|
||||
|
||||
bp = bp + `
|
||||
bp := `
|
||||
java_library {
|
||||
name: "some-updatable-apex-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
apex_available: [
|
||||
"some-updatable-apex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-non-updatable-apex-lib",
|
||||
srcs: ["a.java"],
|
||||
apex_available: [
|
||||
"some-non-updatable-apex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-platform-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
installable: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-art-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
apex_available: [
|
||||
"com.android.art.something",
|
||||
],
|
||||
hostdex: true,
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "some-updatable-apex",
|
||||
key: "some-updatable-apex.key",
|
||||
java_libs: ["some-updatable-apex-lib"],
|
||||
updatable: true,
|
||||
min_sdk_version: "current",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "some-non-updatable-apex",
|
||||
key: "some-non-updatable-apex.key",
|
||||
java_libs: ["some-non-updatable-apex-lib"],
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "some-updatable-apex.key",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "some-non-updatable-apex.key",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "com.android.art.something",
|
||||
key: "com.android.art.something.key",
|
||||
java_libs: ["some-art-lib"],
|
||||
updatable: true,
|
||||
min_sdk_version: "current",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "com.android.art.something.key",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "some-updatable-apex-file_contexts",
|
||||
srcs: [
|
||||
|
@ -4598,145 +4666,86 @@ func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNoUpdatableJarsInBootImage(t *testing.T) {
|
||||
bp := `
|
||||
java_library {
|
||||
name: "some-updatable-apex-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
apex_available: [
|
||||
"some-updatable-apex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-non-updatable-apex-lib",
|
||||
srcs: ["a.java"],
|
||||
apex_available: [
|
||||
"some-non-updatable-apex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-platform-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
installable: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "some-art-lib",
|
||||
srcs: ["a.java"],
|
||||
sdk_version: "current",
|
||||
apex_available: [
|
||||
"com.android.art.something",
|
||||
],
|
||||
hostdex: true,
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "some-updatable-apex",
|
||||
key: "some-updatable-apex.key",
|
||||
java_libs: ["some-updatable-apex-lib"],
|
||||
updatable: true,
|
||||
min_sdk_version: "current",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "some-non-updatable-apex",
|
||||
key: "some-non-updatable-apex.key",
|
||||
java_libs: ["some-non-updatable-apex-lib"],
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "some-updatable-apex.key",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "some-non-updatable-apex.key",
|
||||
}
|
||||
|
||||
apex {
|
||||
name: "com.android.art.something",
|
||||
key: "com.android.art.something.key",
|
||||
java_libs: ["some-art-lib"],
|
||||
updatable: true,
|
||||
min_sdk_version: "current",
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "com.android.art.something.key",
|
||||
}
|
||||
`
|
||||
|
||||
var error string
|
||||
var transform func(*dexpreopt.GlobalConfig)
|
||||
|
||||
// updatable jar from ART apex in the ART boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||
})
|
||||
|
||||
// updatable jar from ART apex in the framework boot image => error
|
||||
error = "module 'some-art-lib' from updatable apex 'com.android.art.something' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("updatable jar from ART apex in the framework boot image => error", func(t *testing.T) {
|
||||
error = "module 'some-art-lib' from updatable apex 'com.android.art.something' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"com.android.art.something:some-art-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// updatable jar from some other apex in the ART boot image => error
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// non-updatable jar from some other apex in the ART boot image => error
|
||||
error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("non-updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
|
||||
error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// updatable jar from some other apex in the framework boot image => error
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("updatable jar from some other apex in the framework boot image => error", func(t *testing.T) {
|
||||
error = "module 'some-updatable-apex-lib' from updatable apex 'some-updatable-apex' is not allowed in the framework boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// non-updatable jar from some other apex in the framework boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.T) {
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||
})
|
||||
|
||||
// nonexistent jar in the ART boot image => error
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("nonexistent jar in the ART boot image => error", func(t *testing.T) {
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// nonexistent jar in the framework boot image => error
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("nonexistent jar in the framework boot image => error", func(t *testing.T) {
|
||||
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"platform:nonexistent"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// platform jar in the ART boot image => error
|
||||
error = "module 'some-platform-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
||||
t.Run("platform jar in the ART boot image => error", func(t *testing.T) {
|
||||
error = "module 'some-platform-lib' is not allowed in the ART boot image"
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.ArtApexJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||
})
|
||||
|
||||
// platform jar in the framework boot image => ok
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
||||
t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
|
||||
transform = func(config *dexpreopt.GlobalConfig) {
|
||||
config.BootJars = []string{"platform:some-platform-lib"}
|
||||
}
|
||||
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTestFor(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue