Merge "Refactor test to use Go subtests idiom." am: 56b92cf177
Change-Id: Ia9d181d43b8edacf023636ab561ccf8e4e7fc10a
This commit is contained in:
committed by
Automerger Merge Worker
commit
3102921784
@@ -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"}]}`)
|
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()
|
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 {
|
filegroup {
|
||||||
name: "some-updatable-apex-file_contexts",
|
name: "some-updatable-apex-file_contexts",
|
||||||
srcs: [
|
srcs: [
|
||||||
@@ -4598,145 +4666,86 @@ func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNoUpdatableJarsInBootImage(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 error string
|
||||||
var transform func(*dexpreopt.GlobalConfig)
|
var transform func(*dexpreopt.GlobalConfig)
|
||||||
|
|
||||||
// updatable jar from ART apex in the ART boot image => ok
|
t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.ArtApexJars = []string{"com.android.art.something:some-art-lib"}
|
config.ArtApexJars = []string{"com.android.art.something:some-art-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||||
|
})
|
||||||
|
|
||||||
// updatable jar from ART apex in the framework boot image => error
|
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"
|
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) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.BootJars = []string{"com.android.art.something:some-art-lib"}
|
config.BootJars = []string{"com.android.art.something:some-art-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// updatable jar from some other apex in the ART boot image => error
|
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"
|
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) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.ArtApexJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
config.ArtApexJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// non-updatable jar from some other apex in the ART boot image => error
|
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"
|
error = "module 'some-non-updatable-apex-lib' is not allowed in the ART boot image"
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.ArtApexJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
config.ArtApexJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// updatable jar from some other apex in the framework boot image => error
|
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"
|
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) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.BootJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
config.BootJars = []string{"some-updatable-apex:some-updatable-apex-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// non-updatable jar from some other apex in the framework boot image => ok
|
t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.T) {
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.BootJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
config.BootJars = []string{"some-non-updatable-apex:some-non-updatable-apex-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||||
|
})
|
||||||
|
|
||||||
// nonexistent jar in the ART boot image => error
|
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'"
|
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.ArtApexJars = []string{"platform:nonexistent"}
|
config.ArtApexJars = []string{"platform:nonexistent"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// nonexistent jar in the framework boot image => error
|
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'"
|
error = "failed to find a dex jar path for module 'nonexistent'"
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.BootJars = []string{"platform:nonexistent"}
|
config.BootJars = []string{"platform:nonexistent"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// platform jar in the ART boot image => error
|
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"
|
error = "module 'some-platform-lib' is not allowed in the ART boot image"
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.ArtApexJars = []string{"platform:some-platform-lib"}
|
config.ArtApexJars = []string{"platform:some-platform-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, error, bp, transform)
|
testNoUpdatableJarsInBootImage(t, error, transform)
|
||||||
|
})
|
||||||
|
|
||||||
// platform jar in the framework boot image => ok
|
t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
|
||||||
transform = func(config *dexpreopt.GlobalConfig) {
|
transform = func(config *dexpreopt.GlobalConfig) {
|
||||||
config.BootJars = []string{"platform:some-platform-lib"}
|
config.BootJars = []string{"platform:some-platform-lib"}
|
||||||
}
|
}
|
||||||
testNoUpdatableJarsInBootImage(t, "", bp, transform)
|
testNoUpdatableJarsInBootImage(t, "", transform)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTestFor(t *testing.T) {
|
func TestTestFor(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user