Add tests for the ignored "profile_guided: true" property.
This is tricky and is worth some tests. Bug: 241823638 Test: m nothing Change-Id: I9c09451d075dca7563eb42c63812375cfd974fbf
This commit is contained in:
@@ -15,10 +15,11 @@
|
|||||||
package apex
|
package apex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/dexpreopt"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/dexpreopt"
|
||||||
"android/soong/java"
|
"android/soong/java"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) {
|
|||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithSystemserverclasspathFragment,
|
prepareForTestWithSystemserverclasspathFragment,
|
||||||
prepareForTestWithMyapex,
|
prepareForTestWithMyapex,
|
||||||
dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar"),
|
dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
@@ -69,11 +70,24 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "baz",
|
||||||
|
srcs: ["d.java"],
|
||||||
|
installable: true,
|
||||||
|
dex_preopt: {
|
||||||
|
profile_guided: true, // ignored
|
||||||
|
},
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
systemserverclasspath_fragment {
|
systemserverclasspath_fragment {
|
||||||
name: "mysystemserverclasspathfragment",
|
name: "mysystemserverclasspathfragment",
|
||||||
contents: [
|
contents: [
|
||||||
"foo",
|
"foo",
|
||||||
"bar",
|
"bar",
|
||||||
|
"baz",
|
||||||
],
|
],
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"myapex",
|
"myapex",
|
||||||
@@ -81,17 +95,24 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
ctx := result.TestContext
|
||||||
|
|
||||||
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
"etc/classpaths/systemserverclasspath.pb",
|
"etc/classpaths/systemserverclasspath.pb",
|
||||||
"javalib/foo.jar",
|
"javalib/foo.jar",
|
||||||
"javalib/bar.jar",
|
"javalib/bar.jar",
|
||||||
"javalib/bar.jar.prof",
|
"javalib/bar.jar.prof",
|
||||||
|
"javalib/baz.jar",
|
||||||
})
|
})
|
||||||
|
|
||||||
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
`myapex.key`,
|
`myapex.key`,
|
||||||
`mysystemserverclasspathfragment`,
|
`mysystemserverclasspathfragment`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false)
|
||||||
|
assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true)
|
||||||
|
assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSystemserverclasspathFragmentNoGeneratedProto(t *testing.T) {
|
func TestSystemserverclasspathFragmentNoGeneratedProto(t *testing.T) {
|
||||||
@@ -251,7 +272,7 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
|
|||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithSystemserverclasspathFragment,
|
prepareForTestWithSystemserverclasspathFragment,
|
||||||
prepareForTestWithMyapex,
|
prepareForTestWithMyapex,
|
||||||
dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar"),
|
dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
apex {
|
apex {
|
||||||
name: "myapex",
|
name: "myapex",
|
||||||
@@ -289,11 +310,24 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "baz",
|
||||||
|
srcs: ["d.java"],
|
||||||
|
dex_preopt: {
|
||||||
|
profile_guided: true, // ignored
|
||||||
|
},
|
||||||
|
installable: true,
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
systemserverclasspath_fragment {
|
systemserverclasspath_fragment {
|
||||||
name: "mysystemserverclasspathfragment",
|
name: "mysystemserverclasspathfragment",
|
||||||
standalone_contents: [
|
standalone_contents: [
|
||||||
"foo",
|
"foo",
|
||||||
"bar",
|
"bar",
|
||||||
|
"baz",
|
||||||
],
|
],
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"myapex",
|
"myapex",
|
||||||
@@ -301,12 +335,19 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
|
ctx := result.TestContext
|
||||||
|
|
||||||
|
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
|
||||||
"etc/classpaths/systemserverclasspath.pb",
|
"etc/classpaths/systemserverclasspath.pb",
|
||||||
"javalib/foo.jar",
|
"javalib/foo.jar",
|
||||||
"javalib/bar.jar",
|
"javalib/bar.jar",
|
||||||
"javalib/bar.jar.prof",
|
"javalib/bar.jar.prof",
|
||||||
|
"javalib/baz.jar",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false)
|
||||||
|
assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true)
|
||||||
|
assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
|
func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
|
||||||
@@ -353,3 +394,11 @@ func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
|
|||||||
`prebuilt_foo`,
|
`prebuilt_foo`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName string, variant string, expected bool) {
|
||||||
|
dexpreopt := ctx.ModuleForTests(moduleName, variant).Rule("dexpreopt")
|
||||||
|
actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=")
|
||||||
|
if expected != actual {
|
||||||
|
t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user